var loginRedirect = 'index.php';
$(document).ready(function(){

	$("#dim").css("height", $(document).height());

	$(".loginLink").click(function(){
		loginRedirect  = $(this).attr("href");
		$('html').animate({
			scrollTop: $("#fullWidth").offset().top
		}, 400);
		$("#dim").slideDown();
		return false;
	});

	$(".close").click(function(){
			$("#dim").slideUp();
		return false;
	});


	$("#login").ajaxForm({
		dataType: 'json',
		beforeSubmit: function() {
			  $("#error").show();
			$("#errorText").html("");
			$("#progress").show();
		},
		success: function(response) {
			if(response.status == "error") {
				$("#progress").hide();
				$("#errorText").html(response.error).show();
			} else {
				$("#dim").slideUp();
				$("#error").hide();
				top.location = loginRedirect;
			}
		}
	}); 
});

$(window).bind("resize", function(){
		$("#dim").css("height", $(window).height());
});

