//this files deals with functions & calls for the registration pages.

bindDOBAgeCheck = function(){
	var speed = 150;
	
		 $("#over16Check option:selected").each(function () {
	    	if($(this).text() !== "No"){
				$('#DOBHolder').hide();
			}
		});
	
	
	$('#over16Check').change( function(){ 
	    $("#over16Check option:selected").each(function () {
	    	if($(this).text() == "No"){
		    	$('#DOBHolder').show(speed);
			}else{
	            $('#DOBHolder').hide(speed);
	        }
		});
	} );
}

bindReferealSource = function(){
	var speed = 150;
	
	$("#referalContainer option:selected").each(function () {
	    	if($(this).text() !== "Other"){
				$('#otherReferalContainer').hide();
			}
	});
	
	$('#referalContainer').change( function(){ 
	    $("#referalContainer option:selected").each(function () {
	    	if($(this).text() == "Other"){
		    	$('#otherReferalContainer').show(speed);
			}else{
	            $('#otherReferalContainer').hide(speed);
	        }
		});
	} );
}

bindPermissionTest = function(){

if($('#parentsPermissionHolder').length !== 0){

	var speed = 300;
	
	$("#parentsPermissionHolder option:selected").each(function () {
	    	if($(this).text() !== "Yes"){
				$('#paymentDetails, .submitHolder').hide();
			}
	});

	
	
	
	$('#parentsPermissionHolder').change( function(){ 
	    $("#parentsPermissionHolder option:selected").each(function () {
	    	if($(this).text() == "Yes"){
		    	$('#paymentDetails, .submitHolder').show(speed);
			}else{
	            $('#paymentDetails, .submitHolder').hide(speed);
	        }
		});
	} );
	
	
	
	}
}

bindSavePrompt = function(){

	if($('#step5').length == 0){
	
	  window.onbeforeunload = confirmExit;
	  function confirmExit()
	  {
	    return "Any changes you have made, will not be saved if you leave the page now";
	  }
	  
	}
}

bindSafeClicks = function(){

	$('.submitHolder input, .backHolder').click(function(){ window.onbeforeunload = null; });

}

$(document).ready(function() {

	bindDOBAgeCheck();
	bindReferealSource();
	bindPermissionTest();
	bindSavePrompt();
	bindSafeClicks();
});

