$(document).ready(function(){ 
	addEventListener('load', function() { setTimeout(hideAddressBar, 0); }, false); function hideAddressBar() { window.scrollTo(0, 1); }
	$('input').attr('autocomplete', 'off');
	$("#loginPost").submit(function (e) {
		e.preventDefault();
		$("#submit").fadeTo(100,0.4);
		$.ajax({
			type: "POST",
			url: this.action,
			data: $(this).serialize(),
			complete: function(xhr){
				if(xhr.status!=202) {
					$("#submit").fadeTo(100,1);
					$("#loginPost .warning,.info").remove();
					$("#loginPost").prepend("<p class=\"warning\" style=\"display:none;\">"+xhr.responseText+"</p>");
					$(".warning").fadeIn(200);
				} else { 
					window.location.replace(xhr.responseText);
				}
			}
		});
	});
	$("#forgotten").submit(function (e) {
		e.preventDefault();
		$("#retrieve").fadeTo(100,0.4);
		$.ajax({
			type: "POST",
			url: this.action,
			data: $(this).serialize(),
			complete: function(xhr){
				if(xhr.status!=202) {
					$("#retrieve").fadeTo(100,1);
					$("#forgotten .warning").remove();
					$("#forgotten").prepend("<p class=\"warning\" style=\"display:none;\">"+xhr.responseText+"</p>");
					$(".warning").fadeIn(200);
				} else { 
					$(".warning,.info").slideUp(300);
					$("#forgotten").html("<p class=\"big\">"+xhr.responseText+"</p>");
				}
			}
		});
	});
	$(".iforgot").live('click', function(e) {
		e.preventDefault();
		$("#innerbox").animate({"left": "-100%"},500,function() { 
			$("#submit").fadeTo(100,1); 
			$(".warning").slideUp(300);
		});
	});
	$(".retry").live('click', function(e) { 
		e.preventDefault(); 
		$("#innerbox").animate({"left": "0%"},500);
	});
});
