var ageChoice = null;
var showSignup = function() {
	$('.content').hide();
	$('#frame .framepage').hide();
	if (ageChoice == null) {
		$('#frame .enterdob').show();
	} else if (ageChoice == 1) {
		 $('#frame .signup-parent').show();
	} else if (ageChoice == 2) {
		 $('#frame .signup').show();
	}
	$('#frame').show();
}
var closeSignup = function() {
	$('#frame').hide();
	$('.content').show();
}
var showLegal = function(){
	$("#legal-handle").mouseover(function(){
		$("#footer-container .text").fadeIn("fast");

		$("#footer-container").mouseleave(function(){
			$(this).find(".text").fadeOut("fast");
		}); 
	}); 
};
$(function() {
	showLegal();
});
var enterDob = function() { 
	$.post(URL_BASE, { action: 'enterDob', dob_month: $('input[name=dob_month]').val(), dob_day: $('input[name=dob_day]').val(), dob_year: $('input[name=dob_year]').val() },
		 function(data){
			 if (data.error.length > 0) {
			   alert(data.error);
			 } else {
				 $('#frame .framepage').hide();
			   if (data.parent == true) {
					 $('#frame .signup-parent').show();
					 ageChoice = 1;
				 } else {
					 $('#frame .signup').show();
					 ageChoice = 2;
				 }
			 }
		 }, "json");
}
var signupParent = function() {
	$.post(URL_BASE, { action: 'signupParent', emailaddress: $('.signup-parent input[name=emailaddress]').val(), parentemailaddress: $('.signup-parent input[name=parentemailaddress]').val() },
		 function(data){
			 if (data.error.length > 0) {
			   alert(data.error);
			 } else if (data.accepted == true) {
				 $('#frame .framepage').hide();
				 $('.signup-parent input[name=emailaddress]').val('');
				 $('.signup-parent input[name=parentemailaddress]').val('')
				 $('#frame .thankyou-parent').show();
			 }
		 }, "json");
}
var signup = function() {
	$.post(URL_BASE, { action: 'signup', emailaddress: $('.signup input[name=emailaddress]').val() },
		 function(data){
			 if (data.error.length > 0) {
			   alert(data.error);
			 } else if (data.accepted == true) {
				 $('#frame .framepage').hide();
				 $('.signup input[name=emailaddress]').val('');
				 $('#frame .thankyou').show();
			 }
		 }, "json");
}
