// business rules
/*
CHANGE 21.nov.2005  J.Strelow
	added "Still in High School" to highereducation drop-down.  If they choose it, take them to the 
	NoThankYou page.. per docket #37750

*/
/* 
Change 7.Feb.2006 Gaurav Parikh
	added the alert message "We are Sorry, You do not meet our Requirements at this time!",
	if the above change by justin happens on Iframes.. as per ticket 1681
*/
var message = "We are Sorry, You do not meet our Requirements at this time!"
function CheckBusinessRules(oForm) {

	var bIsGood = true;

	//CHANGE 21.nov.2005
//	if (oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School") {
	if (oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "HighSchool" || oForm.highesteducation.value == "Still in High School") 
	{
			
		if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
		}
		else
		{
			bIsGood = false;
			//alert("Failed on highesteducation.");
			//oForm.action = "nothankyou.asp";
		}
	}
	// if they are not in the US and have checked no to the us citizen question then:
	if (oForm.country.options[oForm.country.selectedIndex].value != "United States" && oForm.uscitizen[1].checked == true) 
	{
		
		if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
		}
		else
		{
			bIsGood = false;
			//alert("Failed on uscitizen");
			//oForm.action = "nothankyou.asp";
		}
	}

	// IT education level
	if ( oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "IT")
	{
		if (oForm.kcitprogram.options[oForm.kcitprogram.selectedIndex].value == "MSIT") 
		{
			if (oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "GED" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "HighSchool" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "SomeCollegeLessThan2" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Associates" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School")
			{
				if(oForm.iFrame_AID) {
					alert(message);
					bIsGood = false;
					return false;
				}
				else	
				{
					bIsGood = false;
					//alert("Failed on GED/HighSchool education on BSN");
					//oForm.action = "nothankyou.asp";
				}
			}
		}
	}
	
	// LS education level
	if ( oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "LS")
	{

		if (oForm.kclsprogram.options[oForm.kclsprogram.selectedIndex].value == "MSLS" && 
			(oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "GED" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "HighSchool" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "SomeCollegeLessThan2" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Associates" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School"))
		{
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else	
			{
				bIsGood = false;
				//alert("Failed on GED/HighSchool education on BSN");
				//oForm.action = "nothankyou.asp";
			}
		}
	}

	// BIZ education level
	if ( oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "BIZ")
	{

		if (oForm.kcbizprogram.options[oForm.kcbizprogram.selectedIndex].value == "MSM" && 
			(oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "GED" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "HighSchool" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "SomeCollegeLessThan2" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Associates" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School"))
		
		{
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else	
			{
				bIsGood = false;
				//alert("Failed on GED/HighSchool education on BSN");
				//oForm.action = "nothankyou.asp";
			}
		}
	}

	//var nurGPA = document.getElementById("nursegpa");
	if ( oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "NUR")
	{
		if ( oForm.gpa[1].checked  || oForm.rnlicense[1].checked)
		{
			if(oForm.iFrame_AID) {
				alert(message);
				bIsGood = false;
				return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on gpa on NUR or EDU");
				//oForm.action = "nothankyou.asp";
			}
		}
		
		if ( oForm.BACHELOR[1].checked  || oForm.GPA2[1].checked || oForm.LICENSE[1].checked)
		{
			if(oForm.iFrame_AID) {
				alert(message);
				bIsGood = false;
				return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on BACHELOR/GPA2/LICENSE on NUR or EDU");
				//oForm.action = "nothankyou.asp";
			}
		}

		if (oForm.kubsnprogram.options[oForm.kubsnprogram.selectedIndex].value == "BSN" && 
			(oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "GED" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "HighSchool" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "SomeCollegeLessThan2" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE"))
		{
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else	
			{
				bIsGood = false;
				//alert("Failed on GED/HighSchool education on BSN");
				//oForm.action = "nothankyou.asp";
			}
		}

		if (oForm.kubsnprogram.options[oForm.kubsnprogram.selectedIndex].value == "MSNN" && 
			(oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "GED" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "HighSchool" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "SomeCollegeLessThan2" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Associates" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School"))
		{
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else	
			{
				bIsGood = false;
				//alert("Failed on GED/HighSchool education on BSN");
				//oForm.action = "nothankyou.asp";
			}
		}

	}
	
	// CJ form questions
	if( oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "CJ")
	{
		if( oForm.Associates[1].checked )
		{
			if(oForm.iFrame_AID) {
				alert(message);
				bIsGood = false;
				return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on Associates areastudy for CJ");
				//oForm.action = "nothankyou.asp";
			}
		}
		
		if ( oForm.Enforcement[1].checked )
		{
			if(oForm.iFrame_AID) {
				alert(message);
				bIsGood = false;
				return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on Enforcement areastudy for CJ");
				//oForm.action = "nothankyou.asp";
			}
		}

		if (oForm.kccjprogram.options[oForm.kccjprogram.selectedIndex].value == "MSCJ" && 
			(oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "GED" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "HighSchool" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "SomeCollegeLessThan2" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Associates" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School"))
		{
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else	
			{
				bIsGood = false;
				//alert("Failed on GED/HighSchool education on BSN");
				//oForm.action = "nothankyou.asp";
			}
		}

		if (oForm.kccjprogram.options[oForm.kccjprogram.selectedIndex].value == "CSTC" && 
			(oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School"))
		{
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else	
			{
				bIsGood = false;
				//alert("Failed on GED/HighSchool education on BSN");
				//oForm.action = "nothankyou.asp";
			}
		}
		if (oForm.kccjprogram.options[oForm.kccjprogram.selectedIndex].value == "MASC" && 
			(oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School"))
		{
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else	
			{
				bIsGood = false;
				//alert("Failed on GED/HighSchool education on BSN");
				//oForm.action = "nothankyou.asp";
			}
		}

	}

	//EDU
	if( oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "EDU")
	{
		if( oForm.degreeed[1].checked )
		{
			if(oForm.iFrame_AID) {
				alert(message);
				bIsGood = false;
				return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on degreeed areastudy for EDU");
				//oForm.action = "nothankyou.asp";
			}
		}
		
		if ( oForm.teach[1].checked )
		{
			if(oForm.iFrame_AID) {
				alert(message);
				bIsGood = false;
				return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on teach areastudy for EDU");
				//oForm.action = "nothankyou.asp";
			}
		}

	}
	
	//  MBA, MSM, MSCJ & MSLS & MSIT Form questions
	if( oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "BIZ" || oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "CJ" || oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "LS" || oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "IT") 
	{
		if( oForm.Bachelors[1].checked )
		{
			if(oForm.iFrame_AID) {
				alert(message);
				bIsGood = false;
				return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on Bachelors areastudy for BIZ/CJ/LS/IT");
				//oForm.action = "nothankyou.asp";
			}
		}
		
		if ( oForm.GPA_M[1].checked )
		{
			if(oForm.iFrame_AID) {
				alert(message);
				bIsGood = false;
				return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on GPA_M areastudy for BIZ/CJ/LS/IT");
				//oForm.action = "nothankyou.asp";
			}
		}
	
		if (oForm.kcbizprogram.options[oForm.kcbizprogram.selectedIndex].value == "MBA" && 
			(oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "GED" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "HighSchool" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "SomeCollegeLessThan2" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Associates" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE") || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School")
		{
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else	
			{
				bIsGood = false;
				//alert("Failed on GED/HighSchool education on BSN");
				//oForm.action = "nothankyou.asp";
			}
		}

		if (oForm.kcbizprogram.options[oForm.kcbizprogram.selectedIndex].value == "MSM" && 
			(oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "GED" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "HighSchool" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "SomeCollegeLessThan2" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Associates" || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "NONE") || oForm.highesteducation.options[oForm.highesteducation.selectedIndex].value == "Still in High School")
		{
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else	
			{
				bIsGood = false;
				//alert("Failed on GED/HighSchool education on BSN");
				//oForm.action = "nothankyou.asp";
			}
		}
	
	}

	//var nurLicense = document.getElementById("nurselicense");
	// masters code - see if one of the masters degrees is selected
	if ( (oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "BIZ" && 
			oForm.kcbizprogram.options[oForm.kcbizprogram.selectedIndex].value == "MBA") || 
		 (oForm.areastudy.options[oForm.areastudy.selectedIndex].value == "CJ" &&
			oForm.kccjprogram.options[oForm.kccjprogram.selectedIndex].value == "MSCJ") ) {
		// then the two qualifying questions are required:
		if ( oForm.Bachelors[1].checked || oForm.GPA_M[1].checked ) {
			// if no bachelor's degree or GPA too low
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;	
			return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on Bachelors areastudy for BIZ/CJ/MBA/MSCJ");
				//oForm.action = "nothankyou.asp"
			}
		}
	}
	// end masters code
	// check whether access to a computer
	if (oForm.havecomputer[1].checked == true) {
			
			if(oForm.iFrame_AID) {
			alert(message);
			bIsGood = false;
			return false;
			}
			else
			{
				bIsGood = false;
				//alert("Failed on Bachelors areastudy for BIZ/CJ/MBA/MSCJ");
				oForm.action = "nothankyou.asp";
			}
	}
	if (bIsGood) {
		//alert("PASSED form validation");
		oForm.action = "/include/SDC_Form_Submit.asp";
	// testing only:
	//		oForm.action = "postbacktester.asp";
	}
	return true;
}

function validateForm(oForm) {
	
	//12/16/08 set dynamic field values.
	SetFormValuesOnQuestions(oForm);
	
	// Russ S. Working
	// Form Validation on Question and program description field values
	var ProgramText = oForm.programCode.value.toLowerCase();
	//alert("ProgramText --> "+ProgramText);

	// Begin program/question validation
	if ( ProgramText =="cstc" || ProgramText =="masc") 
	{
		if (!validate('Associates','Do you possess a minimum of an associates degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education',oForm)) { return false; }
		if (!validate('Enforcement','Are you currently or were you recently employed in the law enforcement field',oForm)) { return false; }
	}
	if ( ProgramText =="msls" || ProgramText =="msit" ) 
	{
		if (!validate('Bachelors','Do you possess a bachelors degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education',oForm)) { return false; }
	}
	if ( ProgramText =="mba" || ProgramText =="msm" || ProgramText =="mscj" ) 
	{
		if (!validate('GPA_M','Do you possess a cumulative undergraduate grade point average (GPA) of 2.50 (out of 4.0)',oForm)) { return false; }
		if (!validate('Bachelors','Do you possess a bachelors degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education',oForm)) { return false; }
	}
	if ( ProgramText =="bsn" ) 
	{
		if (!validate('gpa','Did you graduate with a cumulative grade point average (GPA) of 2.5 or higher?',oForm)) { return false; }
		if (!validate('rnlicense','Do you posses a current, unencumbered license to practice as a registered nurse in at least one U.S. state, including the state in which a clinical will be completed',oForm)) { return false; }
	}
	if ( ProgramText =="msnn" ) 
	{
		if (!validate('BACHELOR','Do you posses a bachelors degree, with an upper-division major in nursing, from a regionally or nationally accredited institution by an agency recognized by the Department of Education',oForm)) { return false; }
		if (!validate('GPA2','Do you posses a cumulative grade point average (GPA) of 3.0 or higher (out of 4.0) for the second half of your undergraduate program (upper division nursing program)',oForm)) { return false; }
		if (!validate('LICENSE','Do you posses a current license as a registered nurse, without restrictions,in the state in which you reside',oForm)) { return false; }
	}

	if ( ProgramText =="mat" || ProgramText =="mati" || ProgramText =="mse") 
	{
		if (!validate('degreeed','Do you possess a bachelors degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education',oForm)) { return false; }
	}
	if ( ProgramText =="mshe" ) 
	{
		if (!validate('degreeed','Do you possess a bachelors degree from a regionally accredited institution or an institution accredited by an agency recognized by the Department of Education',oForm)) { return false; }
		if (!validate('teach','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',oForm)) { return false; }
	}
	// End program/question form validation
	
	if (!validate('firstname','First Name',oForm)) { return false; }
	if (!validate('lastname','Last Name',oForm)) { return false; }
	if (!validate('email','E-mail Address',oForm)) { return false; }
	if (!checkEmail(oForm.email.value)) {
		alert('Form Error:\nPlease use a valid E-mail address');
		return false;
	}
	if (!validate('dayphone','Daytime Phone',oForm)) { return false; }
	var sdayphonePhoneError = phoneIsValid(oForm.dayphone,'Daytime Phone');
	if (sdayphonePhoneError.length > 0) {
		alert(sdayphonePhoneError);
		return false;
	}
	if (!validate('evephone','Evening Phone',oForm)) { return false; }
		var sevephonePhoneError = phoneIsValid(oForm.evephone,'Evening Phone');
	if (sevephonePhoneError.length > 0) {
		alert(sevephonePhoneError);
		return false;
	}

	if (!validate('address','Address',oForm)) { return false; }
	if (!validate('city','City',oForm)) { return false; }
	if (!validate('kaplan_state','State',oForm)) { return false; }
	if (!validate('zip','Zip Code',oForm)) { return false; }
	if (!validate('country','Country',oForm)) { return false; }
	if (!validate('uscitizen','Whether you are a U.S. Citizen or permanent resident of the U.S.',oForm)) { return false; }
	if (!validate('military2','Whether you are an active duty member of the miltary',oForm)) { return false; }
	if (!validate('transfercredits','Whether you have any credits to transfer',oForm)) { return false; }
	if (!validate('havecomputer','Whether you will have access to a computer to take your courses',oForm)) { return false; }
	if (!validate('areastudy','Area of study',oForm)) { return false; }
	
	switch (oForm.areastudy.options[oForm.areastudy.selectedIndex].value) {
		case 'BIZ':
			if (!validate('highesteducation','Highest academic credential',oForm)) { return false; }
			if (!validate('kcbizprogram','Which program you are most interested in',oForm)) { return false; }
		break;
		case 'IT':
			if (!validate('highesteducation','Highest academic credential',oForm)) { return false; }
			if (!validate('kcitprogram','Which program you are most interested in',oForm)) { return false; }		
		break;
		case 'CJ':
			if (!validate('highesteducation','Highest academic credential',oForm)) { return false; }
			if (!validate('kccjprogram','Which program you are most interested in',oForm)) { return false; }
		break;
		case 'LS':
			if (!validate('highesteducation','Highest academic credential',oForm)) { return false; }
			if (!validate('kclsprogram','Which program you are most interested in',oForm)) { return false; }		
		break;
		case 'AS':
			if (!validate('highesteducation','Highest academic credential',oForm)) { return false; }
			if (!validate('kcasprogram','Which program you are most interested in',oForm)) { return false; }
		break;
		case 'NUR':
			if (!validate('highesteducation','Highest academic credential',oForm)) { return false; }
			if (!validate('kubsnprogram', 'Which program you are most interested in', oForm)) { return false;}
		break;
		case 'EDU':
			if (!validate('kueduprogram', 'Which program you are most interested in', oForm)) { return false;}
			if (!validate('highesteducation','Highest academic credential',oForm)) { return false; }
		break;
	}

	var iframe = CheckBusinessRules(oForm);
	if(!iframe)
	{
		if(oForm.iFrame_AID)
		{
			return false;  	
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}


	if (!CheckFilter(oForm)){
		return false;
	}		

	return true;  //reset it back!
	confirm("Everything is Ok! send form?");
	//return false;
}

// std validation

function CheckFilter(oForm) {
	var w1 = String.fromCharCode(115, 104, 105, 116);
	var w2 = String.fromCharCode(112, 105, 115, 115);
	var w3 = String.fromCharCode(99, 117, 110, 116);
	var w4 = String.fromCharCode(116, 105, 116, 115);
	var w5 = String.fromCharCode(97, 115, 115);
	var arrIW = new Array(w1,w2,w3,w4,w5);
	var w6 = String.fromCharCode(102, 117, 99, 107);
	var w7 = String.fromCharCode(99, 111, 99, 107, 115, 117, 99, 107, 101, 114);
	var w8 = String.fromCharCode(109, 111, 116, 104, 101, 114, 102, 117, 99, 107, 101, 114);
	var w9 = String.fromCharCode(97, 115, 115, 104, 111, 108, 101);
	var arrW = new Array(w6,w7,w8,w9);
	var curW = '';
	var curV = '';
	for(var i=0;i<arrIW.length;i++) {
		curW = arrIW[i];
		for (var f=0;f<oForm.length;f++) {
			if (oForm.elements[f].type == 'text') {
				curV = oForm.elements[f].value;
				curV = curV.toLowerCase();
				if (curV.indexOf(curW) > -1) {
					if (curV.indexOf(' ' + curW + ' ') > -1 || curV.indexOf(curW + ' ') == 0 || curV.indexOf(' ' + curW) == (curV.length - (curW.length + 1))) {
						alert('Form must not contain profane content');
						return false;
					}
				}
			}
		}
	}
	for (var i=0;i<arrW.length;i++) {
		curW = arrW[i];
		for (var f=0;f<oForm.length;f++) {
			if (oForm.elements[f].type == 'text') {
				curV = oForm.elements[f].value;
				curV = curV.toLowerCase();
				if (curV.indexOf(curW) > -1) {
					alert ('Error: Profane content not permitted.');
					return false;
				}
			}
		}
	}
	return true;
}

function SetFormValuesOnQuestions(oForm) {

	var sgpa = "";
	var sBachelor = "";

	// Initialize hidden form field for multiple form field answers
	document.contact.allgpa.value=sgpa;
	document.contact.allBachelor.value=sBachelor;	

	//alert("SetFormValuesOnQuestions");

	// Set GPA possible values
	if(oForm.GPA_M[0].checked) 
	{
		sgpa = oForm.GPA_M[0].value;
	}else if(oForm.GPA_M[1].checked)
	{
		sgpa = oForm.GPA_M[1].value;
	}

	if(oForm.GPA2[0].checked) 
	{
		sgpa = oForm.GPA2[0].value;
	}else if(oForm.GPA2[1].checked)
	{
		sgpa = oForm.GPA2[1].value;
	}
	
	if(oForm.gpa[0].checked) 
	{
		sgpa = oForm.gpa[0].value;
	}else if(oForm.gpa[1].checked)
	{
		sgpa = oForm.gpa[1].value;
	}
	// Set hidden form field for multiple form field answers
	document.contact.allgpa.value=sgpa;

	
	// Set Bachelors possible values
	if(oForm.Bachelors[0].checked) 
	{
		sBachelor = oForm.Bachelors[0].value;
	}else if(oForm.Bachelors[1].checked)
	{
		sBachelor = oForm.Bachelors[1].value;
	}

	if(oForm.degreeed[0].checked) 
	{
		sBachelor = oForm.degreeed[0].value;
	}else if(oForm.degreeed[1].checked)
	{
		sBachelor = oForm.degreeed[1].value;
	}
	
	// Set hidden form field for multiple form field answers
	document.contact.allBachelor.value=sBachelor;
}

function phoneIsValid(Obj,sLabel) {
	var sPhone = Obj.value;
	var sPhoneTemp = sPhone;
	sPhone = '';
	var sNumbers = '1234567890';
	for (var i=0;i<sPhoneTemp.length;i++) {
		if (sNumbers.indexOf(sPhoneTemp.charAt(i)) > -1) {
			sPhone += sPhoneTemp.charAt(i);
		}
	}
	if (sPhone.charAt(0) == '1' || sPhone.charAt(0) == 1) {
		sPhone = sPhone.substring(1,(sPhone.length));
	}
	if (sPhone.length != 10) {
		return sLabel + ' must be a 10 digit number\n';
	}
	else { 
		Obj.value = sPhone;
	}
	var sAreaCode = sPhone.substring(0,3);
	var sPrefix = sPhone.substring(3,6);
	var sNumber = sPhone.substring(6,10);
	ary7NotAllowed = new Array('1234567','4567890','0000000','1111111','2222222','3333333','4444444','5555555','6666666','7777777','8888888','9999999')
	ary3NotAllowed = new Array('000','911','555');
	for (var i=0;i<ary7NotAllowed.length;i++) {
		if (sPrefix.toString() + sNumber.toString() == ary7NotAllowed[i])  {
			return sLabel + ' must be a valid phone number\n';
		}
	}
	for (var i=0;i<ary3NotAllowed.length;i++) {
		if (sPrefix.toString() == ary3NotAllowed[i].toString()) {
			return sLabel + ' must be a valid phone number\n';
		}
	}
	return '';
}

function checkEmail(sEmail) {
	var AtSign = sEmail.indexOf('@');
	var Period = sEmail.lastIndexOf('.');
	if (AtSign > -1 && Period > -1 && AtSign < Period) {
		return true;
	}
	else {
		return false;
	}
}

function validate(sFieldName,sLabelName,oForm) {
	var oField = eval('oForm.' + sFieldName);
	var undefined;
	if (oField != undefined) {
	 	if (CheckRequired(oField) ) {
			return true;
		}
		else {
			if (oField[0] == undefined || oField.type == 'select-one') {
				alert('Form Error:\nPlease complete: ' + sLabelName + '.');
				oField.focus();
				return false;
			}
			else {
				if (!CheckRequired(oField)) {
					alert('Form Error:\nPlease complete: ' + sLabelName + '.');
					oField[0].focus();
					return false;
				}
			}
		}
	}
	else if (oField[0] != undefined) {
		if (!CheckRequired(oField)) {
					alert('Form Error:\nPlease complete: ' + sLabelName + '.');
					oField[0].focus();
					return false;
		}
	}
	else {
		alert('undefined field in form: ' + sFieldName);
		return false;
	}
}

function CheckRequired(Obj) {
	var ObjType;
	var retVal;
	var x = 0;
	var undefined;
	ObjType = Obj.type;
	/* types: password, radio, select-multiple, select-one, text, textarea */
	if (ObjType == undefined) {
		ObjType = Obj[0].type;
	}
	switch(ObjType) {
		case 'hidden':
			if(Obj.value.length < 1) {
				retVal = false;
			}
			else {
				retVal = true;
			}
		break;
		case 'text':
			if(Obj.value.length < 1) {
				retVal = false;
			}
			else {
				retVal = true;
			}
		break;
	
		case 'textarea':
			if(Obj.value.length < 1) {
				retVal = false;
			}
			else {
				retVal = true;
			}
		break;
	
		case 'password':
			if(Obj.value.length < 1) {
				retVal = false;
			}
			else {
				retVal = true;
			}
		break;
		case 'file':
			if(Obj.value.length < 1) {
				retVal = false;
			}
			else {
				retVal = true;
			}
		break;
		case 'select-one':
			if(Obj.selectedIndex > 0) {
				retVal = true;
			}
			else {
				retVal = false;
			}
		break;
		
		case 'select-multiple':
			retVal = false;
			for (var x=0;x<Obj.options.length;x++) {
				if (Obj[x].selected) {
					retVal = true;
				}
			}
		break;
		
		case 'radio':
			retVal = false;
			for(var x=0;x<Obj.length;x++) {
				if (Obj[x].checked) {
					retVal = true;
				}
			}
		break;
		
		case 'checkbox':
		
			if (navigator.appName == 'Netscape' && (navigator.appVersion.toString().substr(0,1) == '4' || navigator.appVersion.toString().substr(0,1) == '3' || navigator.appVersion.toString().substr(0,1) == '2')) {
				var arrNum = Obj.length - 1;
				var cbObj;
				if (Obj[arrNum] == undefined) {
					cbObj = Obj;
				}
				else {
					cbObj = Obj[arrNum];
				}
				var formObj = cbObj.form;
				var cbName = cbObj.name;
				var cbCount = 0;
				var cbFirstChecked = cbObj.checked;
				var cbOtherChecked = false;
				for (var cb=0;cb<formObj.length;cb++) {
					if (formObj.elements[cb].type == 'checkbox' && formObj.elements[cb].name == cbName) {
						cbCount++;
						if (formObj.elements[cb].checked) {
							cbOtherChecked = true;
							}
					}
				}
				if (cbCount > 0) {
					if (cbFirstChecked || cbOtherChecked) {
						retVal = true;
					}
					else {
						retVal = false;
					}
				}
				else {
					if (cbFirstChecked) {
						retVal = true;
					}
					else {
						retVal = false;
					}
				}
			}
			else {
			retVal = false;
			if (Obj.length != undefined) {
				for(var x=0;x<Obj.length;x++) {
					if (Obj[x].checked) {
						retVal = true;
					}
				}
			}
			else {
				if (Obj.checked == true) {
					retVal = true;
				}
			}
		}
		break;
		
		
		default:
			retVal = true;
	}
	return retVal;
}

// end std validation