﻿// Fade functions

// @name      The Fade Anything Technique
// @namespace http://www.axentric.com/aside/fat/
// @version   1.0-RC1-m
// @author    Adam Michela
// @modified  Richard Livsey / 28/04/05
// @modiified for form validation Tom Wallace / 10/10/05

var Fat = {
	make_hex : function (r,g,b) 
	{
		r = r.toString(16); if (r.length == 1) r = '0' + r;
		g = g.toString(16); if (g.length == 1) g = '0' + g;
		b = b.toString(16); if (b.length == 1) b = '0' + b;
		return "#" + r + g + b;
	},
	fade_all : function ()
	{
		var a = document.getElementsByTagName("*");
		for (var i = 0; i < a.length; i++) 
		{
			var o = a[i];
			var r = /fade-?(\w{3,6})?/.exec(o.className);
			if (r)
			{
				if (!r[1]) r[1] = "";
				if (!o.id)
					o.id = 'fader_'+Math.floor(Math.random()*100);
		
				Fat.fade_element(o.id,null,null,"#"+r[1]);
			}
		}
	},
	fade_element : function (id, fps, duration, from, to) 
	{
		if (!fps) fps = 30;
		if (!duration) duration = 3000;
		if (!from || from=="#") from = "#FFFF33";
		if (!to) to = this.get_bgcolor(id);

		if (this.timers[id])
			this.cancel_fade(id);
			
		this.timers[id] = new Array();
		
		var frames = Math.round(fps * (duration / 1000));
		var interval = duration / frames;
		var delay = interval;
		var frame = 0;
		
		if (from.length < 7) from += from.substr(1,3);
		if (to.length < 7) to += to.substr(1,3);
		
		var rf = parseInt(from.substr(1,2),16);
		var gf = parseInt(from.substr(3,2),16);
		var bf = parseInt(from.substr(5,2),16);
		var rt = parseInt(to.substr(1,2),16);
		var gt = parseInt(to.substr(3,2),16);
		var bt = parseInt(to.substr(5,2),16);
		
		var r,g,b,h;
		this.end = false;
		while (frame < frames)
		{
			r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames));
			g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames));
			b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
			h = this.make_hex(r,g,b);
		
			this.timers[id][this.timers[id].length] = setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay);

			frame++;
			delay = interval * frame; 
		}
		this.timers[id][this.timers[id].length] = setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay);
	},
	cancel_fade : function(id)
	{
		if (!this.timers[id])
			return;
		
		for (var i=0; i<this.timers[id].length; i++)
			clearTimeout(this.timers[id][i]);
	},
	set_bgcolor : function (id, c)
	{
		var o = document.getElementById(id);
		o.style.backgroundColor = c;
	},
	get_bgcolor : function (id)
	{
		var o = document.getElementById(id);
		while(o)
		{
			var c;
			if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color");
			if (o.currentStyle) c = o.currentStyle.backgroundColor;
			if ((c != "" && c != "transparent") || o.tagName == "BODY") { break; }
			o = o.parentNode;
		}
		if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF";
		var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/);
		if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3]));
		return c;
	},
	timers : new Array()
}

window.onload = function(){Fat.fade_all();}

function Querystring(qs) { 
	this.params = new Object()
	this.get=Querystring_get
	if (qs == null)
		qs=location.search.substring(1,location.search.length)
	if (qs.length == 0) return
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') 
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0]).toLowerCase();
		if (pair.length == 2)
			value = unescape(pair[1]).toLowerCase();
		else
			value = name.toLowerCase();
		this.params[name] = value.toLowerCase();
	}
}

function Querystring_get(key, default_) {
	if (default_ == null) default_ = null;
	var value=this.params[key]
	if (value==null) value=default_;
	return value
}

function highlightError(field)
{
	var p = window.location.pathname; //path and filename, but not domain
	var l = window.location.host; //domain name only, but not path or filename
	var qs = new Querystring();
	//this is where you turn the fader on for various URLs. it's turned off on all sites by default
	if((qs.get("fader") && qs.get("fader") == "on") || l.indexOf("degreereview") > -1)
	{ //Check querystring to see if it contains "fader=on", or if url contains "capellauniversityonline" or "degreereview". if so, run highlight code
		if(document.getElementById("fadeError"))
		//if some other field is highlighted, clear it first before highlighting a new field
		{
			document.getElementById("fadeError").style.backgroundColor = "transparent";
			document.getElementById("fadeError").id = '';
		}
		//sets the id of the grandparent of the form field that has an error to "fadeError", 
		//thereby triggering the fader effect on the table row containing it
		field.parentNode.parentNode.id = 'fadeError';
		//setup default fade colors and allow querystring to overwrite default color settings
		//sfcolor = start fade color, best to make this the same as the background color of the form
		//efcolor = end fade color
		if(qs.get("sfcolor") != null){var sfcolor = qs.get("sfcolor");}
		else{var sfcolor = "F0F0F0";}
		if(qs.get("efcolor") != null){var efcolor = qs.get("efcolor");}
		else{var efcolor = "B4B4B4";}
		// set color values for degreereview
		if(l.indexOf("degreereview") > -1){sfcolor = "F7F7F0";efcolor = "D4D4BC";}
		//run fade effect on any element with id fadeError
		//parameters are (id of element to fade, fps, duration of effect in milliseconds, starting color of effect, ending color of effect)
		Fat.fade_element("fadeError", 30, 1700, "#" +sfcolor, "#" +efcolor);
	}
}

// end fade functions
/* :::::: 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.form1.areazipoverride.value='yes';
		document.form1.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='';
		highlightError(text);
		text.focus();
	}
	else if (this.containsProfanity(text.value))
	{
		this.raiseError(label + ' must not contain profane content.');
		highlightError(text);
		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='';
		highlightError(text);
		text.focus();
		
	}
	else if (this.containsProfanity(text.value))
	{
		this.raiseError(label + ' must not contain profane content.');
		highlightError(text);
		text.select();
	}
	else if (!this.isTextValid(text.value))
	{
		this.raiseError(label + ' contains invalid characters.');
		highlightError(text);
		text.select();
	}
}

function V_validatePhone(phone, label)
{
	if (!this.isValid) return;
	
	if (phone.value == '')
	{
		this.raiseError(label + ' phone number must not be blank.');
		highlightError(phone);
		phone.focus();
	}
	else if (phone.value.length < 7)
	{
		this.raiseError(label + ' phone number should have at least seven numbers.');
		highlightError(phone);
		phone.focus();
	}
	else if (!this.isPhoneNumeric(phone.value))
	{
		this.raiseError(label + ' phone number should have only numbers.');
		highlightError(phone);
		phone.focus();
	}
}

function V_validateZip(zip, label)
{
	if (!this.isValid) return;
	if (zip.value == '')
	{
		this.raiseError(label + ' must not be blank.');
		highlightError(zip);
		zip.focus();
	}
	else if (zip.value.length < 5)
	{
		this.raiseError(label + ' must be at least five characters.');
		highlightError(zip);
		zip.focus();
	}
	else if (!this.isZipValid(zip.value.toLowerCase()))
	{
		this.raiseError(label + ' contains invalid characters.');
		highlightError(zip);
		zip.select();
	}
}

function V_validateZipCanada(zip, label)
{
	if (!this.isValid) return;
	if (zip.value == '')
	{
		this.raiseError(label + ' must not be blank.');
		highlightError(zip);
		zip.focus();
	}
	else if (zip.value.length < 6)
	{
		this.raiseError(label + ' must be at least six characters.');
		highlightError(zip);
		zip.focus();
	}
	else if (!this.isZipValid(zip.value.toLowerCase()))
	{
		this.raiseError(label + ' contains invalid characters.');
		highlightError(zip);
		zip.select();
	}
}

function V_validateNumericOnly(myField, label)
{
	if (!this.isValid) return;
	if (myField.value == '')
	{
		this.raiseError(label + ' must not be blank.');
		highlightError(myField);
		myField.focus();
	}
	else if (myField.value.length < 4)
	{
		this.raiseError(label + ' must be four characters long.');
		highlightError(myField);
		myField.focus();
	}
}

function V_validateEmail(email, label)
{
	if (!this.isValid) return;
	if (email.value == '')
	{
		this.raiseError(label + ' must not be blank.');
		highlightError(email);
		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.');
			highlightError(email);
			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.');
			highlightError(email);
			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.');
				highlightError(email);
				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;

	var frm = document.forms[0];

//---------- custom functions ----------

function checkDegree()
{
	switch(frm.program_code[frm.program_code.selectedIndex].value)
	{
		case '368':
		case '370':
		case '373':
		case '622':
			alert('Thank you for your interest in Capella University.  The specialization you have selected is for current K-12 professionals interested in extending their education with a graduate degree.  Please be aware that this specialization does not lead to initial teacher licensure.');
			break;
		default:
			break;
	}
}

function checkCountry()
{
	if (frm.country_code[frm.country_code.selectedIndex].value != '' && frm.country_code[frm.country_code.selectedIndex].value != 'USA' && frm.country_code[frm.country_code.selectedIndex].value != 'CAN')
	{
		alert('Thank you for your interest in receiving information about Capella University.  At this time, Capella is only accepting applicants from the United States and Canada.');
		highlightError(frm.country_code);
		frm.country_code.focus();
	}
	else if((frm.country_code[frm.country_code.selectedIndex].value == 'USA' || frm.country_code[frm.country_code.selectedIndex].value == 'CAN') && document.getElementById("stateRow").className == 'hidden')
		document.getElementById('stateRow').className = 'visible';
}

function updateCapellaDegrees()
{
	var schoolOfInterest = document.getElementById("institution");
	var degreeProgram = document.getElementById("program_code");	
	var degreeProgramLen = degreeProgram.length;
	
	frm.program_code.disabled = false;
	
	// empty list	
	for(var i = 0; i <= degreeProgramLen; i++)
	{
		degreeProgram.options[0] = null;
	}
	
	//create new list
	switch (schoolOfInterest[schoolOfInterest.selectedIndex].value)
	{
		// Business selected
		case '1':
			var arrCapellaDegreeBusiness = ["Select one"];
			arrCapellaDegreeBusiness = arrCapellaDegreeBusiness.concat(arrCapellaDegree0);
			for (var i = 0; i < arrCapellaDegreeBusiness.length; i++)
			{
				var pipeLocation = arrCapellaDegreeBusiness[i].indexOf('|')
				var curDegreeCode = arrCapellaDegreeBusiness[i].substring(0, pipeLocation)
				var curDegree = arrCapellaDegreeBusiness[i].substring(pipeLocation + 1, arrCapellaDegreeBusiness[i].length)
				
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			break;
		// Technology selected
		case '2':
			var arrCapellaDegreeTechnology = ["Select one"];
			arrCapellaDegreeTechnology = arrCapellaDegreeTechnology.concat(arrCapellaDegree1);
			for (var i = 0; i < arrCapellaDegreeTechnology.length; i++)
			{
				var pipeLocation = arrCapellaDegreeTechnology[i].indexOf('|')
				var curDegreeCode = arrCapellaDegreeTechnology[i].substring(0, pipeLocation)
				var curDegree = arrCapellaDegreeTechnology[i].substring(pipeLocation + 1, arrCapellaDegreeTechnology[i].length)
				
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			break;
		// Education selected
		case '3':
			var arrCapellaDegreeEducation = ["Select one"];
			arrCapellaDegreeEducation = arrCapellaDegreeEducation.concat(arrCapellaDegree2);
			for (var i = 0; i < arrCapellaDegreeEducation.length; i++)
			{
				var pipeLocation = arrCapellaDegreeEducation[i].indexOf('|')
				var curDegreeCode = arrCapellaDegreeEducation[i].substring(0, pipeLocation)
				var curDegree = arrCapellaDegreeEducation[i].substring(pipeLocation + 1, arrCapellaDegreeEducation[i].length)
				
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			break;
		// Psychology selected
		case '4':
			var arrCapellaDegreePsychology = ["Select one"];
			arrCapellaDegreePsychology = arrCapellaDegreePsychology.concat(arrCapellaDegree3);
			for (var i = 0; i < arrCapellaDegreePsychology.length; i++)
			{
				var pipeLocation = arrCapellaDegreePsychology[i].indexOf('|')
				var curDegreeCode = arrCapellaDegreePsychology[i].substring(0, pipeLocation)
				var curDegree = arrCapellaDegreePsychology[i].substring(pipeLocation + 1, arrCapellaDegreePsychology[i].length)
				
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			break;
		// Human Services selected
		case '5':
			var arrCapellaDegreeHuman = ["Select one"];
			arrCapellaDegreeHuman = arrCapellaDegreeHuman.concat(arrCapellaDegree4);
			for (var i = 0; i < arrCapellaDegreeHuman.length; i++)
			{
				var pipeLocation = arrCapellaDegreeHuman[i].indexOf('|')
				var curDegreeCode = arrCapellaDegreeHuman[i].substring(0, pipeLocation)
				var curDegree = arrCapellaDegreeHuman[i].substring(pipeLocation + 1, arrCapellaDegreeHuman[i].length)
				
				degreeProgram.options[i] = new Option(curDegree, curDegreeCode)
			}
			break;
		// unknown selection
		default:
			degreeProgram.options[0] = new Option('Select one', '')
			degreeProgram.disabled = true;
			break;
	}
	
}

function setSelectedDegree()
{
	var schoolOfInterest = document.getElementById("education_level");
	var degreeProgram = document.getElementById("program_code");	
	var degreeProgramLen = degreeProgram.length;
	
	if (schoolOfInterest[schoolOfInterest.selectedIndex].value != '' && schoolOfInterest[schoolOfInterest.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;
			}
		}
	}
}

function toggleAge()
{
	var ageRow = document.getElementById("ageRow");
	if(RequireAge())
		ageRow.className = "visible";
	else
		ageRow.className = "hidden";
}

function RequireAge()
{
	switch(frm.education_level[frm.education_level.selectedIndex].value)
	{
	    case '1':
	    case '2':
	    case '3':
	    case '4':
	    case '5':
	        return true;
	    default:
	        return false;
	}
}

//---------- form validation function ----------
function validateForm() {
	var degID = 0;
	var v = new Validator();
	
	// verify school of interest
	if (frm.institution[frm.institution.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate your school of interest.');
			highlightError(frm.institution);
			frm.institution.focus();
		}
	}
	
	// verify program_code
	if (frm.program_code[frm.program_code.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate your degree program of interest.');
			highlightError(frm.program_code);
			frm.program_code.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.');
			highlightError(frm.education_level);
			frm.education_level.focus();
		}
	}
	
	//verify enrollment date
	if (frm.month_completion_date[frm.month_completion_date.selectedIndex].value == '' || frm.year_completion_date[frm.year_completion_date.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate your projected start date.');
			highlightError(frm.month_completion_date);
			frm.month_completion_date.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 phone fields
	// verify home area code
	if (frm.h_area_code.value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please enter your home area code');
			highlightError(frm.h_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');
			highlightError(frm.h_area_code);
			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.');
			highlightError(frm.h_area_code);
			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.');
			highlightError(frm.h_area_code);
			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');
			highlightError(frm.h_phone);
			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');
			highlightError(frm.h_phone);
			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.');
			highlightError(frm.h_phone);
			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.');
			highlightError(frm.h_phone);
			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.');
			highlightError(frm.h_phone);
			frm.h_phone.focus();
		}
	}
	
	//validate best_time_to_call field
	if (frm.best_time_to_call[frm.best_time_to_call.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please select the best time to call.');
			highlightError(frm.best_time_to_call);
			frm.best_time_to_call.focus();
		}
	}
	
	
// verify evening area code
//	2009-07-02removed evening phone field from form
//	if (frm.c_area_code.value != '' && frm.c_area_code.value.length < 3)
//	{
//		if (v.isValid)
//		{
//			v.raiseError('Evening area code must have 3 digits');
//			highlightError(frm.c_area_code);
//			frm.c_area_code.focus();
//		}
//	}
//	
//	if (frm.c_area_code.value != '' && frm.c_area_code.value.length == 3 && !v.isPhoneNumeric(frm.c_area_code.value))
//	{
//		if (v.isValid)
//		{
//			v.raiseError('Evening area code should contain only numbers.');
//			highlightError();
//			frm.c_area_code.focus(c_area_code);
//		}
//	}
//	if (frm.c_area_code.value == '111' || frm.c_area_code.value == '123' || frm.c_area_code.value == '222' || frm.c_area_code.value == '333' || frm.c_area_code.value == '444' || frm.c_area_code.value == '555' || frm.c_area_code.value == '666' || frm.c_area_code.value == '777' || frm.c_area_code.value == '888' || frm.c_area_code.value == '999' || frm.c_area_code.value == '911' || frm.c_area_code.value == '000' || frm.c_area_code.value == '098')
//	{
//		if (v.isValid)
//		{
//			v.raiseError('Evening area code apears to be invalid.');
//			highlightError(frm.c_area_code);
//			frm.c_area_code.focus();
//		}
//	}
//	
//	// verify evening phone number
//	if (frm.c_phone.value != '' && frm.c_phone.value.length < 7)
//	{
//		if (v.isValid)
//		{
//			v.raiseError('Evening phone number must have 7 digits');
//			highlightError(frm.c_phone);
//			frm.c_phone.focus();
//		}
//	}
//	
//	if (frm.c_phone.value != '' && frm.c_phone.value.length >= 7 && !v.isPhoneNumeric(frm.c_phone.value))
//	{
//		if (v.isValid)
//		{
//			v.raiseError('Evening phone number should contain only numbers.');
//			highlightError(frm.c_phone);
//			frm.c_phone.focus();
//		}
//	}
//	if (frm.c_phone.value.replace(/-/gi,'')=='1111111' || frm.c_phone.value.replace(/-/gi,'')=='1234567' || frm.c_phone.value.replace(/-/gi,'')=='4567890' || frm.c_phone.value.replace(/-/gi,'')=='0000000' || frm.c_phone.value.replace(/-/gi,'')=='2222222' || frm.c_phone.value.replace(/-/gi,'')=='3333333' || frm.c_phone.value.replace(/-/gi,'')=='4444444' || frm.c_phone.value.replace(/-/gi,'')=='5555555' || frm.c_phone.value.replace(/-/gi,'')=='6666666' || frm.c_phone.value.replace(/-/gi,'')=='7777777' || frm.c_phone.value.replace(/-/gi,'')=='8888888' || frm.c_phone.value.replace(/-/gi,'')=='9999999' || frm.c_phone.value.replace(/-/gi,'')=='00000000' || frm.c_phone.value.replace(/-/gi,'')=='000000')
//	{
//		if (v.isValid)
//		{
//			v.raiseError('Evening phone number appears to be invalid.');
//			highlightError(frm.c_phone);
//			frm.c_phone.focus();
//		}
//	}
//	if (frm.c_phone.value.indexOf('000') == 0 || frm.c_phone.value.indexOf('911') == 0 || frm.c_phone.value.indexOf('555') == 0 || frm.c_phone.value.indexOf('1234') == 0 || frm.c_phone.value.indexOf('0123') == 0)
//	{
//		if (v.isValid)
//		{
//			v.raiseError('Evening phone number appears to be invalid.');
//			highlightError(frm.c_phone);
//			frm.c_phone.focus();
//		}
//	}
//	
//// verify both evening phone fields are filled out, if either one is
//	if ((frm.c_area_code.value == '') && (frm.c_phone.value != ''))
//	{
//		if (v.isValid)
//		{
//			v.raiseError('Please enter your evening area code.');
//			highlightError(frm.c_area_code);
//			frm.c_area_code.focus();
//		}
//	}
//	
//	if ((frm.c_phone.value == '') && (frm.c_area_code.value != ''))
//	{
//		if (v.isValid)
//		{
//			v.raiseError('Please enter your evening phone number');
//			highlightError(frm.c_phone);
//			frm.c_phone.focus();
//		}
//	}	
	
	// 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.validateTextChars(frm.city, 'City');	
	
	// 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 state is not blank if country is USA or CAN	
	if (document.getElementById('countryRow').className == 'visible' && document.getElementById('stateRow').className == 'visible' && frm.state_code[frm.state_code.selectedIndex].value == '' && (frm.country_code[frm.country_code.selectedIndex].value == "USA" || frm.country_code[frm.country_code.selectedIndex].value == "CAN"))
	{
		if (v.isValid)
		{
			if(document.getElementById("stateRow").className == "hidden")
				document.getElementById("stateRow").className = "visible";
			v.raiseError('Please select your state.');
			highlightError(frm.state_code);
			//show country question if it's not already visible
			if(document.getElementById("stateRow").className == "hidden")
				document.getElementById("stateRow").className = "visible";
			frm.state_code.focus();
		}
	}
	
	//verify country
	if (frm.country_code[frm.country_code.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please select your country.');
			highlightError(frm.country_code);
			//show country question if it's not already visible
			if(document.getElementById("countryRow").className == "hidden")
				document.getElementById("countryRow").className = "visible";
			frm.country_code.focus();
		}
	}
	else if (frm.country_code[frm.country_code.selectedIndex].value != 'USA' && frm.country_code[frm.country_code.selectedIndex].value != 'CAN')
	{
		checkCountry();
		return;
	}
	
	if (frm.age_21.value == '' && RequireAge())
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate your age.');
			highlightError(frm.age_21);
			frm.age_21.focus();
		}
	}
	
	// verify military_benefit is selected
	if (frm.military_benefit[0].checked != true && frm.military_benefit[1].checked != true)
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate if you are associated with the United States military.');
			highlightError(frm.military_benefit[0]);
			frm.military_benefit[0].focus();
		}
	}
	
	//if persona questions are present, validate them
	if(document.getElementById("persona1q"))
	{
		// verify persona1q
		if (frm.persona1q[frm.persona1q.selectedIndex].value == '')
		{
			if(v.isValid)
			{
				v.raiseError('Please indicate your primary motivation for going back to school.');
				highlightError(frm.persona1q);
				frm.persona1q.focus();
			}
		}
	}
	
	if(document.getElementById("persona2q"))
	{
		// verify persona2q
		if (frm.persona2q[frm.persona2q.selectedIndex].value == '')
		{
			if(v.isValid)
			{
				v.raiseError('Please indicate your approach to making a major decision.');
				highlightError(frm.persona2q);
				frm.persona2q.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();
	}
}