window.onload = function() {
	resetPage();
}
function resetPage(){

	if(!document.UserForm.SOURCE.value.startsWith("EDG_---")){
		// if(document.UserForm.ONLINECAMPUS){
			// document.UserForm.ONLINECAMPUS[0].checked = true;
		// }
		document.UserForm.MILITARY.value = 0;
		document.UserForm.DEGREELEVEL.focus();
	}
	reValue();
	document.UserForm.ZIP.focus();
}
function reSetValue(q1, q2, q3, q4){
	if(document.UserForm.ONLINECAMPUS){
		if(q1 != ''){
			// if(document.UserForm.ONLINECAMPUS){
				// document.UserForm.ONLINECAMPUS[parseInt(q1)].checked = true;
			// }
		}
	}
	document.UserForm.ZIP.value = q2;
	document.UserForm.DEGREELEVEL.value = q3;
	document.UserForm.MILITARY.value = q4;
	
}

function showAlert(){
	alert("Please enter a valid Zip Code. Thank You!");	
	document.UserForm.ZIP.focus();
}
function validateForm1(form){

	// if(form.ONLINECAMPUS){
		// if(!form.ONLINECAMPUS[0].checked && !form.ONLINECAMPUS[1].checked && !form.ONLINECAMPUS[2].checked){
			// alert("Please indicate whether you are interested in online or campus based learning.");			
			// return false;
		// }
	// }
	
	if(checkzip(form.ZIP.value) == 0){
		alert("Please enter a valid zip code");
		form.ZIP.focus();
		return false;
	}	


	if(form.DEGREELEVEL.value ==''){
		alert("Please select the hightest level of education you have completed");
		form.DEGREELEVEL.focus();
		return false;
	}	
	
	if(document.UserForm.MILITARY.value ==""){
		alert("Please indicate whether you are associated with the U.S. military");
		return false;	
	}

	return true;	
}


function checkzip(value){
	if(trimString(value)==""){
		return 0;
	}
	else if(value.length != 5){
		return 0;
	}
	else{
		return validZip(value);
	}
}

function validZip(zipnum){

	var numExp = /[^0-9]/;
	if(numExp.test(zipnum)){
		return 0;
	}
	////doing zipcode check ////
	
	var invalidZip = Array(
		"000", "001", "002", "003", "004", "099", "213", "269", "343", "345",
		"348", "353", "419", "428", "429", "517", "518", "519", "529", "533",
		"536", "552", "568", "578", "579", "589", "621", "632", "642", "643",
		"659", "663", "682", "694", "695", "696", "697", "698", "699", "702",
		"709", "715", "732", "742", "771", "817", "818", "819", "839", "848",
		"849", "851", "854", "858", "861", "862", "866", "867", "868", "869",
		"872", "876", "886", "887", "888", "892", "896", "899", "909", "929",
		"987");
	
	if(invalidZip.contains(zipnum.substring(0,3))){
		return 0;
	}
	return 1;
}
