// JavaScript Document
//Ellis MBA - Ticket 806 - bh - 2/27/2006

function isDate(dateStr) 
{
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); //check format
	if (matchArray == null) return false;
	var iMonth = matchArray[1]; // parse date into variables
	var iDay = matchArray[3];
	var iYear = matchArray[5];
	if (iMonth < 1 || iMonth > 12) return false;
	if (iDay < 1 || iDay > 31) return false;
	if ((iMonth==4 || iMonth==6 || iMonth==9 || iMonth==11) && iDay==31) return false;
	if (iMonth == 2) 
	{ // check for february 29th
		var isleap = (iYear % 4 == 0 && (iYear % 100 != 0 || iYear % 400 == 0));
		if (iDay > 29 || (iDay == 29 && !isleap)) return false;
	}
	return true;
}

function FixDate(oMonth, oDay, oYear) 
{
	var iMonth = parseInt(oMonth[oMonth.selectedIndex].value);
	var iDay = parseInt(oDay[oDay.selectedIndex].value);
	var iYear = parseInt(oYear[oYear.selectedIndex].value);
	var iMax = 31;
	if (iMonth == 2) 
	{
		if ((((iYear % 4) == 0) && ((iYear % 100) != 0)) || ((iYear % 400) == 0)) 
		{
			iMax = 29;
		}
		else 
		{
			iMax = 28;
		}
	}
	else if ((iMonth == 4) || (iMonth == 6) || (iMonth == 9) || (iMonth == 11)) 
	{
		iMax = 30;
	}
	oDay.length = iMax;
	for (var i=iMax; i > 28; i--) 
	{
		oDay[i - 1].text = i;
		oDay[i - 1].value = i;
	}
	if (iDay > iMax)
	{
		oDay.selectedIndex = (iMax - 1);
	}
}

function areaCodeIsValid(Obj)
{
	var sAreaCode = Obj.value;
	var bAreaCodeFound = false;
	
	//array contains all acceptable US Area Codes
	var aryAcceptableAreaCodes = new Array('201','202','203','205','206','207','208','209','210','212','213','214','215','216','217',
										   '218','219','224','225','228','229','231','234','239','240','248','251','252','253','254',
										   '256','260','262','267','269','270','276','281','283','301','302','303','304','305','307',
										   '308','309','310','312','313','314','315','316','317','318','319','320','321','323','325',
										   '330','334','336','337','339','340','347','351','352','360','361','386','401','402','404',
										   '405','406','407','408','409','410','412','413','414','415','417','419','423','425','430',
										   '432','434','435','440','443','469','470','478','479','480','484','501','502','503','504',
										   '505','507','508','509','510','512','513','515','516','517','518','520','530','540','541',
										   '551','559','561','562','563','567','570','571','573','574','580','585','586','601','602',
										   '603','605','606','607','608','609','610','612','614','615','616','617','618','619','620',
										   '623','626','630','631','636','641','646','650','651','660','661','662','670','671','678',
										   '680','682','684','691','692','701','702','703','704','706','707','708','712','713','714',
										   '715','716','717','718','719','720','724','727','731','732','734','740','754','757','760',
										   '763','765','770','772','773','774','775','781','785','786','787','801','802','803','804',
										   '805','806','808','810','812','813','814','815','816','817','818','828','830','831','832',
										   '843','845','847','848','850','856','857','858','859','860','862','863','864','865','870',
										   '878','901','903','904','906','907','908','909','910','912','913','914','915','916','917',
										   '918','919','920','925','928','931','936','937','939','940','941','947','949','952','954',
										   '956','970','971','972','973','978','979','980','985','989');
	
	for (var i=0; i<aryAcceptableAreaCodes.length; i++)
	{
		if (aryAcceptableAreaCodes[i] == sAreaCode)
		{
			bAreaCodeFound = true;
			break;
		}
	}
	return bAreaCodeFound;
}

function phoneIsValid(sPhone,sLabel,iLength) 
{
	//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.length != iLength)//10) 
	{
		return sLabel + ' must be a ' + iLength + ' 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','3456789','4567890')
	ary3NotAllowed = new Array('000','911','555','012','123');
	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 populateCountryCode(Obj)
{
	var arrCountryCode = new Array;
	
	arrCountryCode['US'] = '1';
	arrCountryCode['AU'] = '61';
	arrCountryCode['AT'] = '43';
	arrCountryCode['BE'] = '32';
	arrCountryCode['CA'] = '1';
	arrCountryCode['DK'] = '45';
	arrCountryCode['FI'] = '358';
	arrCountryCode['FR'] = '33';
	arrCountryCode['DE'] = '49';
	arrCountryCode['HK'] = '852';
	arrCountryCode['IS'] = '354';
	arrCountryCode['IR'] = '353';
	arrCountryCode['IT'] = '39';
	arrCountryCode['JP'] = '81';
	arrCountryCode['KR'] = '82';
	arrCountryCode['LU'] = '352';
	arrCountryCode['NL'] = '31';
	arrCountryCode['NO'] = '47';
	arrCountryCode['PT'] = '351';
	arrCountryCode['ES'] = '34';
	arrCountryCode['SE'] = '46';
	arrCountryCode['CH'] = '41';
	arrCountryCode['TW'] = '886';
	arrCountryCode['GB'] = '44';
	arrCountryCode['0'] = '';
//	arrCountryCode['OT'] = ''

	document.contactform.workcountrycode.value = arrCountryCode[Obj.value];
	document.contactform.c_country_code.value =  arrCountryCode[Obj.value];
	
	//if they choose a country other than US or Canada disable the State/Province field
	if (Obj.value == "US" || Obj.value == "CA")
	{
		document.contactform.state.disabled = false;
		document.contactform.province.disabled = true;
	}
	else
	{
		document.contactform.state.disabled = true;
		document.contactform.province.disabled = false;
	}
	
}

function CheckFilter(oForm) 
{
	var w1 = String.fromCharCode(50,51,32,102,97,107,101,32,115,116,114,101,101,116);
	var w2 = String.fromCharCode(107,105,115,115,109,121,97,115,115);
	var w3 = String.fromCharCode(49,50,51,32,110,111,119,104,101,114,101,32,112,108,97,99,101);
	var w4 = String.fromCharCode(108,101,115,98,111);
	var w5 = String.fromCharCode(97,110,97,108);
	var w6 = String.fromCharCode(109,32,111,32,116,32,104,32,101,32,114,32,102,32,117,32,99,32,107,32,101,32,114,32);
	var w7 = String.fromCharCode(97,114,115,101);
	var w8 = String.fromCharCode(109,97,115,116,117,114,98,97,116,101);
	var w9 = String.fromCharCode(97,115,115);
	var w10 = String.fromCharCode(109,111,116,104,101,114,102,117,99,107,101,114);
	var w11 = String.fromCharCode(97,115,115,104,111,108,101);
	var w12 = String.fromCharCode(110,105,103,103,101,114);
	var w13 = String.fromCharCode(98,97,108,108,115);
	var w14 = String.fromCharCode(111,115,97,109,109,97);
	var w15 = String.fromCharCode(98,97,115,116,97,114,100);
	var w16 = String.fromCharCode(112,101,99,107,101,114);
	var w17 = String.fromCharCode(98,105,110,32,108,97,100,101,110);
	var w18 = String.fromCharCode(112,101,110,105,115);
	var w19 = String.fromCharCode(98,105,116,99,104);
	var w20 = String.fromCharCode(112,105,109,112);
	var w21 = String.fromCharCode(98,108,111,119);
	var w22 = String.fromCharCode(112,105,115,115);
	var w23 = String.fromCharCode(98,111,111,98,105,101,115);
	var w24 = String.fromCharCode(112,111,111,110,116,97,110,103);
	var w25 = String.fromCharCode(98,111,111,98,115);
	var w26 = String.fromCharCode(112,111,111,112);
	var w27 = String.fromCharCode(98,117,116,116,115,110,105,102,102,101,114);
	var w28 = String.fromCharCode(112,111,111,112,101,114);
	var w29 = String.fromCharCode(99,108,105,116);
	var w30 = String.fromCharCode(112,111,111,112,121);
	var w31 = String.fromCharCode(99,111,99,107);
	var w32 = String.fromCharCode(112,114,105,99,107);
	var w33 = String.fromCharCode(99,111,99,107,115,117,99,107,101,114);
	var w34 = String.fromCharCode(112,114,111,115,116,105,116,117,116,101);
	var w35 = String.fromCharCode(99,114,97,112);
	var w36 = String.fromCharCode(112,117,115,115,121);
	var w37 = String.fromCharCode(99,117,109,98,114,101,97,116,104);
	var w38 = String.fromCharCode(114,101,99,116,117,109);
	var w39 = String.fromCharCode(99,117,110,116);
	var w40 = String.fromCharCode(115,99,114,111,116,117,109);
	var w41 = String.fromCharCode(100,105,99,107,104,101,97,100);
	var w42 = String.fromCharCode(115,101,109,101,110);
	var w43 = String.fromCharCode(100,105,108,100,111,115);
	var w44 = String.fromCharCode(115,101,120);
	var w45 = String.fromCharCode(102,97,103,103,111,116);
	var w46 = String.fromCharCode(115,104,105,116);
	var w47 = String.fromCharCode(102,97,107,101);
	var w48 = String.fromCharCode(115,108,117,116);
	var w49 = String.fromCharCode(102,97,114,116);
	var w50 = String.fromCharCode(115,112,97,109);
	var w51 = String.fromCharCode(102,97,114,116,104,101,97,100);
	var w52 = String.fromCharCode(115,117,99,107);
	var w53 = String.fromCharCode(102,117,99,107);
	var w54 = String.fromCharCode(115,117,99,107,32,109,101);
	var w55 = String.fromCharCode(102,117,99,107,101,114);
	var w56 = String.fromCharCode(116,101,115,116,105,99,108,101,115);
	var w57 = String.fromCharCode(106,101,114,107,111,102,102);
	var w58 = String.fromCharCode(116,105,116,115);
	var w59 = String.fromCharCode(106,105,103,103,101,114);
	var w60 = String.fromCharCode(116,119,97,116);
	var w61 = String.fromCharCode(106,105,115,109);
	var w62 = String.fromCharCode(117,112,121,111,117,114,115);
	var w63 = String.fromCharCode(106,105,122,122);
	var w64 = String.fromCharCode(117,114,105,110,101);
	var w65 = String.fromCharCode(106,105,122,122,117,109);
	var w66 = String.fromCharCode(118,97,103,105,110,97);
	var w67 = String.fromCharCode(106,111,107,101);
	var w68 = String.fromCharCode(119,104,111,114,101);

	var arrIW = new Array(w5,w7,w9,w44);
	var arrW = new Array(w1,w2,w3,w4,w6,w8,w10,w11,w12,w13,w14,w15,w16,w17,w18,w19,w20,w21,w22,w23,w24,w25,w26,w27,w28,w29,w30,w31,w32,w33,w34,w35,w36,w37,w38,w39,w40,w41,w42,w43,w45,w46,w47,w48,w49,w50,w51,w52,w53,w54,w55,w56,w57,w58,w59,w60,w61,w62,w63,w64,w65,w66,w67,w68);
	var arrRW = new Array('aaa','bbb','ccc','ddd','eee','fff','ggg','hhh','iii','jjj','kkk','lll','mmm','nnn','ooo','ppp','qqq','rrr','sss','ttt','uuu','vvv','www','xxx','yyy','zzz','asdf','asfd','jkl')
	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 (curW.length == curV.length || (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();
				
				/* check standalone word not embeded words, modified on 1-28-2005, Andy*/
				if (curV.indexOf(curW) > -1) 
				{
					if (curW.length == curV.length || (curV.indexOf(' ' + curW + ' ') > -1 || curV.indexOf(curW + ' ') == 0 || curV.indexOf(' ' + curW) == (curV.length - (curW.length + 1))) )
					{
						alert ('Error: Profane content not permitted.');
						return false;
					}
				}
			}
		}
	}
	for (var i=0;i<arrRW.length;i++) 
	{
		curW = arrRW[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: Invalid content not permitted.');
					return false;
				}
			}
		}
	}
	return true;
}


function ValidateData(oPrmForm) 
{ 
	if (!CheckFilter(oPrmForm)) 
	{
		return false;
	}
	var bBrowserGood = false;
	var bBrowserDrawsBordersCorrectly = false;
	var sBrowser = "Unknown";
	if (navigator.appName == "Netscape") 
	{
		sBrowser = "Netscape";
		if (parseFloat(navigator.appVersion) >= 5) 
		{
			bBrowserGood = true;
			bBrowserDrawsBordersCorrectly = true;
		}
	}
	else if (navigator.appName == "Microsoft Internet Explorer") 
	{
		sBrowser = "IE";
		if (parseFloat(navigator.appVersion) >= 4) 
		{
			bBrowserGood = true;
		}
	}
	
	var bReturn = true;
	var bFieldGood = true;var sErrors = '';
	
	bFieldGood = true;

	if (oPrmForm.country.selectedIndex > 0) 
	{
		//if they choose other -- display message
		if (oPrmForm.country.value == "OT")
		{
			alert("Thank you for your interest in receiving information about Ellis.\n  At this time, Ellis is only accepting applicants from the United States or Canada.");
			return false;
		}
	}
	else 
	{
		sErrors = sErrors + 'Country missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.country.style.backgroundColor = '#FFFFFF';
		}
		else 
		{
			oPrmForm.country.style.backgroundColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.firstname.value.length > 0) 
	{
	}
	else 
	{
		sErrors = sErrors + 'First Name missing\n';
		bFieldGood = false;
	}
	
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.firstname.style.borderLeftColor = 'buttonface';
			oPrmForm.firstname.style.borderTopColor = 'buttonface';
			oPrmForm.firstname.style.borderRightColor = 'buttonface';
			oPrmForm.firstname.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.firstname.style.borderLeftColor = 'tomato';
			oPrmForm.firstname.style.borderTopColor = 'tomato';
			oPrmForm.firstname.style.borderRightColor = 'tomato';
			oPrmForm.firstname.style.borderBottomColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.lastname.value.length > 0) 
	{
	}
	else 
	{
		sErrors = sErrors + 'Last Name missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.lastname.style.borderLeftColor = 'buttonface';
			oPrmForm.lastname.style.borderTopColor = 'buttonface';
			oPrmForm.lastname.style.borderRightColor = 'buttonface';
			oPrmForm.lastname.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.lastname.style.borderLeftColor = 'tomato';
			oPrmForm.lastname.style.borderTopColor = 'tomato';
			oPrmForm.lastname.style.borderRightColor = 'tomato';
			oPrmForm.lastname.style.borderBottomColor = 'tomato';
		}
	}
	
	
	
	bFieldGood = true;
	if (oPrmForm.address.value.length > 0) 
	{
	}
	else 
	{
		sErrors = sErrors + 'Street Address missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.address.style.borderLeftColor = 'buttonface';
			oPrmForm.address.style.borderTopColor = 'buttonface';
			oPrmForm.address.style.borderRightColor = 'buttonface';
			oPrmForm.address.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.address.style.borderLeftColor = 'tomato';
			oPrmForm.address.style.borderTopColor = 'tomato';
			oPrmForm.address.style.borderRightColor = 'tomato';
			oPrmForm.address.style.borderBottomColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.city.value.length > 0) 
	{
	}
	else 
	{
		sErrors = sErrors + 'City missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.city.style.borderLeftColor = 'buttonface';
			oPrmForm.city.style.borderTopColor = 'buttonface';
			oPrmForm.city.style.borderRightColor = 'buttonface';
			oPrmForm.city.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.city.style.borderLeftColor = 'tomato';
			oPrmForm.city.style.borderTopColor = 'tomato';
			oPrmForm.city.style.borderRightColor = 'tomato';
			oPrmForm.city.style.borderBottomColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.state.selectedIndex > 0) 
	{
	}
	else 
	{
		sErrors = sErrors + 'State missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.state.style.backgroundColor = '#FFFFFF';
		}
		else 
		{
			oPrmForm.state.style.backgroundColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.zip.value.length > 0) 
	{
	}
	else 
	{
		sErrors = sErrors + 'Zip Code missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.zip.style.borderLeftColor = 'buttonface';
			oPrmForm.zip.style.borderTopColor = 'buttonface';
			oPrmForm.zip.style.borderRightColor = 'buttonface';
			oPrmForm.zip.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.zip.style.borderLeftColor = 'tomato';
			oPrmForm.zip.style.borderTopColor = 'tomato';
			oPrmForm.zip.style.borderRightColor = 'tomato';
			oPrmForm.zip.style.borderBottomColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.email.value.length > 0) 
	{
		//regex email validation
		if (!(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(oPrmForm.email.value)))

		{
			sErrors = sErrors + 'Please enter a valid E-mail address\n';
		    bFieldGood = false;
		}
	}
	else 
	{
		sErrors = sErrors + 'E-mail Address missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
		oPrmForm.email.style.borderLeftColor = 'buttonface';
		oPrmForm.email.style.borderTopColor = 'buttonface';
		oPrmForm.email.style.borderRightColor = 'buttonface';
		oPrmForm.email.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.email.style.borderLeftColor = 'tomato';
			oPrmForm.email.style.borderTopColor = 'tomato';
			oPrmForm.email.style.borderRightColor = 'tomato';
			oPrmForm.email.style.borderBottomColor = 'tomato';
		}
	}

	
	bFieldGood = true;
	if (oPrmForm.workcountrycode.value.length > 0) 
	{
	}
	else 
	{
		sErrors = sErrors + 'Work Country Code missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.workcountrycode.style.borderLeftColor = 'buttonface';
			oPrmForm.workcountrycode.style.borderTopColor = 'buttonface';
			oPrmForm.workcountrycode.style.borderRightColor = 'buttonface';
			oPrmForm.workcountrycode.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.workcountrycode.style.borderLeftColor = 'tomato';
			oPrmForm.workcountrycode.style.borderTopColor = 'tomato';
			oPrmForm.workcountrycode.style.borderRightColor = 'tomato';
			oPrmForm.workcountrycode.style.borderBottomColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.workareacode.value.length > 0) 
	{
		bFieldGood = areaCodeIsValid(oPrmForm.workareacode);
		if (!bFieldGood)
		{
			sErrors = sErrors + 'Work Area Code is not valid\n';
		}
	}
	else 
	{
		sErrors = sErrors + 'Work Area Code missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.workareacode.style.borderLeftColor = 'buttonface';
			oPrmForm.workareacode.style.borderTopColor = 'buttonface';
			oPrmForm.workareacode.style.borderRightColor = 'buttonface';
			oPrmForm.workareacode.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.workareacode.style.borderLeftColor = 'tomato';
			oPrmForm.workareacode.style.borderTopColor = 'tomato';
			oPrmForm.workareacode.style.borderRightColor = 'tomato';
			oPrmForm.workareacode.style.borderBottomColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.workphone.value.length > 0) 
	{
		var sPhoneError;
		//Must be 7 characters for US
		//Must be 10 characters if not US
		if (oPrmForm.country.value == 'US')
		{
			sPhoneError =  phoneIsValid(oPrmForm.workphone.value,'Work phone',7);
		}
		else
		{
			sPhoneError =  phoneIsValid(oPrmForm.workphone.value,'Work phone',10);
		}
		
		if (sPhoneError.length > 0)
		{
			sErrors = sErrors + sPhoneError
			bFieldGood = false;
		}
		else
		{
			//oPrmForm.dayphone.value = oPrmForm.workareacode.value + oPrmForm.workphone.value;
		}
	}
	else 
	{
		sErrors = sErrors + 'Work Phone missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.workphone.style.borderLeftColor = 'buttonface';
			oPrmForm.workphone.style.borderTopColor = 'buttonface';
			oPrmForm.workphone.style.borderRightColor = 'buttonface';
			oPrmForm.workphone.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.workphone.style.borderLeftColor = 'tomato';
			oPrmForm.workphone.style.borderTopColor = 'tomato';
			oPrmForm.workphone.style.borderRightColor = 'tomato';
			oPrmForm.workphone.style.borderBottomColor = 'tomato';
		}
	}
	
		
	bFieldGood = true;
	if (oPrmForm.c_area_code.value.length > 0) 
	{
		bFieldGood = areaCodeIsValid(oPrmForm.c_area_code);
		if (!bFieldGood)
		{
			sErrors = sErrors + 'Other Area Code is not valid\n';
		}

	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.c_area_code.style.borderLeftColor = 'buttonface';
			oPrmForm.c_area_code.style.borderTopColor = 'buttonface';
			oPrmForm.c_area_code.style.borderRightColor = 'buttonface';
			oPrmForm.c_area_code.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.c_area_code.style.borderLeftColor = 'tomato';
			oPrmForm.c_area_code.style.borderTopColor = 'tomato';
			oPrmForm.c_area_code.style.borderRightColor = 'tomato';
			oPrmForm.c_area_code.style.borderBottomColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.c_phone.value.length > 0) 
	{
		var sPhoneError;
		//Must be 7 characters for US
		//Must be 10 characters if not US
		if (oPrmForm.country.value == 'US')
		{
			sPhoneError =  phoneIsValid(oPrmForm.c_phone.value,'Other phone',7);
		}
		else
		{
			sPhoneError =  phoneIsValid(oPrmForm.c_phone.value,'Other phone',10);
		}
		
		if (sPhoneError.length > 0)
		{
			sErrors = sErrors + sPhoneError
			bFieldGood = false;
		}
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.c_phone.style.borderLeftColor = 'buttonface';
			oPrmForm.c_phone.style.borderTopColor = 'buttonface';
			oPrmForm.c_phone.style.borderRightColor = 'buttonface';
			oPrmForm.c_phone.style.borderBottomColor = 'buttonface';
		}
		else 
		{
			oPrmForm.c_phone.style.borderLeftColor = 'tomato';
			oPrmForm.c_phone.style.borderTopColor = 'tomato';
			oPrmForm.c_phone.style.borderRightColor = 'tomato';
			oPrmForm.c_phone.style.borderBottomColor = 'tomato';
		}
	}
	
	bFieldGood = true;
	if (oPrmForm.education_level.selectedIndex > 0) 
	{
		if (oPrmForm.education_level.selectedIndex < 3) 
		{
			//some college, high school grad are not acceptable
			alert('Ellis College requires a Bachelor\'s degree or higher for admission to any Graduate level program.');
			return false;
		}
	}
	else 
	{
		sErrors = sErrors + 'Education Level missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.education_level.style.backgroundColor = '#FFFFFF';
		}
		else 
		{
			oPrmForm.education_level.style.backgroundColor = 'tomato';
		}	
	}

	
	bFieldGood = true;
	if (oPrmForm.yrs_exp_3[0].checked || oPrmForm.yrs_exp_3[1].checked)
	{
	}
	else
	{
		sErrors = sErrors + 'Do you have 3 or more years work experience? missing\n';
		bFieldGood = false;
	}


	bFieldGood = true;
	if (oPrmForm.enroll_timeframe.selectedIndex > 0) 
	{
	}
	else 
	{
		sErrors = sErrors + 'When do you plan to start? missing\n';
		bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.enroll_timeframe.style.backgroundColor = '#FFFFFF';
		}
		else 
		{
			oPrmForm.enroll_timeframe.style.backgroundColor = 'tomato';
		}
	}

	bFieldGood = true;
	if (oPrmForm.program.selectedIndex > 0 && oPrmForm.program.options[oPrmForm.program.selectedIndex].value != '0' && oPrmForm.program.options[oPrmForm.program.selectedIndex].value != '' ) {
	}
	else {
	sErrors = sErrors + 'Program of Interest missing\n';
	bFieldGood = false;
	}
	if (bBrowserGood) 
	{
		if (bFieldGood) 
		{
			oPrmForm.program.style.backgroundColor = '#FFFFFF';
		}
		else 
		{
			oPrmForm.program.style.backgroundColor = 'tomato';
		}
	}
	
	if (sErrors.length > 0) 
	{
		bReturn = false;
		alert('The following errors occurred:\n' + sErrors);
	}
	else
	{
		//reenable fields so they post
		oPrmForm.workcountrycode.disabled = false;
		oPrmForm.c_country_code.disabled = false;
	}
	return bReturn;
}
