// window.onload = function() {
	// resetPage();
// }
function resetPage(){

	reValue();
	if(document.UserForm.SOURCE.value !=""){		
		
		if(document.UserForm.MILITARY && document.UserForm.MILITARY.value ==""){			
			document.UserForm.MILITARY.value = "0";		
		}		
		document.UserForm.ZIP.focus();
	}	
}
function reSetValue(q1, q2, q3, q4){
	document.UserForm.ZIP.value = q2;
	document.UserForm.DEGREELEVEL.value = q3;	
}

function showAlert(type){
	switch(type){
		case 1:
			alert("Please enter a valid Zip Code. Thank You!");	
			break;
		case 2:
			alert("Please enter a valid Zip Code in the USA. Thank You!");	
			break;
		case 3:
			alert("We are sorry, there is no program matched. Thank You!");				
			break;
	}
	document.UserForm.ZIP.focus();
}
function validateSmall(form){
	
	if(form.SUBJECT.value ==''){
		alert("Please select a subject area that you are interested in");
		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 && document.UserForm.MILITARY.value ==""){
		alert("Please indicate whether you are associated with the U.S. military");
		form.MILITARY.focus();
		return false;	
	}
	if(checkzip(form.ZIP.value) == 0){
		alert("Please enter a valid zip code");
		form.ZIP.focus();
		return false;
	}
	return true;	
}

function validateForm1(form){
	
	if(validateSubArea(document.UserForm.SUBJECT) == false){
		alert("Please pick one or more subject areas that you are interested in");
		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 && document.UserForm.MILITARY.value ==""){
		alert("Please indicate whether you are associated with the U.S. military");
		form.MILITARY.focus();
		return false;	
	}
	if(checkzip(form.ZIP.value) == 0){
		alert("Please enter a valid zip code");
		form.ZIP.focus();
		return false;
	}
	return true;	
}
function validateSubArea(sel_area){
	for( i = 0; i<sel_area.length; i++){
		if(sel_area[i].checked){
			return true;
		}
	}
	return false;
}
function setSubject(str){
	var sel_area = document.UserForm.SUBJECT;
	if(str != ""){
		if(str == '1,2,3,4,5,6,7,8,9,10,11'){
			str = '12';
		}
		str = ","+str+",";			
		for(var i = 0; i<sel_area.length; i++){
			if(str.indexOf(","+sel_area[i].value+",") != -1){
				sel_area[i].checked = 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;
}
