var preValue;
$(document).ready(function(){
	
	preValue = $("#email").val();
	$("#email").focus(function(){
		
		if($("#email").val() == preValue) {
			$("#email").val("");
			$(this).removeClass("preText");
		}
	});
	
	$("#email").blur(function(){
		
		if($("#email").val() == preValue || $("#email").val() == "") {
			$(this).addClass("preText");
			$("#email").val(preValue);
		}
	});
});

function saveEmail()
{
	var email = $("#email").val();
	if(email.length == 0 || email == "e-mail"){
		$("#emailError").html("Please enter an e-mail address.");
		return;
	}
	
	$("#email").addClass("inputLoading");
	$('#submitButton').attr('disabled', "disabled");
	
	$.post("/",{email:email},function(data){
		$("#email").removeClass("inputLoading");
		$('#submitButton').removeAttr("disabled");
		if(data == "ok") {
			$("#register").fadeOut(function(){
				$(this).html("<div class='thanks'>Thanks!</div>");
				$(this).fadeIn();
			});
		}
		else {
			$("#emailError").html(data);
		}
	});
}
