// 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();
	//Remove comment in following line to enable fading on Keller, DeVry
	if((qs.get("fader") && qs.get("fader") == "on") ||  l.indexOf("welcome.keller") > -1 || l.indexOf("welcome.devry") > -1)
	{ //Check querystring to see if fader=on, or if url contains welcome.keller,  welcome.devry or degreereview. if so, run highlight code
		if(document.getElementById("fadeError"))
		{
			document.getElementById("fadeError").style.backgroundColor = "transparent";
			document.getElementById("fadeError").id = '';
		}
		field.parentNode.parentNode.id = 'fadeError';
		//setup default fade colors and allow querystring to overwrite default color settings
		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 = "C1D8DE";}
		// set color values for keller, devry and degreereview
		if(l.indexOf("welcome.keller") > -1){sfcolor = "E9E1D5";efcolor = "CFC4B2";}
		if(l.indexOf("welcome.devry") > -1){sfcolor = "FDFDFD";efcolor = "CFC4B2";}
		//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;
	}
}

//validation for first zip code entry page
function checkZip() 
{
	var frm = document.frmDeVry;
	if (frm.zipCode.value.length < 3) 
	{
		alert("Please enter a valid zip code.");
		highlightError(frm.zipCode);
		frm.zipCode.focus();
	}
	else
	{
		frm.isZipSubmit.value = "true";
		frm.submit();
	}
}

/* :::::: onChange FUNCTIONS :::::: */
function age17orOlder() {
	var age = document.getElementById("age_21");
	if (age[age.selectedIndex].value == '1') {
		alert ('Applicants to DeVry undergraduate programs must be 17 years of age upon enrollment.  We\'ll hope that you consider us for your future continuing education.');
	}
}
function age17orOlderKeller() {
	var age = document.getElementById("age_21");
	if (age[age.selectedIndex].value == '1') {
		alert ('Applicants to Keller Graduate School of Management programs must be 17 years of age upon enrollment.  We\'ll hope that you consider us for your future continuing education.');
	}
}

//populate dialing code based on country selected; this list same as UOP Online
var DialingCodes = new Array('AD','376','AE','971','AE','971','AE','971','AE','971','AE','971','AE','971','AE','971','AE','971','AF','93','AG','268','AG','268','AI','264','AL','355','AM','374','AN','599','AN','599','AN','599','AN','599','AN','599','AN','599','AO','244','AQ','672','AR','54','AS','684','AT','43','AU','61','AW','297','AZ','994','BA','387','BB','246','BD','880','BE','32','BF','226','BG','359','BH','973','BI','257','BJ','229','BM','441','BN','673','BO','591','BR','55','BS','242','BT','975','BV','0','BW','267','BY','375','BZ','501','CA','1','CC','672','CD','242','CF','236','CG','242','CH','41','CI','225','CK','682','CL','56','CM','237','CN','86','CO','57','CR','506','CU','53','CV','238','CX','672','CY','357','CZ','420','DE','49','DJ','253','DK','45','DM','767','DO','809','DZ','213','EC','593','EE','372','EG','20','EH','212','ER','291','ES','34','ET','251','FI','358','FJ','679','FK','500','FM','691','FO','298','FR','33','FX','33','GA','241','GB','44','GB','44','GB','44','GB','44','GB','44','GD','473','GE','995','GF','594','GH','233','GI','350','GL','299','GM','220','GN','224','GP','590','GQ','245','GR','30','GS','500','GT','502','GU','671','GW','245','GY','592','HK','852','HM','0','HN','504','HR','385','HT','509','HU','36','ID','62','IE','353','IL','972','IN','91','IO','0','IQ','964','IR','98','IS','354','IT','39','JM','876','JO','962','JP','81','KE','254','KG','7','KH','855','KI','686','KM','269','KN','869','KP','82','KP','82','KR','850','KR','850','KW','965','KY','345','KZ','7','LA','856','LB','961','LC','758','LI','423','LK','94','LR','231','LS','266','LT','370','LU','352','LV','371','LY','218','MA','212','MC','33','MD','373','MG','261','MH','692','MK','389','ML','223','MM','95','MN','976','MO','853','MP','670','MQ','596','MR','222','MS','473','MT','356','MU','230','MV','90','MW','265','MX','52','MY','60','MZ','258','NA','264','NC','687','NE','227','NF','672','NG','234','NI','505','NL','31','NO','47','NP','977','NR','674','NU','683','NZ','64','OM','968','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','OT','0','PA','507','PE','51','PF','689','PG','675','PH','63','PK','92','PL','48','PM','508','PN','649','PR','787','PT','351','PW','680','PY','595','QA','974','RE','262','RO','40','RU','7','RW','250','SA','966','SB','677','SC','248','SD','249','SE','46','SG','65','SH','290','SI','386','SJ','79','SK','421','SL','232','SM','378','SN','221','SO','252','SR','597','ST','239','SV','503','SY','963','SZ','268','TC','649','TD','235','TF','596','TG','228','TH','66','TJ','992','TK','690','TM','993','TN','216','TO','676','TP','1','TR','90','TT','868','TV','688','TW','886','TZ','255','UA','380','UG','256','UM','808','US','1','UY','598','UZ','998','VA','39','VC','809','VE','58','VG','284','VI','340','VN','84','VU','678','WF','681','WS','685','YE','967','YT','269','YU','381','ZA','27','ZM','260','ZW','263');
//had to rename because of a function name conflict with UoP's
function updateDialingCodeDevry() {
	for (var i=0; i < DialingCodes.length; i+=2) {
		if (DialingCodes[i] == document.uData.country_code[document.uData.country_code.selectedIndex].value) {
			document.uData.h_country_code.disabled = false;
			document.uData.h_country_code.value = DialingCodes[i+1];
			document.uData.h_country_code.disabled = true;
			return;
		}
	}
}

/* :::::: POPWIN FUNCTION(S) :::::: */
function openWin(page){
	var n=open("pop_devry.aspx?type=" + page, "newWin", "width=382,height=414, location=no,menubar=no,directories=no,toolbar=no,scrollbars=yes,resizable=no,status=no");
	n.focus();
}


/* :::::: 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 + '.');
		highlightError(text);
		text.value='';
		text.focus();
	}
	else if (this.containsProfanity(text.value))
	{
		this.raiseError(label + ' must not contain profane content.');
		text.select();
		highlightError(text);
	}
}
// 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 + '.');
		highlightError(text);
		text.value='';
		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)
{
	var frm = document.uData;
	if (!this.isValid) return;
	if(frm.country_code[frm.country_code.selectedIndex].value == 'US' || frm.country_code[frm.country_code.selectedIndex].value == 'MX')
	{
		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();
		}
	}
	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_validateGradYear(gradYear, label)
{
	if (!this.isValid) return;
	if (gradYear.value == '')
	{
		this.raiseError(label + ' must not be blank.');
		highlightError(gradYear);
		gradYear.focus();
	}
	else if (gradYear.value < '1954')
	{
		this.raiseError(label + ' must be after 1953.');
		highlightError(gradYear);
		gradYear.focus();
	}
	else if (!this.isNumeric(gradYear.value.toLowerCase()))
	{
		this.raiseError(label + ' contains invalid characters.');
		highlightError(gradYear);
		gradYear.select();
	}
	var d = new Date();
	var curr_year = d.getFullYear();
	if(gradYear.value > curr_year)
	{
		this.raiseError(label + ' must not be later than ' + curr_year + '.');
		highlightError(gradYear);
		gradYear.focus();
	}
}

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(" ")!=-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;
Validator.prototype.validateGradYear = V_validateGradYear;



//---------- form validation function ----------
function validateForm() {
	var frm = document.uData;
	var degID = 0;
	var v = new Validator();
	
	// 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 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 == '' && (frm.country_code[frm.country_code.selectedIndex].value == 'US' || frm.country_code[frm.country_code.selectedIndex].value == 'CA'))
	{
		if (v.isValid)
		{
			v.raiseError('Please select your state or Province.');
			highlightError(frm.state_code);
			frm.state_code.focus();
		}
	}
	
	// verify country is not blank & verify zip code
	if (frm.country_code[frm.country_code.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please select a country.');
			highlightError(frm.country_code);
			frm.country_code.focus();
		}
	}
	else 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 phone country
	if (frm.country_code.value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please enter your phone country code');
			frm.country_code.focus();
		}
	}
	
	if (frm.country_code.value != '' && frm.country_code.value.length >= 4 && !v.isPhoneNumeric(frm.country_code.value))
	{
		if (v.isValid)
		{
			v.raiseError('Phone country code should contain only numbers.');
			frm.country_code.focus();
		}
	}		
	// verify work phone fields
	// verify work area code, only if not null
	if (frm.w_area_code.value != '')
	{
		if (frm.w_area_code.value.length < 3)
		{
			if (v.isValid)
			{
				v.raiseError('Work Area code must have at least 3 digits');
				highlightError(frm.w_area_code);
				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.');
				highlightError(frm.w_area_code);
				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')
		{
			if (v.isValid)
			{
				v.raiseError('Work area code apears to be invalid.');
				highlightError(frm.w_area_code);
				frm.w_area_code.focus();
			}
		}
	}
	
	// verify work phone, only if not null
	if (frm.w_phone.value != '')
	{
		if ((frm.country_code[frm.country_code.selectedIndex].value == 'US') || (frm.country_code[frm.country_code.selectedIndex].value == 'CA'))
		{
			if (frm.w_phone.value != '' && frm.w_phone.value.length != 7)
			{
				if (v.isValid)
				{
					v.raiseError('Work phone number must have 7 digits');
					highlightError(frm.w_phone);
					frm.w_phone.focus();
				}
			}
		}
		else
		{
			// International phone numbers should be at least 4 digits
			if (frm.w_phone.value != '' && frm.w_phone.value.length < 4)
			{
				if (v.isValid)
				{
					v.raiseError('Work phone number must be at least 4 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.');
				highlightError(frm.w_phone);
				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.');
				highLightError(w_phone);
				frm.w_phone.focus();
			}
		}
	}
	
	// verify all work phone fields are filled out if any of them are
	if(frm.w_area_code.value != '' && frm.w_phone.value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please enter your work phone number');
			highlightError(frm.w_phone);
			frm.w_phone.focus();
		}
	}
	if(frm.w_area_code.value == '' && frm.w_phone.value != '')
	{
		if (v.isValid)
		{
			v.raiseError('Please enter your work area code');
			highlightError(frm.w_area_code);
			frm.w_area_code.focus();
		}
	}
		
	// verify home phone fields
	// verify 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 at least 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')
	{
		if (v.isValid)
		{
			v.raiseError('Home area code apears to be invalid.');
			highlightError(frm.h_area_code);
			frm.h_area_code.focus();
		}
	}
	
	// verify 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.country_code[frm.country_code.selectedIndex].value == 'US') || (frm.country_code[frm.country_code.selectedIndex].value == 'CA'))
	{
		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();
			}
		}
	}
	else
	{
		// International phone numbers should be at least 4 digits
		if (frm.h_phone.value != '' && frm.h_phone.value.length < 4)
		{
			if (v.isValid)
			{
				v.raiseError('Home phone number must be at least 4 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();
		}
	}
	
	// verify e-mail address is not blank and verify valid format
	v.validateEmail(frm.email, 'Email Address');
	
	// verify age is not blank
	if (frm.age_21[frm.age_21.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate your age.');
			highlightError(frm.age_21);
			frm.age_21.focus();
		}
	}
	
	// verify education level
	if (frm.education_level[frm.education_level.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate the highest degree you\'ve earned.');
			highlightError(frm.education_level);
			frm.education_level.focus();
		}
	}
	
	// verify year of graduation
		//	v.validateNumericOnly(frm.year_completion_date, 'Year of graduation');
	v.validateGradYear(frm.year_completion_date, 'Year of graduation');
	
	
	
	// verify institution attended
	if(frm.institution)
	{
		if (frm.institution.value == '')
		{
//	if (window.location.host.indexOf("welcome.keller") > -1 && frm.institution.value == '')
	//{
		if (v.isValid)
		{
			v.raiseError('Please enter your university or school attended');
			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 program preference.');
			highlightError(frm.program_code);
			frm.program_code.focus();
		}
	}

	// verify program_type
	if (frm.program_type[frm.program_type.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate your degree preference.');
			highlightError(frm.program_type);
			frm.program_type.focus();
		}
	}

	// verify incentive
	if (!frm.incentive[0].checked)
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate that you acknowledge no incentive associated with filling out this form.');
			highlightError(frm.incentive[0]);
			frm.incentive[0].focus();
		}
	}

	// verify accept_submit
	if (!frm.accept_submit[0].checked)
	{
		if (v.isValid)
		{
			v.raiseError('Please indicate that you would like to submit your request.');
			highlightError(frm.accept_submit[0]);
			frm.accept_submit[0].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;
			}
		}
		updateDialingCodeDevry();
		if(frm.w_phone != '')
			frm.w_country_code.value = frm.h_country_code.value;
		document.uData.h_country_code.disabled = false;
		frm.submit();
	}
}

