/* :::::: AUTO TAB FUNCTIONS :::::: */
var phone_field_length=0;

function TabNext(obj,event,len,next_field)
{
	if(document.all)
	{	
		var key_pressed = window.event.keyCode;
		
		if (event == "down")
		{
			phone_field_length=obj.value.length;
		}
		else if (event == "up")
		{
			if (key_pressed != 8 && key_pressed != 9 && key_pressed != 16 && key_pressed != 17 && key_pressed != 18 && key_pressed != 35 && key_pressed != 36 && key_pressed != 45 && key_pressed != 46 && key_pressed != 144)
			{
				if (obj.value.length != phone_field_length)
				{
					phone_field_length=obj.value.length;
					if (phone_field_length == len)
					{
						next_field.focus();
					}
				}
			}
			else
			{
				window.event.cancelBubble = true;
			}
		}
	}
	else
	{
		return;
	}
}

/* :::::: FORM VALIDATION :::::: */

// Validator Object code
//___________________________________________
function AreaZipMismatch(str)
{
	if(confirm(str))
	{
		document.uData.areazipoverride.value='yes';
		document.uData.submit();
	}
}

function Validator()
{
	this.isValid = true;
	this.fullMatchProfanity = new Array('shit','piss','cunt','tits','ass');
	this.partialMatchProfanity = new Array('fuck','cocksucker','motherfucker','asshole');
	this.validNumbers = '0123456789';
	this.validPhoneCharacters = '0123456789';
	this.validZipCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789- ';
	this.validTextCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ';
}

new Validator();

function V_raiseError(message)
{
	if (this.isValid) alert(message);
	this.isValid = false;
}

function V_containsProfanity(field)
{
	for (var i=0; i<this.fullMatchProfanity.length; i++)
	{
		if (field.toLowerCase() == this.fullMatchProfanity[i]) return true;
	}
	for (var i=0; i<this.partialMatchProfanity.length; i++)
	{
		if (field.toLowerCase().indexOf(this.partialMatchProfanity[i]) > -1) return true;
	}
	return false;
}

function V_validateText(text, label)
{
	if (!this.isValid) return;
	if (text.value == '' || text.value.replace(/ /gi,'')=='')
	{
		this.raiseError('Please enter your ' + label + '.');
		text.value='';
		text.focus();
	}
	else if (this.containsProfanity(text.value))
	{
		this.raiseError(label + ' must not contain profane content.');
		text.select();
	}
}
// for text only like first and last name
function V_validateTextChars(text, label)
{
	if (!this.isValid) return;
	if (text.value == '' || text.value.replace(/ /gi,'')=='' || text.value.length < 2)
	{
		this.raiseError('Please enter your ' + label + '.');
		text.value='';
		text.focus();
		
	}
	else if (this.containsProfanity(text.value))
	{
		this.raiseError(label + ' must not contain profane content.');
		text.select();
	}
	else if (!this.isTextValid(text.value))
	{
		this.raiseError(label + ' contains invalid characters.');
		text.select();
	}
}

function V_validatePhone(phone, label)
{
	if (!this.isValid) return;
	
	if (phone.value == '')
	{
		this.raiseError(label + ' phone number must not be blank.');
		phone.focus();
	}
	else if (phone.value.length < 7)
	{
		this.raiseError(label + ' phone number should have at least seven numbers.');
		phone.focus();
	}
	else if (!this.isPhoneNumeric(phone.value))
	{
		this.raiseError(label + ' phone number should have only numbers.');
		phone.focus();
	}
}

function V_validateZip(zip, label)
{
	if (!this.isValid) return;
	if (zip.value == '')
	{
		this.raiseError(label + ' must not be blank.');
		zip.focus();
	}
	else if (zip.value.length < 5)
	{
		this.raiseError(label + ' must be at least five characters.');
		zip.focus();
	}
	else if (!this.isZipValid(zip.value.toLowerCase()))
	{
		this.raiseError(label + ' contains invalid characters.');
		zip.select();
	}
}

function V_validateZipCanada(zip, label)
{
	if (!this.isValid) return;
	if (zip.value == '')
	{
		this.raiseError(label + ' must not be blank.');
		zip.focus();
	}
	else if (zip.value.length < 6)
	{
		this.raiseError(label + ' must be at least six characters.');
		zip.focus();
	}
	else if (!this.isZipValid(zip.value.toLowerCase()))
	{
		this.raiseError(label + ' contains invalid characters.');
		zip.select();
	}
}

function V_validateNumericOnly(myField, label)
{
	if (!this.isValid) return;
	if (myField.value == '')
	{
		this.raiseError(label + ' must not be blank.');
		myField.focus();
	}
	else if (myField.value.length < 4)
	{
		this.raiseError(label + ' must be four characters long.');
		myField.focus();
	}
}

function V_validateEmail(email, label)
{
	if (!this.isValid) return;
	if (email.value == '')
	{
		this.raiseError(label + ' must not be blank.');
		email.focus();
	}
	// Email validation
	if (email.value != '')
	{
		var str = email.value;
		var instancecounter = 0;

		str += '';
		intAt = str.indexOf( '@', 1 );		// the "@"
		intDot = str.lastIndexOf( '.' );		// the last "."
		namestr = str.substring( 0, intAt );		// everything before the "@"
		domainstr = str.substring( intAt +1, str.length );		// everything after the "@"
		toplevelstr = str.substring( intDot +1, str.length);		// everything after the last "."
		
		if ((str.indexOf('test@') > -1) || (str.indexOf('@test.') > -1))
		{
			this.raiseError(label + ' appears to be invalid.');
			email.select();
		}
		
		if ((str.indexOf(" ")!=-1) || (intAt == -1) || (intDot == -1 ) || (namestr.length == 0) || (domainstr.length == 0) || (intAt > intDot) || (domainstr.indexOf(".") <= 0) || (toplevelstr.length <= 1))
		{
			this.raiseError(label + ' appears to be invalid.');
			email.select();
		} 
		else
		{
			// iterate through email address checking for
			// more than 1 @ sysmbol, or none at all
			for ( i = 0; i < str.length; i++ )
			{
				if ((str.substring(i,i+1)) == "@" )
				{
					instancecounter = instancecounter + 1;
				}
			}
			// Check to see if we have none, or more than one @ symbol
			if ((instancecounter > 1) || (instancecounter == 0 ))
			{
				this.raiseError(label + ' appears to be invalid.');
				email.select();
			}
		}
	}
}

function V_isNumeric(field)
{
	for (var i=0; i<field.length; i++)
	{
		if (this.validNumbers.indexOf(field.charAt(i),0) == -1) return false;
	}
	return true;
}

function V_isPhoneNumeric(field)
{
	for (var i=0; i<field.length; i++)
	{
		if (this.validPhoneCharacters.indexOf(field.charAt(i),0) == -1) return false;
	}
	return true;
}

function V_isZipValid(field)
{
	for (var i=0; i<field.length; i++)
	{
		if (this.validZipCharacters.indexOf(field.charAt(i),0) == -1) return false;
	}
	return true;
}

function V_isTextValid(field)
{
	for (var i=0; i<field.length; i++)
	{
		if (this.validTextCharacters.indexOf(field.charAt(i),0) == -1) return false;
	}
	return true;
}

Validator.prototype.raiseError = V_raiseError;
Validator.prototype.validateText = V_validateText;
Validator.prototype.validateTextChars = V_validateTextChars;
Validator.prototype.validatePhone = V_validatePhone;
Validator.prototype.validateZip = V_validateZip;
Validator.prototype.validateZipCanada = V_validateZipCanada;
Validator.prototype.validateNumericOnly = V_validateNumericOnly;
Validator.prototype.isNumeric = V_isNumeric;
Validator.prototype.isZipValid = V_isZipValid;
Validator.prototype.isTextValid = V_isTextValid;
Validator.prototype.isPhoneNumeric = V_isPhoneNumeric;
Validator.prototype.validateEmail = V_validateEmail;
Validator.prototype.containsProfanity = V_containsProfanity;


//---------- custom functions ----------

//global variable to hold value of the user selected degree
var strSelectedWaldenDegree = '';

function checkCountry()
{
	var frm = document.uData;
	
	if (frm.country_code[frm.country_code.selectedIndex].value != '' && frm.country_code[frm.country_code.selectedIndex].value != 'US' && frm.country_code[frm.country_code.selectedIndex].value != 'CA')
	{
		alert('Thank you for your interest in receiving information about Walden University.  At this time, Walden is only accepting applicants from the United States and Canada.');
		frm.country_code.focus();
	}
}

function setCurWaldenDegree()
{
	strSelectedWaldenDegree = document.uData.program_code[document.uData.program_code.selectedIndex].value;
	
	// If user selects a nursing degree, display nursing popup
	if (
		(strSelectedWaldenDegree == 'NURSING.GEN.INTEREST')
		|| (strSelectedWaldenDegree == 'MS.W1HHS.NUR.W1ED')
		|| (strSelectedWaldenDegree == 'MS.W1HHS.NUR.W1LMS')
		|| (strSelectedWaldenDegree == 'NURSING.GEN.INTERES2')
		|| (strSelectedWaldenDegree == 'MS.W1HHS.NUR.W1ED2')
		|| (strSelectedWaldenDegree == 'MS.W1HHS.NUR.W1LMS2')
		&& (document.uData.current_rn.value == ''))
		{ 
			nursingPopUp();
		}
}

function nursingPopUp()
{
	var nursingPop = window.open('pop_walden.asp', 'popUp', 'width=330,height=170,left=0,top=180,toolbar=no,location=0,directories=0,status=no,menubar=no,scrollbars=yes,resizable=yes');
	nursingPop.focus()
}

function updateWaldenDegrees()
{
	var frm = document.uData;
	var educationLevel = document.getElementById("education_level");
	var degreeProgram = document.getElementById("program_code");	
	var degreeProgramLen = degreeProgram.length;
	var blnIsValidDegree = false;
	var intIndexOfValidDegree = -1;
	
	// empty list	
	for(var i = 0; i <= degreeProgramLen; i++)
	{
		degreeProgram.options[0] = null;
	}
	
	//create new list
	switch (educationLevel[educationLevel.selectedIndex].value)
	{
		// invalid level of education selected
		case '17000005': //High school diploma
		case '17000006': //Some college 0-44 credits
		case '17000007': //Some college 45-59 credits
			var arrWaldenDegreeAll = ["Select one"];
			arrWaldenDegreeAll = arrWaldenDegreeAll.concat(arrWaldenDegree0,arrWaldenDegree1,arrWaldenDegree2);
			for (var i = 0; i < arrWaldenDegreeAll.length; i++)
			{
				var pipeLocation = arrWaldenDegreeAll[i].indexOf('|')
				var curDegreeCode = arrWaldenDegreeAll[i].substring(0, pipeLocation)
				var curDegree = arrWaldenDegreeAll[i].substring(pipeLocation + 1, arrWaldenDegreeAll[i].length)
				
				if(curDegreeCode == strSelectedWaldenDegree)
				{
					blnIsValidDegree = true;
					intIndexOfValidDegree = i;
				}
				
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			if(blnIsValidDegree == true && intIndexOfValidDegree > -1)
			{
				degreeProgram.options[intIndexOfValidDegree].selected = true;
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
			}
			alert ('Based on the information you provided, you do not currently meet the application requirements for Walden University.');
			break;
		// Nursing Diploma selected
		case '17000115':
			var arrWaldenDegreeNursing = ["Select one"];
			arrWaldenDegreeNursing = arrWaldenDegreeNursing.concat(arrWaldenDegree5, arrWaldenDegree6);
			for (var i = 0; i < arrWaldenDegreeNursing.length; i++)
			{
				var pipeLocation = arrWaldenDegreeNursing[i].indexOf('|')
				var curDegreeCode = arrWaldenDegreeNursing[i].substring(0, pipeLocation)
				var curDegree = arrWaldenDegreeNursing[i].substring(pipeLocation + 1, arrWaldenDegreeNursing[i].length)
				
				if(curDegreeCode == strSelectedWaldenDegree)
				{
					blnIsValidDegree = true;
					intIndexOfValidDegree = i;
				}
								
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			if(blnIsValidDegree != true && strSelectedWaldenDegree != '')
			{
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
				alert('The Education Level you have selected does not meet the minimum academic requirements for the degree you have selected.  If you\'d like information about a different degree program, please select it now.  We appreciate your interest in Walden University and look forward to helping you reach your educational goals.');
				strSelectedWaldenDegree = '';
			}
			if(blnIsValidDegree == true && intIndexOfValidDegree > -1)
			{
				degreeProgram.options[intIndexOfValidDegree].selected = true;
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
			}
			break;
		// Some College selected
		case '17000008':
			var arrWaldenDegreeSomeC = ["Select one"];
			arrWaldenDegreeSomeC = arrWaldenDegreeSomeC.concat(arrWaldenDegree6);
			for (var i = 0; i < arrWaldenDegreeSomeC.length; i++)
			{
				var pipeLocation = arrWaldenDegreeSomeC[i].indexOf('|')
				var curDegreeCode = arrWaldenDegreeSomeC[i].substring(0, pipeLocation)
				var curDegree = arrWaldenDegreeSomeC[i].substring(pipeLocation + 1, arrWaldenDegreeSomeC[i].length)
				
				if(curDegreeCode == strSelectedWaldenDegree)
				{
					blnIsValidDegree = true;
					intIndexOfValidDegree = i;
				}
								
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			if(blnIsValidDegree != true && strSelectedWaldenDegree != '')
			{
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
				alert('The Education Level you have selected does not meet the minimum academic requirements for the degree you have selected.  If you\'d like information about a different degree program, please select it now.  We appreciate your interest in Walden University and look forward to helping you reach your educational goals.');
				strSelectedWaldenDegree = '';
			}
			if(blnIsValidDegree == true && intIndexOfValidDegree > -1)
			{
				degreeProgram.options[intIndexOfValidDegree].selected = true;
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
			}
			break;
		// AA/AS Degree selected
		case '17000009':
			var arrWaldenDegreeB = ["Select one"];
			arrWaldenDegreeB = arrWaldenDegreeB.concat(arrWaldenDegree0, arrWaldenDegree6);
			for (var i = 0; i < arrWaldenDegreeB.length; i++)
			{
				var pipeLocation = arrWaldenDegreeB[i].indexOf('|')
				var curDegreeCode = arrWaldenDegreeB[i].substring(0, pipeLocation)
				var curDegree = arrWaldenDegreeB[i].substring(pipeLocation + 1, arrWaldenDegreeB[i].length)
				
				if(curDegreeCode == strSelectedWaldenDegree)
				{
					blnIsValidDegree = true;
					intIndexOfValidDegree = i;
				}
								
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			if(blnIsValidDegree != true && strSelectedWaldenDegree != '')
			{
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
				alert('The Education Level you have selected does not meet the minimum academic requirements for the degree you have selected.  If you\'d like information about a different degree program, please select it now.  We appreciate your interest in Walden University and look forward to helping you reach your educational goals.');
				strSelectedWaldenDegree = '';
			}
			if(blnIsValidDegree == true && intIndexOfValidDegree > -1)
			{
				degreeProgram.options[intIndexOfValidDegree].selected = true;
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
			}
			break;
		// BA/BS Degree selected
		case '17000010':
			var arrWaldenDegreeBAndM = ["Select one"];
			arrWaldenDegreeBAndM = arrWaldenDegreeBAndM.concat(arrWaldenDegree0,arrWaldenDegree1);
			for (var i = 0; i < arrWaldenDegreeBAndM.length; i++)
			{
				var pipeLocation = arrWaldenDegreeBAndM[i].indexOf('|')
				var curDegreeCode = arrWaldenDegreeBAndM[i].substring(0, pipeLocation)
				var curDegree = arrWaldenDegreeBAndM[i].substring(pipeLocation + 1, arrWaldenDegreeBAndM[i].length)
				
				if(curDegreeCode == strSelectedWaldenDegree)
				{
					blnIsValidDegree = true;
					intIndexOfValidDegree = i;
				}
				
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			if(blnIsValidDegree != true && strSelectedWaldenDegree != '')
			{
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
				alert('The Education Level you have selected does not meet the minimum academic requirements for the degree you have selected.  If you\'d like information about a different degree program, please select it now.  We appreciate your interest in Walden University and look forward to helping you reach your educational goals.');
				strSelectedWaldenDegree = '';
			}
			if(blnIsValidDegree == true && intIndexOfValidDegree > -1)
			{
				degreeProgram.options[intIndexOfValidDegree].selected = true;
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
			}
			break;
		// Master's Degree, Ph.D. Degree, or Post doctoral certificate selected
		case '17000011':
		case '17000012':
		case '170000013':
		// unknown selection
		default:
			var arrWaldenDegreeAll = ["Select one"];
			arrWaldenDegreeAll = arrWaldenDegreeAll.concat(arrWaldenDegree0,arrWaldenDegree1,arrWaldenDegree2);
			for (var i = 0; i < arrWaldenDegreeAll.length; i++)
			{
				var pipeLocation = arrWaldenDegreeAll[i].indexOf('|')
				var curDegreeCode = arrWaldenDegreeAll[i].substring(0, pipeLocation)
				var curDegree = arrWaldenDegreeAll[i].substring(pipeLocation + 1, arrWaldenDegreeAll[i].length)
				
				if(curDegreeCode == strSelectedWaldenDegree)
				{
					blnIsValidDegree = true;
					intIndexOfValidDegree = i;
				}
				
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			if(blnIsValidDegree != true && strSelectedWaldenDegree != '')
			{
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
				alert('The Education Level you have selected does not meet the minimum academic requirements for the degree you have selected.  If you\'d like information about a different degree program, please select it now.  We appreciate your interest in Walden University and look forward to helping you reach your educational goals.');
				strSelectedWaldenDegree = '';
			}
			if(blnIsValidDegree == true && intIndexOfValidDegree > -1)
			{
				degreeProgram.options[intIndexOfValidDegree].selected = true;
				blnIsValidDegree = false;
				intIndexOfValidDegree = -1;
			}
			break;
	}
	
}

/*function setSelectedDegree()
{
	var frm = document.uData;
	var educationLevel = document.getElementById("education_level");
	var degreeProgram = document.getElementById("program_code");	
	var degreeProgramLen = degreeProgram.length;
	
	if (educationLevel[educationLevel.selectedIndex].value != '' && educationLevel[educationLevel.selectedIndex].value != null && frm.selectedDegree != '' && frm.selectedDegree != null)
	{
		var theDegree = frm.selectedDegree.value;
		for (var i = 0; i < degreeProgramLen; i ++)
		{
			if (degreeProgram.options[i].value == theDegree)
			{
				degreeProgram.options[i].selected = true;
				break;
			}
		}
	}
} */

//---------- form validation function ----------
function validateForm() {
	var frm = document.uData;
	var degID = 0;
	var v = new Validator();
	
	// verify prefix
	if (frm.exp_1[frm.exp_1.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please select a prefix.');
			frm.exp_1.focus();
		}
	}
	
	// verify first name is not blank
	v.validateTextChars(frm.first_name, 'First Name');
	
	// verify last name is not blank
	v.validateTextChars(frm.last_name, 'Last Name');
	
	// verify e-mail address is not blank and verify valid format
	v.validateEmail(frm.email, 'Email Address');
	
	// verify street address
	v.validateText(frm.address, 'Street Address');
	
	// verify city
	v.validateText(frm.city, 'City');	
	
	// verify state is not blank if country is US or CA
	if (frm.state_code[frm.state_code.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please select your state.');
			frm.state_code.focus();
		}
	}
	
	// verify zip code
	if (frm.country_code[frm.country_code.selectedIndex].value != '' && frm.country_code[frm.country_code.selectedIndex].value == 'CA')
	{
		v.validateZipCanada(frm.zip, 'ZIP');
	}
	else
	{
		v.validateZip(frm.zip, 'ZIP');
	}
	
	//verify country
	if (frm.country_code[frm.country_code.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please select your country.');
			frm.country_code.focus();
		}
	}
	else if (frm.country_code[frm.country_code.selectedIndex].value != 'US' && frm.country_code[frm.country_code.selectedIndex].value != 'CA')
	{
		if (v.isValid)
		{
			v.raiseError('Thank you for your interest in receiving information about Walden University.  At this time, Walden is only accepting applicants from the United States and Canada.');
			frm.country_code.focus();
		}
	}
		
	// verify phone fields
	// verify home area code
	if (frm.h_area_code.value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please enter your home area code');
			frm.h_area_code.focus();
		}
	}
	
	if (frm.h_area_code.value != '' && frm.h_area_code.value.length < 3)
	{
		if (v.isValid)
		{
			v.raiseError('Home area code must have 3 digits');
			frm.h_area_code.focus();
		}
	}
	
	if (frm.h_area_code.value != '' && frm.h_area_code.value.length == 3 && !v.isPhoneNumeric(frm.h_area_code.value))
	{
		if (v.isValid)
		{
			v.raiseError('Home area code should contain only numbers.');
			frm.h_area_code.focus();
		}
	}
	if (frm.h_area_code.value == '111' || frm.h_area_code.value == '123' || frm.h_area_code.value == '222' || frm.h_area_code.value == '333' || frm.h_area_code.value == '444' || frm.h_area_code.value == '555' || frm.h_area_code.value == '666' || frm.h_area_code.value == '777' || frm.h_area_code.value == '888' || frm.h_area_code.value == '999' || frm.h_area_code.value == '911' || frm.h_area_code.value == '000' || frm.h_area_code.value == '098')
	{
		if (v.isValid)
		{
			v.raiseError('Home area code apears to be invalid.');
			frm.h_area_code.focus();
		}
	}
	
	// verify home phone number
	if (frm.h_phone.value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please enter your home phone number');
			frm.h_phone.focus();
		}
	}
	
	if (frm.h_phone.value != '' && frm.h_phone.value.length < 7)
	{
		if (v.isValid)
		{
			v.raiseError('Home phone number must have 7 digits');
			frm.h_phone.focus();
		}
	}
	
	if (frm.h_phone.value != '' && frm.h_phone.value.length >= 7 && !v.isPhoneNumeric(frm.h_phone.value))
	{
		if (v.isValid)
		{
			v.raiseError('Home phone number should contain only numbers.');
			frm.h_phone.focus();
		}
	}
	if (frm.h_phone.value.replace(/-/gi,'')=='1111111' || frm.h_phone.value.replace(/-/gi,'')=='1234567' || frm.h_phone.value.replace(/-/gi,'')=='4567890' || frm.h_phone.value.replace(/-/gi,'')=='0000000' || frm.h_phone.value.replace(/-/gi,'')=='2222222' || frm.h_phone.value.replace(/-/gi,'')=='3333333' || frm.h_phone.value.replace(/-/gi,'')=='4444444' || frm.h_phone.value.replace(/-/gi,'')=='5555555' || frm.h_phone.value.replace(/-/gi,'')=='6666666' || frm.h_phone.value.replace(/-/gi,'')=='7777777' || frm.h_phone.value.replace(/-/gi,'')=='8888888' || frm.h_phone.value.replace(/-/gi,'')=='9999999' || frm.h_phone.value.replace(/-/gi,'')=='00000000' || frm.h_phone.value.replace(/-/gi,'')=='000000')
	{
		if (v.isValid)
		{
			v.raiseError('Home phone number appears to be invalid.');
			frm.h_phone.focus();
		}
	}
	if (frm.h_phone.value.indexOf('000') == 0 || frm.h_phone.value.indexOf('911') == 0 || frm.h_phone.value.indexOf('555') == 0 || frm.h_phone.value.indexOf('1234') == 0 || frm.h_phone.value.indexOf('0123') == 0)
	{
		if (v.isValid)
		{
			v.raiseError('Home phone number appears to be invalid.');
			frm.h_phone.focus();
		}
	}
	
	// verify work area code
	if (frm.w_area_code.value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please enter your work area code');
			frm.w_area_code.focus();
		}
	}
	if (frm.w_area_code.value != '' && frm.w_area_code.value.length < 3)
	{
		if (v.isValid)
		{
			v.raiseError('Work area code must have 3 digits');
			frm.w_area_code.focus();
		}
	}
	
	if (frm.w_area_code.value != '' && frm.w_area_code.value.length == 3 && !v.isPhoneNumeric(frm.w_area_code.value))
	{
		if (v.isValid)
		{
			v.raiseError('Work area code should contain only numbers.');
			frm.w_area_code.focus();
		}
	}
	if (frm.w_area_code.value == '111' || frm.w_area_code.value == '123' || frm.w_area_code.value == '222' || frm.w_area_code.value == '333' || frm.w_area_code.value == '444' || frm.w_area_code.value == '555' || frm.w_area_code.value == '666' || frm.w_area_code.value == '777' || frm.w_area_code.value == '888' || frm.w_area_code.value == '999' || frm.w_area_code.value == '911' || frm.w_area_code.value == '000' || frm.w_area_code.value == '098')
	{
		if (v.isValid)
		{
			v.raiseError('Work area code apears to be invalid.');
			frm.w_area_code.focus();
		}
	}
	
	// verify work phone number
	if (frm.w_phone.value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please enter your work phone number');
			frm.w_phone.focus();
		}
	}
	if (frm.w_phone.value != '' && frm.w_phone.value.length < 7)
	{
		if (v.isValid)
		{
			v.raiseError('Work phone number must have 7 digits');
			frm.w_phone.focus();
		}
	}
	
	if (frm.w_phone.value != '' && frm.w_phone.value.length >= 7 && !v.isPhoneNumeric(frm.w_phone.value))
	{
		if (v.isValid)
		{
			v.raiseError('Work phone number should contain only numbers.');
			frm.w_phone.focus();
		}
	}
	if (frm.w_phone.value.replace(/-/gi,'')=='1111111' || frm.w_phone.value.replace(/-/gi,'')=='1234567' || frm.w_phone.value.replace(/-/gi,'')=='4567890' || frm.w_phone.value.replace(/-/gi,'')=='0000000' || frm.w_phone.value.replace(/-/gi,'')=='2222222' || frm.w_phone.value.replace(/-/gi,'')=='3333333' || frm.w_phone.value.replace(/-/gi,'')=='4444444' || frm.w_phone.value.replace(/-/gi,'')=='5555555' || frm.w_phone.value.replace(/-/gi,'')=='6666666' || frm.w_phone.value.replace(/-/gi,'')=='7777777' || frm.w_phone.value.replace(/-/gi,'')=='8888888' || frm.w_phone.value.replace(/-/gi,'')=='9999999' || frm.w_phone.value.replace(/-/gi,'')=='00000000' || frm.w_phone.value.replace(/-/gi,'')=='000000')
	{
		if (v.isValid)
		{
			v.raiseError('Work phone number appears to be invalid.');
			frm.w_phone.focus();
		}
	}
	if (frm.w_phone.value.indexOf('000') == 0 || frm.w_phone.value.indexOf('911') == 0 || frm.w_phone.value.indexOf('555') == 0 || frm.w_phone.value.indexOf('1234') == 0 || frm.w_phone.value.indexOf('0123') == 0)
	{
		if (v.isValid)
		{
			v.raiseError('Work phone number appears to be invalid.');
			frm.w_phone.focus();
		}
	}
	
	if(frm.exp_4.value.length > 0 && !v.isPhoneNumeric(frm.exp_4.value))
	{
		if (v.isValid)
		{
			v.raiseError('Work phone extension should contain only numbers.');
			frm.exp_4.focus();
		}
	}
	
	if (frm.exp_2.selectedIndex == 0)
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate the best time to call.');
			frm.exp_2.focus();
		}
	}
	//verify AM/PM
	if (frm.exp_3[0].checked != true && frm.exp_3[1].checked != true)
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate the best time to call, either AM or PM.');
			frm.exp_3[0].focus();
		}
	}
	
	// verify education level
	if (frm.education_level[frm.education_level.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate your highest level of education.');
			frm.education_level.focus();
		}
	}
	
	if ( // if user has selected high school diploma, somecollege 0-44 credits or some college 45-59 credits, block form submission
		(frm.education_level[frm.education_level.selectedIndex].value == '17000005')
		|| (frm.education_level[frm.education_level.selectedIndex].value == '17000006')
		|| (frm.education_level[frm.education_level.selectedIndex].value == '17000007'))
	{
		if (v.isValid)
		{
			v.raiseError('The Education Level you have selected does not meet the application requirements for Walden University.');
			frm.education_level.focus();
		}
	}
	
	// verify program_code
	if (frm.program_code[frm.program_code.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate your degree program preference.');
			frm.program_code.focus();
		}
	}
	
	//verify enrollment date
	if (frm.enroll_timeframe[frm.enroll_timeframe.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate your enrollment date.');
			frm.enroll_timeframe.focus();
		}
	}
	
	if (v.isValid) 
	{
		for (var i=0; i<document.links.length; i++)
		{
			if (document.links[i].href.toLowerCase() == 'javascript:validateform();')
			{
				document.links[i].href = '#';
				break;
			}
		}
		frm.program_code.disabled = false;
		frm.submit();
	}
}
