// 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
// @modified for form validation Tomas Gombos / 18/10/2006



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();
	if((qs.get("fader") && qs.get("fader") == "on") || l.indexOf("localhost") > -1 || l.indexOf("waldenonlineuniversity") > -1 || l.indexOf("degreereview") > -1)
	{ //Check querystring to see if it contains "fader=on", or if url contains "waldenonlineuniversity" 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";}
		if(l.indexOf("waldenonlineuniversity") > -1){sfcolor = "F8F5EE";efcolor = "E9DFC0";}
		// 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.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='';
		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 < 3)
	{
		this.raiseError('Please enter your ' + label + ' its to short.');
		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;


//---------- 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 == ''))
		{ 
			
			
			var answer = confirm ("Do you have a valid RN License?");
				if (answer)
				{
				//alert ("Woo Hoo! So am I.");
				document.uData.current_rn.value = "Yes";
				document.uData.dupa.value = 1;
				}
					else
					{
				//	alert ("Darn. Well, keep trying then.");
					document.uData.current_rn.value = "No"
					document.uData.dupa.value = 2;
					}
			
			
			
			
			
			//			nursingPopUp();
		}
}
http://www.waldenonlineuniversity.com/pop_walden_nursing.aspx

//pop_walden_nursing.aspx
function nursingPopUp()
{
	if (document.uData.quest2.value == "NURSING.GEN.INTEREST" || document.uData.quest2.value == "MS.W1HHS.NUR.W1ED" || document.uData.quest2.value == "MS.W1HHS.NUR.W1LMS" || document.uData.quest2.value == "NURSING.GEN.INTERES2" || document.uData.quest2.value == "MS.W1HHS.NUR.W1ED2" || document.uData.quest2.value == "MS.W1HHS.NUR.W1LMS2")
			{
			var answer = confirm ("Do you have a valid RN License?");
				if (answer)
				{
				//alert ("Woo Hoo! So am I.");
				document.uData.current_rn.value = "Yes";
				document.uData.dupa.value = 1;
				}
					else
					{
					//alert ("Darn. Well, keep trying then.");
					document.uData.current_rn.value = "No"
					document.uData.dupa.value = 1;
					}
			
	    	}	
	
	
	
	
	
	//var nursingPop = window.open('http://www.waldenonlineuniversity.com/pop_walden_nursing.aspx', '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.');
			highlightError(frm.exp_1);
			frm.exp_1.focus();
		}
	}
	
	// verify first name is not blank
	v.validateTextChars(frm.first_name, 'First Name');


		
	//if (document.uData.first_name.value.length < 3)
	
	//{	alert ("First name length is to short.");
	//highlightError(frm.first_name);
	//document.uData.first_name.focus();
	//return false;
	//}
	
	
	// 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.');
			highlightError(frm.state_code);
			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.');
			highlightError(frm.country_code);
			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.');
			highlightError(frm.country_code);
			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');
			highlightError(frm.h_area_code);
			frm.h_area_code.focus();
		}
	}
	
	if (frm.h_area_code.value != '' && frm.h_area_code.value.length < 2)
	{
		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();
		}
	}
	
	// verify work area code
	if (frm.w_area_code.value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please enter your work area code');
			highlightError(frm.w_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');
			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' || frm.w_area_code.value == '098')
	{
		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 number
	if (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_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();
		}
	}
	
	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(frm.w_phone);
			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.');
			highlightError(frm.w_phone);
			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.');
			highlightError(frm.exp_4);
			frm.exp_4.focus();
		}
	}
	
	if (frm.exp_2[frm.exp_2.selectedIndex].value == '')
	{
		if (v.isValid)
		{
			v.raiseError('Please select Best time to call.');
			highlightError(frm.exp_2);
			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.');
			highlightError(frm.exp_3[0]);
			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.');
			highlightError(frm.education_level);
			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.');
			highlightError(frm.education_level);
			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.');
			highlightError(frm.program_code);
			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.');
			highlightError(frm.enroll_timeframe);
			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();
	}
}
