$(document).ready(function(){

	var globalStep2 = "";
	var globalStep3 = "";
	
	$('#step1input').val(""); // Clear the inputs for step 1
	$('.step2input').val(""); // Clear inputs for step 2
	$('.step3input').val(""); // Clear inputs for step 3
	
	$('#step1input').change(function(){
	
	$('.step2').hide(); // Hide step2 title
	$('.step2input').hide(); // Hide all step 2 select box's
	$('.step2input').val(""); // Clear the value of step 2 select boxs
	
	$('.step3').hide(); // Hide step 3 title
	$('.step3input').hide(); // Hide all step 3 select box's
	$('.step3input').val("");  // Clear the values of all step 3 box's
			
		
		// Value = the value of the step 1 select box
		var value = $(this).val();
		
		/* 
		   This statement,
		   It takes the value of the select box.. and checks it against the following.
		   Then when it finds the 'case' that matches it will execute the code
		*/
		switch(value){
			case "GeneralEnglishElementarytoAdvanced":
				$('#step2input-1, .step2').show(); // The code here (and below) shows the select box specific to this selection on step 1
				break;
				
			case "GeneralEnglishElementarytoAdvancedSkillsHour":
				$('#step2input-2, .step2').show();
				break;
				
			case "IELTSInternationalEnglishLanguageTestingSystem":
				$('#step2input-3, .step2').show();
				break;
				
			case "IELTSInternationalEnglishLanguageTestingSystemSkills":
				$('#step2input-4, .step2').show();
				break;
			
			case "FCECambridgeFirstCertificate":
				$('#step2input-5, .step2').show();
				break;
			
			case "CAECambridgeAdvancedExamination":
				$('#step2input-6, .step2').show();
				break;
				
			case "CPECambridgeProficiencyExamination":
				$('#step2input-7, .step2').show();
				break;
				
			case "IELTSInternationalEnglishLanguageTestingSystemEve":
				$('#step2input-7, .step2').show();
				break;
			
			case "FrenchBeginnerstoIntermediate":
				$('#step2input-8, .step2').show();
				break;
				
			case "SpanishBeginnerstoIntermediate":
				$('#step2input-9, .step2').show();
				break;
				
			case "OnetooneEnglishClasses":
				$('#step2input-10, .step2').show();
				break;
				
			case "OnetooneFrenchSpanishorOtherLanguages":
				$('#step2input-11, .step2').show();
				break;
				
			/* If you want to add a new item to the step 1 select box, you need to add this in the same format as above:
				
				case: "THE VALUE OF THE OPTION ITEM":
					$('THE ITEM WHICH IT WILL SHOW FOR STEP 2, .step2').show();
					break;
					
			*/
		}		
		
	});
	
	$('.step2input').change(function(){
	
	globalStep2 = $(this).val();
	
	$('.step3').hide(); // Hide step 3 title
	$('.step3input').hide(); // Hide step 3 select box's
	$('.step3input').val(""); // Clear step3 select box's
			
			
		/*
		  The statement below is almost the same as the one above, it still checks the value of step 1 but it executes different code depending on which one is chosen.
		*/
		var value = $('#step1input').val();
		switch(value){
			case "GeneralEnglishElementarytoAdvanced":
				$('#step3input-1, .step3').show(); // This now shows the select box specific to this chosen item for step 3
				break;
				
			case "GeneralEnglishElementarytoAdvancedSkillsHour":
				$('#step3input-1, .step3').show();
				break;
				
			case "IELTSInternationalEnglishLanguageTestingSystem":
				$('#step3input-1, .step3').show();
				break;
				
			case "IELTSInternationalEnglishLanguageTestingSystemSkills":
				$('#step3input-1, .step3').show();
				break;
			
			case "FCECambridgeFirstCertificate":
				$('#step3input-2, .step3').show();
				break;
			
			case "CAECambridgeAdvancedExamination":
				$('#step3input-2, .step3').show();
				break;
				
			case "CPECambridgeProficiencyExamination":
				$('#step3input-2, .step3').show();
				break;
				
			case "IELTSInternationalEnglishLanguageTestingSystemEve":
				$('#step3input-2, .step3').show();
				break;
				
			case "FrenchBeginnerstoIntermediate":
				$('#step3input-3, .step3').show();
				break;
				
			case "SpanishBeginnerstoIntermediate":
				$('#step3input-3, .step3').show();
				break;
				
			case "OnetooneEnglishClasses":
				$('#step3input-4, .step3').show();
				break;
				
			case "OnetooneFrenchSpanishorOtherLanguages":
				$('#step3input-4, .step3').show();
				break;
				
			/* If you want to add a new item to the step 1 select box, you need to add this in the same format as above:
				
				case: "THE VALUE OF THE OPTION ITEM":
					$('THE ITEM WHICH IT WILL SHOW FOR STEP 3, .step3').show();
					break;
					
			*/
		}		
			
	});
	
	$('.step3input').change(function(){
		
		globalStep3 = $(this).val();
		
	});
	
	// Check all items are filled it.
	$('#form').submit(function(){
	
		var input1 = $('#step1input').val();
		var input2 = globalStep2
		var input3 = globalStep3;
		
			if(input1==""||input2==""||input3==""){
				$('#errorText').fadeIn();
				$('#errorText').show();
				return false;
			}
			else {
				$('#errorText').fadeOut();
				$('#errorText').hide();
				return true;
			}
	
	});
	
});