/////////////////////////////////////////////////////////////////
// FileName : register.js
// Description : Javascript functions for registration page
// Requires : 
//		jquery/jquery-1.2.3.pack.js
/////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
// initialize the page and connection the events handlers
/////////////////////////////////////////////////////////////
$(document).ready(function() {
	$(window).unload(checkForNavigation);
	$('form').submit(submitRegistrationForm);
	
	$('#consumerSigninLink').click(function() {
		$('a#signInLink').addClass('showTab');
		$('#quickSignInFormWrapper').fadeIn('normal');
	});	
	
	$('#regConsumerForgotPasswordLink').click(function() {
		$('#consumerForgotPassword').modal({
			containerId: 'consumerForgotPasswordModalContainer',
			close: false				
		});
	});

});

/////////////////////////////////////////////////////////////
// submitRegistrationForm
// For any forms on the registration page, this sets formSubmitted
// to true for checking by unload function.. to prevent
// redirection to the secondchance page
/////////////////////////////////////////////////////////////
var formSubmitted = 0;
function submitRegistrationForm() {
	formSubmitted = 1;
}

/////////////////////////////////////////////////////////////
// onUnload
// Checks that form was submitted via form post, if not
// redirects to secondchance page
/////////////////////////////////////////////////////////////
function checkForNavigation(){
	if ( formSubmitted == 0 ) {
		window.location = '/secondchance/';
	}
}

