var aoiNames = new Array();
var aoiProgramNames = new Array();
var aoiProgramIds = new Array();
var areaInterest = new Array();

function validateStep1(form) {

	if(!validateSchoolFormCO(form)){
		return false;
	}
	with(form){
		if(!validateDropDown(educationLevel)) {
			alert('Please choose your education level.');
			return false;
		}
		var eduVal = educationLevel.options[educationLevel.selectedIndex].value;
		if(eduVal == 'NONE' || eduVal == 'StillHighSchool'){
			alert('Kaplan currently does not accept students with this education level.');
			document.getElementById('educationLevel').options[0].selected = true;
			return false;
		}
	}
	return true;
}

function validateStep2(form) {
	
	with(form) {
		if(!validateDropDown(custom1)) {
			alert("Please choose your area of interest");
			return false;
		}
		if(!validateDropDown(programId)) {
			alert('Please choose a program.');
			return false;
		}
	}
	if(!validateKaplanSchoolFormCO(form)){
		return false;
	}
	with(form) {
		var pgId = programId.options[programId.selectedIndex].value;
		var aoi = programAOIArray[pgId];
		var programValue = programCodesArray[pgId];
		if(!validateProgramSpecificInputs(aoi, programValue, form)) {
			return false;
		}
	}
	        
	return true;
}

function validateThankYou(form) {
	
		     
	with(form) {
		var pgId = programId.options[programId.selectedIndex].value;
		var aoi = areaInterest[pgId];
		var programValue = programValues[pgId];
		educationLevel.value = '';
		if(!validateDropDown(educationLevel1)){
			alert('Please select your Education Level.');
			document.getElementById('custom1').disabled = true;
			document.getElementById('programId').disabled = true;			
			return false;
		}
		if(!validateDropDown(custom1)){
			alert('Please select an Area of Interest.');
			return false;
		}
		if(!validateDropDown(programId)){
			alert('Please select an Program of Interest.');
			return false;
		}		
		if(validateDropDown(educationLevel1)) {
			educationLevel.value = educationLevel1[educationLevel1.selectedIndex].value;
		}
		if(!validateThankYouProgramSpecificInputs(aoi, programValue, form)) {
			return false;
		}
		if(!validateEducationLevelThankYouPage(aoi, programValue, form)) {
			return false;
		}
	}
	if(document.getElementById("comments")!=null){
	var comment =document.getElementById("comments").value;
	 if(comment!=null&&trim(comment).length<3){
        alert("Please specify why you want to enroll in this University ?");
        return false;
		}
		 if(comment!=null&&trim(comment).length>500){
        alert("Why you want to enroll comment can only be upto 500 chars.");
        return false;
		}
	}
	return true;
}

function validateEducationLevelThankYouPage(aoi, programValue, form) {
	with(form) {
		if(programValue == 'PTC') {
			if(educationLevel1.options[educationLevel1.selectedIndex].value == 'NursingDiploma') {
				alert('You do not meet the academic requirements to apply for this program');
				return false;
			}
		}
	}
	return true;
}

function onProgramChange(programId) {
	var pgId = programId.options[programId.selectedIndex].value;
	
	var aoi = areaInterest[pgId];
	var programValue = programValues[pgId];
	/*if(!(aoi == 'Education' || aoi == 'Health Care Pathways')){
			populateEducation1Level(aoi, programValue);			
	}*/
	populateAOIForProgram(pgId);
	showHideDataThankYou(aoi, programValue);
}
function populateAOIForProgram(prgId) {
	for(var i = aoiProgramIds.length - 1; i >= 0; i--) {
		var programs = aoiProgramIds[i];
		
		for(var j = 0; j < programs.length; j++) {
			if(programs[j] == prgId) {
				document.getElementById('custom1').selectedIndex = i;
				onAOIChange(document.getElementById('custom1'));
				document.getElementById('programId').selectedIndex = j;
				return;
			}
		}
	}
}

function populateEducation1Level(aoi, progValue){
	var educationLevelDropDown = document.getElementById('educationLevel1');
	var degreeNameArray = new Array("Still in high school", "GED", "High school diploma", "Nursing Diploma",
		  	"Some college (fewer than two years)", "Associate's degree", "Bachelor's degree",
		  	"Post-graduate study", "Master's degree", "Doctoral degree", "None of the above");
	var degreeValueArray = new Array("StillHighSchool", "GED", "HighSchool", "NursingDiploma", "SomeCollegeLessThan2",
			"Associates", "Bachelors", "PostGrad", "Masters", "DoctoralDegree", "NONE");

	for(var i=educationLevelDropDown.length-1;i>0;i--){
		educationLevelDropDown.options[i] = null;
	}
	for(var index=0; index<degreeNameArray.length; index++){
		if(index ==3){
			if(progValue == 'BSN' || progValue == 'MSNN'){
				optGroup = document.createElement('option');
				optGroup.innerHTML = degreeNameArray[index];
				optGroup.value = degreeValueArray[index];
				optGroup.title = degreeNameArray[index];
				educationLevelDropDown.appendChild(optGroup);
				continue;
			}else{
				continue;
			}
		}	
		optGroup = document.createElement('option');
		optGroup.innerHTML = degreeNameArray[index];
		optGroup.value = degreeValueArray[index];
		optGroup.title = degreeNameArray[index];
		educationLevelDropDown.appendChild(optGroup);
	}
}

function validateThankYouProgramSpecificInputs(aoi, programValue, form) {
	with(form) {
		/*if(!(aoi == 'Nursing') && !(aoi == 'Health Sciences') && !(aoi == 'Education') &&
			!(aoi == 'Business and Finance') && !(aoi == 'Health Care Pathways') &&
			!(programValue == 'NewsweekMBA') && !(programValue == 'MBA') && !(programValue == 'MSM') &&
			!(programValue == 'MSCJ') && !(programValue == 'MSLS') && !(programValue == 'MASC') && !(programValue == 'CSTC'))
		{	
			if(!validateThankYouFieldSet1(form)) return false;
		}*/
		if(!(aoi == 'Education' || aoi == 'Health Care Pathways'))
		{	
			if(!validateThankYouFieldSet2(aoi, programValue, form)) return false;				
		}
		if(programValue == 'CMC' || programValue == 'GCM' || programValue == 'LCP' || 
				programValue == 'MCC' || programValue == 'PTC')
		{
			if(!validateThankYouFieldSet3(aoi, programValue, form)) return false;
		}
		
		if(programValue == 'CSTC' || programValue == 'MASC')
		{
			if(!validateThankYouFieldSet9(aoi, programValue, form)) return false;
		}
		
		if(programValue == 'BSN')
		{
			if(!validateThankYouFieldSet4(aoi, programValue, form)) return false;
		}
		
		if(programValue == 'ASN') {
			if(!validateThankYouFieldSet10(aoi, programValue, form)) return false;
		}
		
		if(programValue == 'MSNN') {
			if(!validateThankYouFieldSet4(aoi, programValue, form)) return false;
			if(!validateThankYouFieldSet11(aoi, programValue, form)) return false;
		}
		
		if(programValue == 'NewsweekMBA' || programValue == 'MBA' || programValue == 'MSCJ' 
			|| programValue == 'MSLS' || programValue == 'MSM' || programValue == 'MSIT')
		{
			if(!validateThankYouFieldSet5(aoi, programValue, form)) return false;
		}
		if(aoi == 'Teacher Education' || aoi == 'Higher Education Studies')
		{
			if(!validateThankYouFieldSet6(aoi, programValue, form)) return false;
		}
		if(!validateDropDown(custom12)) {
			alert('Please select your plan when are you looking to start.');
			return false;
		}
		if(!validateRadioButtonCondition(credits)) {
			alert("Please specify whether you have any credits to transfer.");
			return false;
		}
		
		if(!validateRadioButtonCondition(military)) {
			alert("Please specify whether you or your spouse are Active Duty, Reservist or Veteran of the U.S. Military.");
			return false;
		}
		if(!(aoi == 'Business and Finance' || aoi == 'Health Care Pathways'))
		{
			if(!validateThankYouFieldSet7(aoi, programValue, form)) return false;
		}
		else
		{
			if(!validateThankYouFieldSet8(aoi, programValue, form)) return false;
		}
		
		if(!canContact.checked) {
			alert("To request more information, you must check the disclaimer checkbox");
			return false;
		}
	}
	return true;
}

function validateThankYouFieldSet10(aoi, programValue, form) {
	with(form) {
		if(!validateRadioButtonCondition(registeredNurse)) {
			alert("Please specify are you willing to relocate to South Florida for up to 2 years to complete the clinical portion of this program");
			return false;
		}
		if(!validateRadioButton(registeredNurse, 2)) {
			alert("To apply for this program, you must be willing to relocate to South Florida for up to 2 years to complete the clinical portion of this program");
			return false;
		}
	}
	return true;
}

function validateThankYouFieldSet11(aoi, programValue, form) {
	with(form) {
		if(!validateRadioButtonCondition(custom2)) {
			alert("Please specify do you posses a bachelor's of science degree in Nursing");
			return false;
		}
		if(!validateRadioButton(custom2, 0)) {
			alert("To apply for this program, you must posses a bachelor's of science degree in Nursing");
			return false;
		}
	}
	return true;
}

function validateThankYouFieldSet9(aoi, programValue, form) {
	with(form) {
		if(!validateRadioButtonCondition(custom3)) {
			alert("Please specify do you possess a minimum of an associate's degree from a regionally accredited institution or an instition accredited by an agency recognized by the Department of Education");
			return false;
		}
		if(!validateRadioButton(custom3, 0)) {
			alert("To apply for this program, you must possess a minimum of an associate's degree from a regionally accredited institution or an instition accredited by an agency recognized by the Department of Education");
			return false;
		}
		if(!validateRadioButtonCondition(custom4)) {
			alert("Please specify are you currently or were you recently employed in the law enforcement field");
			return false;
		}
		if(!validateRadioButton(custom4, 0)) {
			alert("To apply for this program, you should be currently or recently employed in the law enforcement field");
			return false;
		}
	}
	return true;
}

function validateThankYouFieldSet2(aoi, programValue, form) {
	with(form) {
		if(aoi == 'Business and Finance') {
			if(!validateDropDown(educationLevel0)) {
				alert("You must specify the highest academic credential you possess");
				return false;
			}
			
			var eduVal = educationLevel0.options[educationLevel0.selectedIndex].value;
			if(eduVal == 'HSGED' || eduVal == 'SOME' || eduVal == 'AS') {
				alert("You do not meet the academic requirements to apply for this program");
				return false;
			}
		}
		else {
			if(!validateDropDown(educationLevel1)) {
				alert("You must specify the highest academic credential you possess");
				return false;
			}
			var eduVal = educationLevel1.options[educationLevel1.selectedIndex].value;
			if(programValue.indexOf('M')==0 || programValue.indexOf('Newsweek')==0){
				if(!(eduVal == 'Bachelors' || eduVal == 'PostGrad' || 
					eduVal == 'Masters' || eduVal == 'DoctoralDegree')) {
					alert("You do not meet the academic requirements to apply for this program");
					return false;
				}				
			}else if(programValue == 'BSN'){
				if(eduVal == 'GED' || eduVal == 'HighSchool' || eduVal == 'SomeCollegeLessThan2' || eduVal == 'NONE'){
					alert("You do not meet the academic requirements to apply for this program");
					return false;					
				}
			}else{
				if(eduVal == 'NONE' || eduVal == 'StillHighSchool'){
					alert("You do not meet the academic requirements to apply for this program");
					return false;
				}
			}

		}
	}
	return true;
}

function validateThankYouFieldSet3(aoi, programValue, form) {
	with(form) {
		if(!validateDropDown(educationLevel2)) {
			alert("You must specify the highest academic credential you possess");
			return false;
		}
		var eduVal = educationLevel2.options[educationLevel2.selectedIndex].value;
		if(eduVal == 'NoEduc') {
			alert("You do not meet the academic requirements to apply for this program");
			return false;
		}
	}
	return true;
}

function validateThankYouFieldSet4(aoi, programValue, form) {
	with(form) {
		if(!validateDropDown(contactMode)) {
			alert("Please specify preferred method of contact");
			return false;
		}
		if(!validateDropDown(bestCallTime)) {
			alert("Please specify best time to call");
			return false;
		}
		if(!validateRadioButtonCondition(registeredNurse)) {
			alert("Please specify whether you posses a current US license as a registered nurse without restriction");
			return false;
		}
		if(!validateRadioButton(registeredNurse, 0)) {
			alert("To apply for this program, you must posses a current US license as a registered nurse without restriction");
			return false;
		}
		if(!validateDropDown(custom17)) {
			alert("Please specify state where your current or primary RN license was issued");
			return false;
		}
	}
	return true;
}

function validateThankYouFieldSet5(aoi, programValue, form) {
	with(form) {
		if(!validateRadioButtonCondition(custom2)) {
			alert("Please specify do you possess a bachelor's degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education");
			return false;
		}
		if(!validateRadioButton(custom2, 2)) {
			alert("To apply for this program, you should possess a bachelor's degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education");
			return false;
		}
	}
	return true;
}

function validateThankYouFieldSet6(aoi, programValue, form) {
	with(form) {
		if(!validateRadioButtonCondition(custom3)) {
			alert("Please specify do you possess a bachelor's degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education");
			return false;
		}
		if(!validateRadioButton(custom3, 2)) {
			alert("To apply for this program, you should possess a bachelor's degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education");
			return false;
		}
		
		if(programValue == 'MA' || programValue == 'PDT') {
			if(!validateRadioButtonCondition(custom4)) {
				alert("Please specify whether you are a currently practicing K-12 Teacher");
				return false;
			}
			if(!validateRadioButton(custom4, 2)) {
				alert("To apply for this program, you should be currently practicing as a K-12 Teacher");
				return false;
			}
			if(!validateRadioButtonCondition(gpa)) {
				alert("Please specify whether you graduated with a cumulative GPA of 2.75 or higher");
				return false;
			}
			if(!validateRadioButton(gpa, 8)) {
				alert("To apply for this program, you should have graduated with a cumulative GPA of 2.75 or higher");
				return false;
			}
		}
		else if(programValue == 'MSHE') {
			/*if(!validateRadioButtonCondition(gpa)) {
				alert("Please specify do you possess a cumulative undergraduate grade point average (GPA) of 3.0 (out of 4.0) for the second part of your program or 2.5 (out of 4.0) for the entire program");
				return false;
			}
			if(!validateRadioButton(gpa, 10)) {
				alert("To apply for this program, you should possess a cumulative undergraduate grade point average (GPA) of 3.0 (out of 4.0) for the second part of your program or 2.5 (out of 4.0) for the entire program");
				return false;
			}*/
		}
		else {
			/*if(!validateRadioButtonCondition(custom4)) {
				alert("Please specify do you plan on doing your field work in a school district in Iowa, Washington, DC or Broward County in Florida");
				return false;
			}
			if(!validateRadioButton(custom4, 4)) {
				alert("To apply for this program, you should be ready to do your field work in a school district in Iowa, Washington, DC or Broward County in Florida");
				return false;
			}
			if(!validateRadioButtonCondition(gpa)) {
				alert("Please specify whether you graduated with a cumulative GPA of 2.5 or higher");
				return false;
			}*/
		}
	}
	return true;
}

function validateThankYouFieldSet7(aoi, programValue, form) {
	with(form) {
		/*if(!validateRadioButtonCondition(military)) {
			alert("Please specify whether you or your spouse are Active Duty, Reservist or Veteran of the U.S. Military.");
			return false;
		}*/
		/*if(!validateRadioButtonCondition(custom11)) {
			alert("Please specify whether you planning on using Military benefits to fund your education.");
			return false;
		}	*/	
		if(!validateRadioButtonCondition(citizenship)) {
			alert("Please specify whether you are a U.S. citizen or a national or permanent resident of the U.S.");
			return false;
		}
		if(!validateRadioButton(citizenship, 0)) {
			alert("To apply for this program, you should be a U.S. citizen or a national or permanent resident of the U.S.");
			return false;
		}
		if(!validateRadioButtonCondition(custom5)) {
			alert("Please specify whether you have access to a computer to take your courses");
			return false;
		}
		if(!validateRadioButton(custom5, 0)) {
			alert("To apply for this program, you should have access to a computer to take your courses");
			return false;
		}
		if(programValue == 'AASMA') {
			if(!validateRadioButtonCondition(custom6)) {
				alert("Please specify whether you are comfortable dealing with blood and other bodily fluids");
				return false;
			}
			if(!validateRadioButton(custom6, 0)) {
				alert("To apply for this program, you should be comfortable dealing with blood and other bodily fluids");
				return false;
			}
			if(!validateRadioButtonCondition(custom7)) {
				alert("Please specify whether you are comfortable working with needles");
				return false;
			}
			if(!validateRadioButton(custom7, 0)) {
				alert("To apply for this program, you should be comfortable working with needles");
				return false;
			}
			if(!validateRadioButtonCondition(custom8)) {
				alert("Please specify whether you would be comfortable assisting a physician with patient preparation, examinations, and patient relations");
				return false;
			}
			if(!validateRadioButton(custom8, 0)) {
				alert("To apply for this program, you should be comfortable assisting a physician with patient preparation, examinations, and patient relations");
				return false;
			}
		}
	}
	return true;
}

function validateThankYouFieldSet8(aoi, programValue, form) {
	with(form) {
		if(programValue == 'FNC' || programValue == 'LNC') {
			if(!validateRadioButtonCondition(registeredNurse)) {
				alert("Please specify whether you are a registered nurse licensed to practice in the U.S.");
				return false;
			}
			if(!validateRadioButton(registeredNurse, 6)) {
				alert("To apply for this program, you should be a registered nurse licensed to practice in the U.S.");
				return false;
			}
		}
		if(!validateRadioButtonCondition(custom6)) {
			alert("Please specify whether you are currently enrolled in another educational program");
			return false;
		}
		if(!validateRadioButton(custom6, 3)) {
			alert("To apply for this program, you should not be currently enrolled in another educational program");
			return false;
		}
		
		if(programValue == 'PTC' || programValue == 'MCC') {
			if(!validateRadioButtonCondition(custom9)) {
				alert("Please specify whether you have access to a computer to take your courses");
				return false;
			}
			if(!validateRadioButton(custom9, 0)) {
				alert("To apply for this program, you should have access to a computer to take your courses");
				return false;
			}
		}
		if(!validateDropDown(bestCallTime)) {
			alert("Please choose the best time to call you");
			return false;
		}
	}
	return true;
}
function onProgramChangeMain(programId) {
	var pgId = programId.options[programId.selectedIndex].value;
	
	var aoi = getAreaOfInterest(pgId);
	var programValue = programCodesArray[pgId];
	showHideData(aoi, programValue);
}

function resetCustomValues(form) {
	
	with(form) {
		clearAllRadioButtons(custom2);
		clearAllRadioButtons(gpa);
		clearAllRadioButtons(military);
		clearAllRadioButtons(registeredNurse);
		clearAllRadioButtons(canContact);
		clearAllRadioButtons(custom3);
		clearAllRadioButtons(custom4);
		clearAllRadioButtons(custom5);
		clearAllRadioButtons(custom6);
	}

}
function validateProgramSpecificInputs(aoi, programValue, form) {
	with(form) {
		if(programValue == 'CSTC' || programValue == 'MASC')
		{
			if(!validateFieldSet9(aoi, programValue, form)) return false;
		}
		
		if(programValue == 'BSN')
		{
			if(!validateFieldSet4(aoi, programValue, form)) return false;
		}
		
		if(programValue == 'ASN') {
			if(!validateFieldSet10(aoi, programValue, form)) return false;
		}
		
		if(programValue == 'MSNN') {
			if(!validateFieldSet11(aoi, programValue, form)) return false;
		}
		
		if(programValue == 'NewsweekMBA' || programValue == 'MBA' || programValue == 'MSCJ' 
			|| programValue == 'MSLS' || programValue == 'MSM' || programValue == 'MSIT')
		{
			if(!validateFieldSet5(aoi, programValue, form)) return false;
		}
		if(aoi == 'Teacher Education' || aoi == 'Higher Education Studies')
		{
			if(!validateFieldSet6(aoi, programValue, form)) return false;
		}
		if(!validateDropDown(custom12)) {
			alert('Please select your plan when are you looking to start.');
			return false;
		}
		if(!validateRadioButtonCondition(credits)) {
			alert("Please specify whether you have any credits to transfer.");
			return false;
		}		
		if(!validateRadioButtonCondition(military)) {
			alert("Please specify whether you or your spouse are Active Duty, Reservist or Veteran of the U.S. Military.");
			return false;
		}

		if(!(aoi == 'Health Care Pathways'))
		{
			if(!validateFieldSet7(aoi, programValue, form)) return false;
		}
		else
		{
			if(!validateFieldSet8(aoi, programValue, form)) return false;
		}
		
		if(document.getElementById("comments")!=null){
		var comment =document.getElementById("comments").value;
	 	if(comment!=null&&trim(comment).length<3){
     	   alert("Please specify why you want to enroll in this University ?");
    	    return false;
		}
		if(comment!=null&&trim(comment).length>500){
        alert("Why you want to enroll comment can only be upto 500 chars.");
        return false;
		}
	}
	if(! validateJoiningReason ('reasonForJoining') ) { return false; } if(! validateContactQuestion ('contactForQuality') ) { return false;}if(! validateMotivationQuestion ('motivationForQuality') ) {
			return false;
		}	 
		
		if(!canContact.checked) {
			alert("To request more information, you must check the disclaimer checkbox");
			return false;
		}
	}
	return true;
}

function validateFieldSet10(aoi, programValue, form) {
	with(form) {
		if(!validateRadioButtonCondition(registeredNurse)) {
			alert("Please specify are you willing to relocate to South Florida for up to 2 years to complete the clinical portion of this program");
			return false;
		}
	}
	return true;
}

function validateFieldSet11(aoi, programValue, form) {
	with(form) {
		if(!validateDropDown(contactMode)) {
			alert("Please specify preferred method of contact");
			return false;
		}
		if(!validateDropDown(bestCallTime)) {
			alert("Please specify best time to call");
			return false;
		}
		if(!validateRadioButtonCondition(custom2)) {
			alert("Please specify do you posses a bachelor's of science degree in Nursing");
			return false;
		}
		if(!validateRadioButton(custom2,0)) {
			alert("To apply for this program, you must posses a bachelor's of science degree in Nursing");
			return false;
		}
		if(!validateDropDown(custom17)) {
			alert("Please specify state where your current or primary RN license was issued");
			return false;
		}
		if(!validateRadioButtonCondition(registeredNurse)) {
			alert("Please specify whether you posses a current US license as a registered nurse without restriction");
			return false;
		}
		if(!validateRadioButton(registeredNurse, 0)) {
			alert("To apply for this program, you must posses a current US license as a registered nurse without restriction");
			return false;
		}
		
	}
	return true;
}
function validateFieldSet9(aoi, programValue, form) {
	with(form) {
		if(!validateRadioButtonCondition(custom3)) {
			alert("Please specify do you possess a minimum of an associate's degree from a regionally accredited institution or an instition accredited by an agency recognized by the Department of Education");
			return false;
		}
		if(!validateRadioButton(custom3,0)) {
			alert("To apply for this program, you must possess a minimum of an associate's degree from a regionally accredited institution or an instition accredited by an agency recognized by the Department of Education");
			return false;
		}
		if(!validateRadioButtonCondition(custom4)) {
			alert("Please specify are you currently or were you recently employed in the law enforcement field");
			return false;
		}
		if(!validateRadioButton(custom4,0)) {
			alert("To apply for this program, you must specify if you are currently or were you recently employed in the law enforcement field");
			return false;
		}
	}
	return true;
}


function validateFieldSet4(aoi, programValue, form) {
	with(form) {
		if(!validateDropDown(contactMode)) {
			alert("Please specify preferred method of contact");
			return false;
		}
		if(!validateDropDown(bestCallTime)) {
			alert("Please specify best time to call");
			return false;
		}
		if(!validateDropDown(custom17)) {
			alert("Please specify state where your current or primary RN license was issued");
			return false;
		}
		if(!validateRadioButtonCondition(registeredNurse)) {
			alert("Please specify whether you posses a current US license as a registered nurse without restriction");
			return false;
		}
		if(!validateRadioButton(registeredNurse, 0)) {
			alert("To apply for this program, you must posses a current US license as a registered nurse without restriction");
			return false;
		}
	}
	return true;
}

function validateFieldSet5(aoi, programValue, form) {
	with(form) {
		if(!validateRadioButtonCondition(custom2)) {
			alert("Please specify do you possess a bachelor's degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education");
			return false;
		}
		if(!validateRadioButton(custom2, 2)) {
			alert("To apply for this program, you must possess a bachelor's degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education");
			return false;
		}
	}
	return true;
}

function validateFieldSet6(aoi, programValue, form) {
	with(form) {
		if(programValue == 'MA' || programValue == 'MSHE' || programValue == 'MATI' || programValue == 'MAT' || programValue == 'MSE') {
			if(!validateRadioButtonCondition(custom3)) {
				alert("Please specify do you possess a bachelor's degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education");
				return false;
			}
			if(!validateRadioButton(custom3,2)) {
				alert("To apply for this program, you must specify if you possess a bachelor's degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education");
				return false;
			}
		}
	}
	return true;
}

function validateFieldSet7(aoi, programValue, form) {
	with(form) {
		if(!validateRadioButtonCondition(citizenship)) {
			alert("Please specify whether you are a U.S. citizen or a national or permanent resident of the U.S.");
			return false;
		}
		if(!validateRadioButtonCondition(custom5)) {
			alert("Please specify whether you have access to a computer to take your courses");
			return false;
		}
		if(!validateRadioButton(citizenship, 0)) {
			alert("To apply for this program, you must be a U.S. citizen or a national or permanent resident of the U.S.");
			return false;
		}
		if(!validateRadioButton(custom5, 0)) {
			alert("To apply for this program, you must have access to a computer to take your courses");
			return false;
		}
		if(programValue == 'AASMA') {
			if(!validateRadioButtonCondition(custom6)) {
				alert("Please specify whether you are comfortable dealing with blood and other bodily fluids");
				return false;
			}
			if(!validateRadioButtonCondition(custom7)) {
				alert("Please specify whether you are comfortable working with needles");
				return false;
			}
			if(!validateRadioButtonCondition(custom8)) {
				alert("Please specify whether you would be comfortable assisting a physician with patient preparation, examinations, and patient relations");
				return false;
			}
		}
	}
	return true;
}

function validateFieldSet8(aoi, programValue, form) {
	with(form) {
		if(programValue == 'FNC' || programValue == 'LNC') {
			if(!validateRadioButtonCondition(registeredNurse)) {
				alert("Please specify whether you are a registered nurse licensed to practice in the U.S.");
				return false;
			}
		}
		if(!validateRadioButtonCondition(custom6)) {
			alert("Please specify whether you are currently enrolled in another educational program");
			return false;
		}
		if(aoi == 'Business and Finance') {
			if(!validateRadioButtonCondition(custom7)) {
				alert("Please specify whether you have ever enrolled in an online education program");
				return false;
			}
		}
		else if(programValue == 'CMC' || programValue == 'GCM') {
			
		}
		else if(programValue == 'LCP') {
			
		}
		if(programValue == 'PTC' || programValue == 'MCC') {
			if(!validateRadioButtonCondition(custom9)) {
				alert("Please specify whether you have access to a computer to take your courses");
				return false;
			}
		}
		if(!validateDropDown(bestCallTime)) {
			alert("Please choose the best time to call you");
			return false;
		}
	}
	return true;
}
function showHideData(aoi, programValue) {
	
	for(var i = 13; i <= 88; i++) {
		hideLevel('div' + i);
		i++;
		i++;
	}
	hideLevel('div97');
	hideLevel('div100');
	
	
	/*if(!(aoi == 'Nursing') && !(aoi == 'Health Sciences') && !(aoi == 'Education') && !(aoi == 'Business and Finance') &&
			!(aoi == 'Health Care Pathways') && !(programValue == 'NewsweekMBA') && !(programValue == 'MBA') &&
			!(programValue == 'MSM') && !(programValue == 'MSCJ') && !(programValue == 'MSLS') && !(programValue == 'CSTC') && !(programValue == 'MASC'))
	{	
			showLevel('div10');
	}*/
	
	if(programValue == 'CSTC' || programValue == 'MASC') {
			showLevel('div13');
			showLevel('div16');
	}
	
	if(programValue == 'BSN') {
			showLevel('div19');
			showLevel('div22');
			showLevel('div34');
			showLevel('div31');
	}
	
	if(programValue == 'ASN') {
			showLevel('div25');
	}
	
	if(programValue == 'MSNN') {
			showLevel('div19');
			showLevel('div22');
			showLevel('div28');
			showLevel('div31');
			showLevel('div34');
	}
	
	if(programValue == 'NewsweekMBA' || programValue == 'MBA' || programValue == 'MSCJ' 
		|| programValue == 'MSLS' || programValue == 'MSM' || programValue == 'MSIT') {
			showLevel('div37');
		if(programValue == 'NewsweekMBA') {
			showLevel('div40');
		}
		else if(!(programValue == 'MSLS')){
			//showLevel('div43');
		}
	}
		
	if(aoi == 'Teacher Education' || aoi == 'Higher Education Studies') {
		if(programValue == 'MA' || programValue == 'MSHE' || programValue == 'MATI' || programValue == 'MAT' || programValue == 'MSE') {
			showLevel('div46');
		}
		if(programValue == 'MA') {
			showLevel('div49');
			showLevel('div52');
		}
		else if(programValue == 'MSHE') {
			//showLevel('div55');
		}
	}
	
	if(!(aoi == 'Health Care Pathways'))
	{
			//showLevel('div61');
			showLevel('div64');
			showLevel('div67');
			//showLevel('div63');
		
		if(programValue == 'AASMA') {
			showLevel('div70');
			showLevel('div73');
			showLevel('div76');
		}
	}
	else
	{
		if(programValue == 'FNC' || programValue == 'LNC') {
			showLevel('div79');
		}
			showLevel('div82');
		if(aoi == 'Business and Finance') {
			showLevel('div85');
			showLevel('div88');
		}
		if(programValue == 'PTC' || programValue == 'MCC') {
			showLevel('div97');
		}
			showLevel('div100');
	}
}
function showHideDataThankYou(aoi, programValue) {
	
	for(var i = 4; i <= 24; i++) {
		hideLevel('fieldSet' + i);
	}
	
	if(programValue == 'CSTC' || programValue == 'MASC') {
		showLevel('fieldSet21');
	}
	
	if(programValue == 'BSN') {
		showLevel('fieldSet4');
	}
	
	if(programValue == 'ASN') {
		showLevel('fieldSet22');
	}
	
	if(programValue == 'MSNN') {
		showLevel('fieldSet4');
		showLevel('fieldSet23');
	}
	
	if(programValue == 'NewsweekMBA' || programValue == 'MBA' || programValue == 'MSCJ' 
		|| programValue == 'MSLS' || programValue == 'MSM' || programValue == 'MSIT') {
		showLevel('fieldSet5');
		if(programValue == 'NewsweekMBA') {
			showLevel('fieldSet6');
		}
		else if(programValue != 'MASC' && programValue != 'MSLS' && programValue != 'MSIT'){
			//showLevel('fieldSet7');
		}
	}
		
	if(aoi == 'Teacher Education' || aoi == 'Higher Education Studies') {
		showLevel('fieldSet8');
		if(programValue == 'MA' || programValue == 'PDT') {
			showLevel('fieldSet9');
		}
		else if(programValue == 'MSHE') {
			//showLevel('fieldSet24');
		}
		else {
			//showLevel('fieldSet10');
		}
	}
	
	if(!(aoi == 'Health Care Pathways'))
	{
		showLevel('fieldSet11');
		
		if(programValue == 'AASMA') {
			showLevel('fieldSet12');
		}
	}
	else
	{
		if(programValue == 'FNC' || programValue == 'LNC') {
			showLevel('fieldSet13');
		}
		showLevel('fieldSet14');
		if(aoi == 'Business and Finance') {
			showLevel('fieldSet15');
		}
		else if(programValue == 'CMC' || programValue == 'GCM') {
			showLevel('fieldSet16');
		}
		else if(programValue == 'LCP') {
			showLevel('fieldSet17');
		}
		if(programValue == 'PTC' || programValue == 'MCC') {
			showLevel('fieldSet18');
		}
		showLevel('fieldSet19');
	}
}
function checkEducationLevelThankYou(eduValue){
	if(eduValue != ''){	
		if(eduValue == 'StillHighSchool' || eduValue == 'NONE'){
			alert("Kaplan currently does not accept students with this education level.");
			document.getElementById('educationLevel1').options[0].selected = true;
			document.getElementById('custom1').disabled = true;
			document.getElementById('programId').disabled = true;
			return false;
		}else{
			populateOnlineProgramsThankYou(eduValue);
			document.getElementById('custom1').disabled = false;
			document.getElementById('programId').disabled = false;
		}
	}else{
		alert("Please select your education level.");
		document.getElementById('custom1').disabled = true;
		document.getElementById('programId').disabled = true;		
		return false;
	}
	return true;
}
function populateOnlineProgramsThankYou(eduLevel)
{
	var campusId = document.getElementById('campusId').value;
	var url = '/gotoLink.htm?jsp=/colleges/kaplan/getPrograms.jsp&campus='+campusId+'&educationLevel='+eduLevel;
	http=getHttpRequestObj();
	if (http==null)
	{
	  alert ("Your browser does not support AJAX!");
	  return;
	} 
	http.onreadystatechange = function() {
								if(http.readyState == 4){
									var responseString = http.responseText;
									handleHttpResponseGetPrograms(responseString);
								}
							};
	http.open('GET', url, true);
	http.send(null);

}
function handleHttpResponseGetPrograms(responseString) {
	// code for IE
	var xmlObject;
	if (window.ActiveXObject) {
	  xmlObject=new ActiveXObject("Microsoft.XMLDOM");
	  xmlObject.async="false";
	  xmlObject.loadXML(responseString);
	 }
	// code for Mozilla, Firefox, Opera, etc.
	else {
		xmlObject = (new DOMParser()).parseFromString(responseString, "text/xml");
	}
	var locationsElements = xmlObject.getElementsByTagName('program');
	
	programNames.splice(0,programNames.length);
	programIds.splice(0,programIds.length);
	programAOI.splice(0,programAOI.length);
	
	
	for(var i = 0; i < locationsElements.length; i++) {
		var locationElement = locationsElements[i];
		programNames.push(locationElement.getAttribute('name'));
		programIds.push(locationElement.getAttribute('id'));
		programAOI.push(locationElement.getAttribute('aoi'));
		programValues[locationElement.getAttribute('id')] = locationElement.getAttribute('value');
		areaInterest[locationElement.getAttribute('id')] = locationElement.getAttribute('aoi');
	}
	populateProgramsForAOI();
   /* if(selectedProgramId != -1 && selectedProgramId != 0) {
    	onProgramChange(selectedProgramId);
	}*/
}
function populateProgramsForAOI() {
	// Remove all elements from the array
	aoiNames.splice(0, aoiNames.length);
	aoiProgramNames.splice(0, aoiProgramNames.length);
	aoiProgramIds.splice(0, aoiProgramIds.length);
	
	aoiNames.push('--------- Select One ---------');
	
	var programsArray = new Array();
	programsArray.push('--------- Select Program and Learning Format ---------');
	aoiProgramNames.push(programsArray);
	
	programsArray = new Array();
	programsArray.push('-1');
	aoiProgramIds.push(programsArray);
	
	aoiNames.push('Show All');
	
	programsArray = new Array();
	programsArray.push('--------- Select Program and Learning Format ---------');
	aoiProgramNames.push(programsArray);
	
	programsArray = new Array();
	programsArray.push('-1');
	aoiProgramIds.push(programsArray);
	
	// Add all AOIs
	for(var i = 0; i < programNames.length; i++) {
		var aoi = programAOI[i];
		if(aoi != '-1' && aoi != '') {
			var aoiIndex = getIndexOfElementInArray(aoi, aoiNames);
			
			if(aoiIndex == -1) {
				aoiNames.push(aoi);
				programsArray = new Array();
				programsArray.push('--------- Select Program and Learning Format ---------');
				aoiProgramNames.push(programsArray);
				
				programsArray = new Array();
				programsArray.push('-1');
				aoiProgramIds.push(programsArray);
			}
		}
	}
	
	for(var i = 0; i < programNames.length; i++) {
		var aoi = programAOI[i];
		
		if(aoi == '-1') {
			// It means that type of program has changed and this need to be added to all the aois.
			for(var j = 1; j < aoiNames.length; j++) {
				aoiProgramNames[j].push(programNames[i]);
				aoiProgramIds[j].push('-1');
			}
			
		}
		else {
			if(aoi != '') {
				var aoiIndex = getIndexOfElementInArray(aoi, aoiNames);
				var programs = aoiProgramNames[aoiIndex];
				programs.push(programNames[i]);
				
				programs = aoiProgramIds[aoiIndex];
				programs.push(programIds[i]);
			}
			aoiIndex = 1;
			var programs = aoiProgramNames[aoiIndex];
			programs.push(programNames[i]);
			
			programs = aoiProgramIds[aoiIndex];
			programs.push(programIds[i]);
		}
	}
	
	/*var custom1Val = document.getElementById('custom1').value;
	if(custom1Val == 'Campus') {
		for(var i = 1; i < aoiNames.length; i++) {
			var pgNames = aoiProgramNames[i];
			var pgIds = aoiProgramIds[i];
			
			for(var j = 1; j < programIds.length - 2; j++) {
				if(pgIds[j] == '-1' && pgIds[j+1] == '-1' && pgNames[j].toLowerCase().indexOf("campus programs") >= 0) {
					pgIds.splice(j, 1);
					pgNames.splice(j,1);
				}
			}
		}
	}*/

	removeAllOptions(document.getElementById('custom1'));
	addOption(document.getElementById('custom1'), aoiNames[0], '');
	for(var i = 1; i < aoiNames.length; i++) {
		addOption(document.getElementById('custom1'), aoiNames[i], aoiNames[i]);
	}
	onAOIChange(document.getElementById('custom1'));
}
function onAOIChange(aoiHandler) {
	removeAllOptions(document.getElementById('programId'));
	
	var aoiSelectedIndex = aoiHandler.selectedIndex;
	
	var names = aoiProgramNames[aoiSelectedIndex];
	var ids = aoiProgramIds[aoiSelectedIndex];
	
	for(var i = 0; i < names.length; i++) {
		addOption(document.getElementById('programId'), names[i], ids[i]);
	}
	
}
