function whiten(which){
	document.getElementById(which).style.backgroundColor = 'white';
}
function validateForm(){
	if(!validateField("FName,First Name,y,0"))return false;
	if(!validateField("LName,Last Name,y,0"))return false;
	if(!validateField("CAddress,Current Mailing Address,y,0"))return false;
	if(!validateField("CCity,Current City,y,0"))return false;
	if(!validateField("CState,Current State,y,0"))return false;
	if(!validateField("CZip,Current Zip,y,zipOrPlus"))return false;
	if(!validateField("CCounty,Current County,y,0"))return false;
	if(!validateField("PermAddress,Permanent Mailing Address,y,0"))return false;
	if(!validateField("PermCity,Permanent City,y,0"))return false;
	if(!validateField("PermState,Permanent State,y,0"))return false;
	if(!validateField("PermZip,Permanent Zip,y,zipOrPlus"))return false;
	if(!validateField("PermCounty,Permanent County,y,0"))return false;
	if(!validateField("EMail,Email,y,eMail"))return false;
	if(!validateField("HomePhone,Home Phone,y,0"))return false;
	if(!validateField("L4,Last 4 digits of SSN,y,digitsFour"))return false;		
	if(!validateField("DOB,Date of Birth,y,mmddyyyy"))return false;
	if(!validateField("Gender,Gender,y,0"))return false;
	//if(!validateField("hispanic_yn,Are you Hispanic/Latino,y,0"))return false;
	if(!validateField("Ethnicity,Ethnicity,y,0")){
		document.getElementById('Ethnicity').style.backgroundColor = 'ccffcc';
		return false;
	}
	if(document.form1.Ethnicity[8].checked == true){
		if(!validateField("EthnicityOther,Ethnicity Other,y,0"))return false;
	}
	if(!validateField("SEARCHCategory,SEARCH Category,y,0"))return false;
	if(!validateField("EC1Name,Emergency Contact1 Name,y,0"))return false;
	if(!validateField("EC1HPhone,Emergency Contact1 Home Phone,y,0"))return false;
	if(!validateField("EC2Name,Emergency Contact2 Name,y,0"))return false;
	if(!validateField("EC2HPhone,Emergency Contact2 Home Phone,y,0"))return false;
	if(!validateField("HighSchool,High School,y,0"))return false;
	if(!validateField("HSGradMonth,Month of High School Graduation,y,digitsOneOrTwo"))return false;
	if(!validateField("HSGradYear,Year of High School Graduation,y,digitsFour"))return false;
	if(!validateField("HSCity,High School City,y,0"))return false;
	if(!validateField("HSState,High School State,y,0"))return false;
	if(!validateField("HSCounty,High School County,y,0"))return false;
	if(!validateField("EdStatus,Educational Status,y,0"))return false;
	if(document.form1.EdStatus[0].checked == true ){
		if(!validateField("College,College,y,0"))return false;
		if(!validateField("CollegeCity,College City,y,0"))return false;
		if(!validateField("CollegeState,College State,y,0"))return false;
		if(!validateField("CollegeCounty,College County,y,0"))return false;		
		if(!validateField("Program,Program,y,0"))return false;
		if(document.form1.Program[0].checked == true){
			if(!validateField("MedicalSpecialty,Medical Specialty,y,0"))return false;
			if(document.form1.MedicalSpecialty[2].checked == true){
				if(!validateField("MSother,Discipline or Program: Medical: other,y,0"))return false;
			}
		}else if(document.form1.Program[7].checked == true){
			if(!validateField("NPSpecialty,Discipline or Program: Nurse Practitioner: Specialty,y,0"))return false;
		}
		if(!validateField("YearInSchool,Year in school,y,0"))return false;		
		if(!validateField("EGradMonth,Expected Graduation Month,y,digitsOneOrTwo"))return false;
		if(!validateField("EGradYear,Expected Graduation Year,y,digitsFour"))return false;	
	}else if(document.form1.EdStatus[1].checked == true ){
		if(!validateField("Degree,Degree,y,0"))return false;
		if(!validateField("DegreeFrom,Degree awarded from,y,0"))return false;
		if(!validateField("DCity,City,y,0"))return false;
		if(!validateField("DState,State,y,0"))return false;		
		if(!validateField("CGradMonth,Graduation Month,y,digitsOneOrTwo"))return false;
		if(!validateField("CGradYear,Graduation Year,y,digitsFour"))return false;		
		if(!validateField("ResidencyProgram,Residency Program,y,0"))return false;
		if(!validateField("Institution,Institution,y,0"))return false;
		if(!validateField("YearInResidency,Year in Residency,y,0"))return false;
		if(!validateField("RECMonth,Expected Completion Month,y,digitsOneOrTwo"))return false;
		if(!validateField("RECYear,Expected Completion Year,y,digitsFour"))return false;
		if(!validateField("ProgramDirector,Program Director Name,y,0"))return false;
	}
	if(!validateField("InRotation,Are you placed in a Rotation,y,0"))return false;
	if(document.form1.InRotation[1].checked == true){
		if(!validateField("NEArea,What NE Area are you interested in,y,0"))return false;
	}else{
		if(!validateField("Facility,Facility,y,0"))return false;
		if(!validateField("Preceptor,Preceptor,y,0"))return false;
		if(!validateField("RCity,Rotation City,y,0"))return false;
		if(!validateField("RState,Rotation State,y,0"))return false;
		if(!validateField("RZip,Rotation Zip,y,zipOrPlus"))return false;
		if(!validateField("RCounty,Rotation County,y,0"))return false;
		if(!validateField("RBegins,Rotation begins,y,mmddyyyy"))return false;
		if(!validateField("REnds,Rotation ends,y,mmddyyyy"))return false;
		if(!validateField("RotAdvisor,Rotation Advisor,y,0"))return false;
		if(!validateField("AcademicCredit,Academic Credit,y,0"))return false;
		if(!validateField("Housing,Housing,y,0"))return false;
		if(document.form1.Housing[1].checked == true){
			if(!validateField("SpecialCircumstances,Special Circumstances,y,0"))return false;
			if(!validateField("Smoke,Smoke,y,0"))return false;
			if(!validateField("Allergies,Allergies,y,0"))return false;
			if(document.form1.Allergies[0].checked == true){
				if(!validateField("AllergicTo,AllergicTo,y,0"))return false;
			}
		}
	}
	if(!validateField("PriorExp,PriorExperience,y,0"))return false;
	if(!validateField("Goals,Goals,y,0"))return false;
	if(!validateField("CBPC,CBPC,y,0"))return false;
	if(!validateField("Hometown,Hometown,y,0"))return false;
	if(!validateField("CommunityInterests,Community Interests,y,0"))return false;
	if(!validateField("Obligation,Do you have an obligation upon graduation,y,0"))return false;
	if(document.form1.Obligation[0].checked == true){
		if(!validateField("ObligationName,Obligation Type,y,0"))return false;
		if(!validateField("ObligationLength,Number of years of Obligation,y,0"))return false;
		if(!validateField("ObligationTo,Obligation To,y,0"))return false;
	}
	startOfPhrase = "Please rank "
	if(!validateField("ClinicalExp,Clinical Experience,y,0"))return false;
	if(!validateField("SourceofIncome,Source of Income,y,0"))return false;
	if(!validateField("CommunityExp,Community Exerience,y,0"))return false;
	if(!validateField("CareerDecisionMaking,Career Decision Making,y,0"))return false;
	if(!validateField("CultExp,Cultural Experience,y,0"))return false;
	if(!validateField("IDExp,Interdisciplinary Experience,y,0"))return false;
	startOfPhrase = "Please provide a response for "
	var thisIndex = document.form1.OtherFactors.selectedIndex;
	if(document.form1.OtherFactors.options[thisIndex].value > ''){
		if(!validateField("WhatOther,What Other Factor,y,0"))return false;
	}
	if(!validateField("HowDidYouHear,How Did You Hear,y,0"))return false;
	if(document.form1.HowDidYouHear[4].checked == true){
		if(!validateField("HDYHOther,How Did You Hear: Other,y,0"))return false;
	}
	if(!validateField("Disadvantaged,Disadvantaged,y,0"))return false;
}
function lookupCounty(fieldPrefix){
	var cityFieldName = fieldPrefix + "City";
	var stateFieldName = fieldPrefix + "State";
	var city = document.form1[cityFieldName].value;
	var thisIndex = document.form1[stateFieldName].selectedIndex;
	var state = document.form1[stateFieldName][thisIndex].value;
	var oURL = "county_lookup.cfm?city=" + city + "&state=" + state + "&prefix=" + fieldPrefix;
	window.open(oURL,"county_lookup")
}
function fillPermAddress(){
	if(document.form1.PermAddressSame.checked == true){
		document.form1.PermAddress.value = document.form1.CAddress.value
		document.form1.PermCity.value = document.form1.CCity.value
		document.form1.PermState.value = document.form1.CState.value
		document.form1.PermZip.value = document.form1.CZip.value
		document.form1.PermCounty.value = document.form1.CCounty.value
		document.form1.PermAddress.style.backgroundColor = 'white';
		document.form1.PermCity.style.backgroundColor = 'white';
		document.form1.PermState.style.backgroundColor = 'white';
		document.form1.PermZip.style.backgroundColor = 'white';
		document.form1.PermCounty.style.backgroundColor = 'white';
	}
}
var arrCurrStuFields = new Array("College","CollegeAddress","CollegeCity","CollegeState","CollegeZip","CollegeCounty","Program","MedicalSpecialty","MSother","NPSpecialty","YearInSchool","EGradMonth","EGradYear")
var arrResFields =  new Array("Degree","DegreeFrom","DCity","DState","CGradMonth","CGradYear","ResidencyProgram","Institution","YearInResidency","RECMonth","RECYear","ProgramDirector","RPDEMail","RPDPhone")
var arrCurrStuAsterixes = new Array("astCollege","astCollegeCity","astCollegeCounty","astProgram","astYearInSchool","astEGradMonth")
var arrResAsterixes = new Array("astDegree","astDegreeFrom","astDCity","astDState","astCGradMonth","astResidencyProgram","astInstitution","astYearInResidency","astRECMonth","astProgramDirector")
var arrWhiteAsterixes = new Array("astMedicalSpecialty","astNPSpecialty","astMSother")
function enableDisable(which){
	if(which == 'MedStu'){
		for (var i = 0; i < arrCurrStuFields.length; i++){
			var thisField = arrCurrStuFields[i]
			if((document.form1[thisField].type == "text") || (document.form1[thisField].type == "textarea")
			||(document.form1[thisField].type == "file")||(document.form1[thisField].type == "password")|| (document.form1[thisField].type == "select-one")){
				document.form1[thisField].disabled = false;
				document.form1[thisField].style.backgroundColor  = 'white';
			}else{
				for (var j = 0; j < document.form1[thisField].length; j++){
					document.form1[thisField][j].disabled = false;
				}
			}
		}
		for (var i = 0; i < arrCurrStuAsterixes.length; i++){
			var thisField = arrCurrStuAsterixes[i];
			document.getElementById(thisField).style.color = "red";
		}
		for (var i = 0; i < arrResFields.length; i++){
			var thisField = arrResFields[i]
			if((document.form1[thisField].type == "text") || (document.form1[thisField].type == "textarea")
			||(document.form1[thisField].type == "file")||(document.form1[thisField].type == "password")|| (document.form1[thisField].type == "select-one")){
				if(document.form1[thisField].type == "select-one"){
					document.form1[thisField].value = 'NE';
				}else{
					document.form1[thisField].value = '';
				}
				document.form1[thisField].disabled = true;
				document.form1[thisField].style.backgroundColor = 'silver';
			}else{
				for (var j = 0; j < document.form1[thisField].length; j++){
					document.form1[thisField][j].checked = false;
					document.form1[thisField][j].disabled = true;
				}
			}
		}
		for (var i = 0; i < arrResAsterixes.length; i++){
			var thisField = arrResAsterixes[i];
			document.getElementById(thisField).style.color = "black";
		}
	}else{
		for (var i = 0; i < arrCurrStuFields.length; i++){
			var thisField = arrCurrStuFields[i]
			if((document.form1[thisField].type == "text") || (document.form1[thisField].type == "textarea")
			||(document.form1[thisField].type == "file")||(document.form1[thisField].type == "password")|| (document.form1[thisField].type == "select-one")){
				if(document.form1[thisField].type == "select-one"){
					document.form1[thisField].value = 'NE';
				}else{
					document.form1[thisField].value = '';
				}
				document.form1[thisField].disabled = true;
				document.form1[thisField].style.backgroundColor = 'silver';
			}else{
				for (var j = 0; j < document.form1[thisField].length; j++){
					document.form1[thisField][j].checked = false;
					document.form1[thisField][j].disabled = true;
				}
			}
		}
		for (var i = 0; i < arrCurrStuAsterixes.length; i++){
			var thisField = arrCurrStuAsterixes[i];
			document.getElementById(thisField).style.color = "black";
		}
		for (var i = 0; i < arrWhiteAsterixes.length; i++){
			var thisField = arrWhiteAsterixes[i];
			document.getElementById(thisField).style.color = "white";
		}
		for (var i = 0; i < arrResFields.length; i++){
			var thisField = arrResFields[i]
			if((document.form1[thisField].type == "text") || (document.form1[thisField].type == "textarea")
			||(document.form1[thisField].type == "file")||(document.form1[thisField].type == "password")|| (document.form1[thisField].type == "select-one")){
				document.form1[thisField].disabled = false;
				document.form1[thisField].style.backgroundColor = 'white';
			}else{
				for (var j = 0; j < document.form1[thisField].length; j++){
					document.form1[thisField][j].disabled = false;
				}
			}
		}
		for (var i = 0; i < arrResAsterixes.length; i++){
			var thisField = arrResAsterixes[i];
			document.getElementById(thisField).style.color = "red";
		}
	}
}
function asterixToggle(){
	if(document.form1.Program[0].checked == true){
		document.getElementById('astMedicalSpecialty').style.color = 'red'
		document.getElementById('astNPSpecialty').style.color = 'white'
		if(document.form1.MedicalSpecialty[2].checked == true){
			document.getElementById('astMSother').style.color = 'red'
		}else{
			document.getElementById('astMSother').style.color = 'white';
		}
	}else if(document.form1.Program[7].checked == true){
		document.getElementById('astMedicalSpecialty').style.color = 'white'
		document.getElementById('astMSother').style.color = 'white'
		document.getElementById('astNPSpecialty').style.color = 'red'
		document.form1.MedicalSpecialty[0].checked = false;
		document.form1.MedicalSpecialty[1].checked = false;
		document.form1.MedicalSpecialty[2].checked = false;
	}else{
		document.getElementById('astMedicalSpecialty').style.color = 'white'
		document.getElementById('astMSother').style.color = 'white'
		document.getElementById('astNPSpecialty').style.color = 'white'
		document.form1.MedicalSpecialty[0].checked = false;
		document.form1.MedicalSpecialty[1].checked = false;
		document.form1.MedicalSpecialty[2].checked = false;
	}
}
function yesNoEnableDisable(ynField,triggerIndex,fieldList){
	//ynField is the yes/no radio field
	//triggerIndex is whether it's yes or no that triggers the dependent fields
	//fieldList is the list of fields enabled/disabled by the trigger
	var arrFields = fieldList.split(",");
	if(document.form1[ynField][triggerIndex].checked == true){
		for (var i = 0; i < arrFields.length; i++){
			var thisField = arrFields[i]
			var thisAsterix = 'ast' + thisField;
			if((document.form1[thisField].type == "text") || (document.form1[thisField].type == "textarea")
			||(document.form1[thisField].type == "file")||(document.form1[thisField].type == "password")|| (document.form1[thisField].type == "select-one")){
				document.form1[thisField].disabled = false;
				document.form1[thisField].style.backgroundColor  = 'white';
				document.getElementById(thisAsterix).style.color = "red";
			}else{
				document.getElementById(thisAsterix).style.color = "red";
				for (var j = 0; j < document.form1[thisField].length; j++){
					document.form1[thisField][j].disabled = false;
				}
			}
		}
	}else{
		for (var i = 0; i < arrFields.length; i++){
			var thisField = arrFields[i]
			var thisAsterix = 'ast' + thisField;
			if((document.form1[thisField].type == "text") || (document.form1[thisField].type == "textarea")
			||(document.form1[thisField].type == "file")||(document.form1[thisField].type == "password")|| (document.form1[thisField].type == "select-one")){
				if(document.form1[thisField].type == "select-one"){
					document.form1[thisField].value = 'NE';
				}else{
					document.form1[thisField].value = '';
				}
				document.form1[thisField].disabled = true;
				document.form1[thisField].style.backgroundColor  = 'silver';
				document.getElementById(thisAsterix).style.color = "white";
			}else{
				document.getElementById(thisAsterix).style.color = "white";
				for (var j = 0; j < document.form1[thisField].length; j++){
					document.form1[thisField][j].checked = false;
					document.form1[thisField][j].disabled = true;
				}
			}
		}
	}
}
function asterixToggle2(triggerField,triggerIndex,targetAsterix){
	if(document.form1[triggerField][triggerIndex].checked == true){
		document.getElementById(targetAsterix).style.color = "red";
	}else{
		document.getElementById(targetAsterix).style.color = "white";
	}
}
function asterixToggle3(triggerField,triggerIndex,targetAsterix){
	if(document.form1[triggerField].selectedIndex == triggerIndex){
		document.getElementById(targetAsterix).style.color = "white";
	}else{
		document.getElementById(targetAsterix).style.color = "red";
	}
}
