function resetErrors() {
	$('#error').hide();
	$('#error_description').html("");
}

function checkFormOld() {
	
	resetErrors();

	var errors = false;
	var email = $('#email').val();
	var dob_year = $('#dob_year').val();
	var dob_month = $('#dob_month').val();
	var dob_day = $('#dob_day').val();
	var error_description = $('#error_description').html();
	
	if(!email || email == '') {
		errors = true;
		error_description = error_description + "\r\n" + "Please enterss your email address.";
	}
	
	$.post("/actions/ajax_check_user_data.php", { email: email, dob_year: dob_year, dob_month: dob_month, dob_day: dob_day },
		function(data){
	  		if(data == 'email') {
	  			errors = true;
	  			error_description = error_description + "\r\n" + "That email address is already in use.";
	  		}
	  		if(data == 'dob') {
	  			errors = true;
	  			error_description = error_description + "\r\n" + "We're sorry, you must be at least 13 years of age to participate.";
	  		}
	  		
	  		if(errors) {
	  			$('#error_description').html(error_description);
	  			$('#error').show();
	  			return false;
	  		} else {
	  			$('#form_finalize').submit();
	  		}
		});

}

function checkForm() {
	
	resetErrors();

	var errors = false;
	var email = $('#email').val();
	var dob_year = $('#dob_year').val();
	var dob_month = $('#dob_month').val();
	var dob_day = $('#dob_day').val();
	var first_name = $('#first_name').val();
	var last_name = $('#last_name').val();
	var title_text = $('#title_text').val();
	var bio_text = $('#bio_text').val();
	var zipcode = $('#zipcode').val();
	var user_hash = $('#user_hash').val();
	
	var error_description = $('#error_description').html();
	var action = $('#action').val();
	var id = $('#id').val();	// Id of person we're voting for
	
	if(email == '') {
		errors = true;
		error_description = error_description + "\r\n" + "Please enterss your email address.";
	}
	
	$.post("/actions/ajax_check_user_data.php", { email:email, dob_year: dob_year, dob_month: dob_month, dob_day: dob_day, user_hash: user_hash },
		function(data){
	  		if(data == 'email') {
	  			errors = true;
	  			error_description = error_description + "\r\n" + "That email address is already in use.";
	  		}
	  		
	  		if(data == 'dob') {
	  			errors = true;
	  			error_description = error_description + "\r\n" + "We're sorry, you must be at least 13 years of age to participate.";
	  		}
	  		if(errors) {
	  			$('#error_description').html(error_description);
	  			$('#error').show();
	  			return false;
	  		} else {
	  			$.post("/actions/request_finalize_fb_account.php", { email:email, dob_year: dob_year, dob_month: dob_month, dob_day: dob_day, first_name: first_name, last_name: last_name, zipcode: zipcode, title_text:title_text, bio_text:bio_text, id:id, action:action, user_hash:user_hash },
			  		function(data){
			    		if(data == 'vote') {
			    			window.location.href = '/actions/request_vote_for_user.php?id=' + id;
			    		} else if(data == 'profile') {
			    			$.post("/actions/ajax_get_hash_from_id.php",
			    				function(data_hash) {
			    					window.location.href = '/profile/' + data_hash;
			    				}
			    			)
			    		}
			  		}
			  	);
	  		}
		});

}

function checkMarketingForm() {
	
	resetErrors();

	var errors = false;
	var email = $('#email').val();
	
	// Not vaildating right now
	var id = $('#id').val();

	$('#marketing_form').submit();

}


function flashScrollTo(id) {
	$('#wrapper').scrollTo($('#' + id),800);
}