(function($){

$.fn.placeholder = function(){

	return this.each(function(){

		var $this = $(this),
			$label = $(this).prev();
		
		$this.parents("form").attr("autocomplete","off");
		
		if($this.val() != "") {
			$label.hide();
		}

		$this.keyup(function(){
			if($this.val() == "")
				$label.show();
			else
				$label.hide();
		});
		$this.focusin(function(){
			if($this.val() == "")
				$label.addClass("focus").fadeTo(250,.5);
				$this.addClass("focus");
		});
		$this.focusout(function(){
			if($this.val() == "") {
				$label.removeClass("focus").stop(true,true).css('opacity','1').show();
				$this.removeClass("focus");
			}
		});
		$this.keypress(function(e){
			if (e.keyCode == '9') return;

			$label.hide();
		});

	});
};

})(jQuery);

$(document).ready(function() {
	$('#schedule li > a').each(
	   function() {
		var span = $(this).next("span").html();
		if(span != "") {
			$(this).simpletip({
				position: 'right',
				offset: [0, 10],
				content: '<strong>' + $(this).text() + '</strong><p>' + span + '</p>'
			});
		}
	   }
	);
	
	$("#submit").click(function(){
		$(this).parent().submit();
		return false;
	});
	
	$("#comments-submit").click(function(){
		$("#comment_form").submit();
		return false;
	});
	
	$("#login-form input").placeholder();
	
	$("#forgot-password").click(function(e){
		e.preventDefault();
		var h = $("#login-form > form").outerHeight();

		$("#login-form").height(h);
		
		$("#login-form > form").fadeTo(200,0,function(){
			$(this).remove();
		});
		$("#login-form").load("/investors/forgot/p/",function(){
			h = $("#login-form > form").outerHeight();
			
			$("#login-form input").placeholder();
			$("#login-form").animate({"height": h},250);
			$("#login-form > form").css("opacity","0").fadeTo(250,1);
			
			$("#forgot-username").click(function(e){
				e.preventDefault();

				$("#login-form > form").fadeTo(200,0,function(){
					$(this).remove();
				});
				$("#login-form").load("/investors/forgot/u/",function(){

					$("#login-form input").placeholder();
					
					$("#login-form > form").css("opacity","0").fadeTo(250,1);

				});
			});
		});
	});
	
	
});