/*
	EMERSON COLLEGE
		ADMISSIONS PORTAL
			JAVASCRIPT FILE - GENERAL

		VERSION 0.7
*/

function getURLSRC(uri) {
	uri.dir = location.href.substring(0,location.href.lastIndexOf('\/'));
	uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
	uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
	uri.page = location.href.substring(uri.dir.length+1,location.href.length+1);
	pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}

var uri = new Object();
getURLSRC(uri);

//	VARIABLES
general_rooturl = 'http://' + uri.dom;


// Finds the object reguardless of platform
function element(id) { 
	if (document.getElementById != null) {
		// Works for most, but not N4 or IE4
		return document.getElementById(id);
	} else if (document.all != null) {
		// Only works in all IE
		return document.all[id];
	} else if (document.layers != null) {
		// Works only in N4
		return document.layers[id];
	} else {
		// If we get here, browser isn't JS/CSS/DOM complitant at all!
		//		Are we running Lynx here?
		return null;
	}
}

// Null javascript function
function nulled() {
	null;
}

// Standard getURL fuction
function getURL(src,win,root) {
	// Vars
	if (root == undefined) { root = 0; }
	if (win == undefined) { win = 0; }
	
	// Add root URL if needed
	if (root == 1) {
        liveSrc = general_rooturl + src;
    } else {
        liveSrc = src;
    }
	
	if (win == 1) {	// Make a new window
		//window.location.href = liveSrc;
		window.open(liveSrc,'_blank','copyhistory=yes,resizable=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes');
	} else {// Same window
		document.location.href = liveSrc;
	}
}


// Activates the menu properties
function activateMenu(area) {
	//alert("activateMenu() ->\n"+page_type + "_navbar_element_" + areas[area]+"|\narea = "+area);
	clearallmenu(area);
	element(page_type + "_navbar_element_" + areas[area]).className = "navbar_element_selected";
	element(page_type + "_navbar_element_link_" + areas[area]).className = "navbar_element_selected_link";
	element(page_type + "_navbar_" + areas[area]).style.display = "block";
	element(page_type + "_navbar_element_" + areas[area]).style.borderRightColor = "#9FC823";
	if (area == 0) {
		element(page_type + "_navbar_element_" + areas[area]).style.borderLeftColor = "#9FC823";
	} else {
		tempvar = (area - 1);
		//alert(tempvar)
		element(page_type + "_navbar_element_" + areas[tempvar]).style.borderRightColor = "#9FC823";
		if (tempvar != 0) {
			element(page_type + "_navbar_element_" + areas[tempvar]).style.borderLeftColor = "#9FC823";
		}
	}
}

// Reset every menu element to defaults.
function clearallmenu(active) {
	var count = 0;
	while (areas.length > count) {
		if (active != count) {
		//alert(page_type + "_navbar_element_" + areas[count]);
		element(page_type + "_navbar_element_" + areas[count]).className = "navbar_element";
		element(page_type + "_navbar_element_link_" + areas[count]).className = "navbar_element_link";
		element(page_type + "_navbar_" + areas[count]).style.display = "none";
		element(page_type + "_navbar_element_" + areas[count]).style.borderRightColor = "#FFFFFF";
		element(page_type + "_navbar_element_" + areas[count]).style.borderLeftColor = "#FFFFFF";
		}
		count++;
	}
	
}

// Reset every menu element to defaults.
function clearDefaultMenu(standard) {
	var count = 0;
	if (typeof(areas) != "undefined") {
		while (areas.length > count) {
			if (standard != areaIDs[count]) {
			  //alert(page_type + "_navbar_element_" + areas[count]);
			  element(page_type + "_navbar_element_" + areas[count]).className = "navbar_element";
			  element(page_type + "_navbar_element_link_" + areas[count]).className = "navbar_element_link";
			  element(page_type + "_navbar_" + areas[count]).style.display = "none";
			  element(page_type + "_navbar_element_" + areas[count]).style.borderRightColor = "#FFFFFF";
			  element(page_type + "_navbar_element_" + areas[count]).style.borderLeftColor = "#FFFFFF";	
			} else {
			  //alert("clearDefaultMenu() -> activateMenu("+areas[count]+")");
			  activateMenu(count);
			}
			count++;
		}
	}
}

// Change CSS styles
function changeStyle(type) {
	changeCSS(type);
	if (type == 0) {
		changeCSS(0);
		element("changeCSStext").innerHTML = "<a href='javascript:changeStyle(1);'>Full View Site</a>";
	} else {
		changeCSS(1);
		element("changeCSStext").innerHTML = "<a href='javascript:changeStyle(0);'>Text Only Site</a>";
	}
}
function cssChangeType() {
	if (document.getElementsByTagName) {
		x = document.getElementsByTagName('link');
	} else if (document.all) {
		x = document.all.tags('link');
	} else {
		alert('This script does not work in your browser.');
		return;
	}
	return x;
}
function changeCSS(nr) {
	x = cssChangeType();
	nr--;
	for (var i=0;i<x.length;i++) {
		dis = !(i == nr);
		x[i].disabled = dis;
	}
}

function mainarea_infobar_show(id) {
	
	$(id).style.display='block';
	
}
function mainarea_infobar_hide(id) {
	
	$(id).style.display='none';
	
}

/*

	MACROMEDIA FLASH DETECTION
	(C) MACROMEDIA 2005

*/

<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 7;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Revision of Flash required
var requiredRevision = 0;
// the version of javascript supported
var jsVersion = 1.0;
// -----------------------------------------------------------------------------
// -->

<!-- // Detect Client Browser type
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.1;
// JavaScript helper required to detect Flash Player PlugIn version information
function JSGetSwfVer(i){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			descArray = flashDescription.split(" ");
			tempArrayMajor = descArray[2].split(".");
			versionMajor = tempArrayMajor[0];
			versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
      		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
            flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
      	} else {
			flashVer = -1;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	// Can't detect in all other cases
	else {
		
		flashVer = -1;
	}
	return flashVer;
} 
// If called with no parameters this function returns a floating point value 
// which should be the version of the Flash Player or 0.0 
// ex: Flash Player 7r14 returns 7.14
// If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
{
 	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
   	// loop backwards through the versions until we find the newest version	
	for (i=25;i>0;i--) {	
		if (isIE && isWin && !isOpera) {
			versionStr = VBGetSwfVer(i);
		} else {
			versionStr = JSGetSwfVer(i);		
		}
		if (versionStr == -1 ) { 
			return false;
		} else if (versionStr != 0) {
			if(isIE && isWin && !isOpera) {
				tempArray         = versionStr.split(" ");
				tempString        = tempArray[1];
				versionArray      = tempString .split(",");				
			} else {
				versionArray      = versionStr.split(".");
			}
			versionMajor      = versionArray[0];
			versionMinor      = versionArray[1];
			versionRevision   = versionArray[2];
			//alert("Major: "+versionArray[0]+"\nMinor: "+versionArray[1]+"\nRevision: "+versionArray[2]);
			
			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
			versionNum        = parseFloat(versionString);
        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
				return true;
			} else {
				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
			}
		}
	}	
	return (reqVer ? false : 0.0);
}


/*

	CommonSpot Javascript Functions
	
*/
function doLink921() {
	window.location.href = '';
}
function SubmitForm921() {
	retval = doSubmit921();
	if (retval == true)
		document.dlgform921.submit();
}
function doSubmit921() {
	if (document.dlgform921.srchString.value.length == 0) {
		alert ("Please enter something to search for");
		return false;
	}
	document.dlgform921.startpage.value=1;
	document.dlgform921.curpage.value=1;
	return true;
}


/*
	Main Title Flash Publisher
*/

function loadFlashTitle_main(admissionUrl,imagesUrl) {
	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
	
	if(hasRightVersion) {  // if we've detected an acceptable version
		var oeTags = '<div id="root_image_flash"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
		+ 'width="800" height="422"'
		+ 'codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
		+ '<param name="movie" value="' + admissionUrl + 'templates/swf/admission.swf" />'
		+ '<param name="menu" value="false" />'
		+ '<param name="quality" value="best" />'
		+ '<param name="bgcolor" value="#ffffff" />'
		+ '<embed src="' + admissionUrl + 'templates/swf/admission.swf" menu="false" quality="best" bgcolor="#ffffff" '
		+ 'width="800" height="422" name="admission" align="middle"'
		+ 'play="true"'
		+ 'loop="false"'
		+ 'quality="high"'
		+ 'allowScriptAccess="sameDomain"'
		+ 'type="application/x-shockwave-flash"'
		+ 'pluginspage="https://www.adobe.com/go/getflashplayer">'
		+ '<\/EMBED>'
		+ '<\/OBJECT></div>';
		document.write(oeTags);   // embed the flash movie
	} else {
		document.write('<div id="root_image_noflash">				<img src="' + imagesUrl + 'admission_ho');
		document.write('me.png" alt="Hello." title="" width="800" height="442" border="0" usemap="');
		document.write('#hello_map" />				<map name="hello_map" id="hello_map">					<area shape="');
		document.write('poly" coords="356,402,356,226,487,226,487,215,525,215,525,270,543,270,543,3');
		document.write('94,536,393,536,403" href="http://www.emerson.edu/ce/" target="_blank" title');
		document.write('="Continuing Education: Want more?" alt="Continuing Education" />					<are');
		document.write('a shape="rect" coords="525,90,704,270" href="/admission/graduate/" title="G');
		document.write('raduate Admission: Choose Your Path" alt="Graduate Admission" />					<area');
		document.write(' shape="rect" coords="299,38,487,226" href="/admission/undergraduate/" titl');
		document.write('e="Undergraduate Admission: Who are you?" alt="Undergraduate Admission" />');
		document.write('				</map>			</div>');
	}
	
}
/*
	EMERSON COLLEGE
		ADMISSIONS PORTAL
			JAVASCRIPT FILE - FORMS

		VERSION 1.2
*/


	var regex_email = /^[a-z0-9][^\(\)\<\>\@\,\;\:\\\"\[\]]*\@[a-z0-9][a-z0-9\-\.]*\.[a-z]{2,4}$/i;
	var regex_states = /[a-z]{2}/i;
	var regex_zip_us = /^(\d{5}-\d{4})|(\d{5})$/;
	var regex_phone_us = /^[(\[]?\d{3}[)-\.\] ]*\d{3}[-\. ]?\d{4}$/;
	
	var check_emailChecker = regex_email;
	var check_zipcode = regex_zip_us;

	var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
	var check_sportsDisplay_resetvalues_array = new Array('cbBasketball','cbCrossCountry','cbTrack','cbLacrosse','cbSoccer','cbSoftball','cbTennis','cbVolleyball','cbBaseball','cbGolf','cbDance');

function check_gradinquiry() {
	
	var check_gradInquiry_alert = false;
	var check_gradinquiry_countryType = '';
	
	// Checks all elements for required and proper formating.
	
		// First name (exists)
		
			if ($F('tbFirstName') == "") {
				check_failedTest('tbFirstName');
				check_gradInquiry_alert = true;
			} else {
				check_passedTest('tbFirstName');
			}
		
		// Last name (exists)
		
			if ($F('tbLastName') == "") {
				check_failedTest('tbLastName');
				check_gradInquiry_alert = true;
			} else {
				check_passedTest('tbLastName');
			}
		
		// Gender (selected)
		
			if ($('rbSex_m').checked === false && $('rbSex_f').checked === false) {
				//check_failedTest('rbSex','Please select your gender.');
				//check_gradInquiry_alert = true;
			} else {
				check_passedTest('rbSex');
			}
		
		// E-mail (exists && formated)
		
			
		
			// First check if something is filled in:
			if ($F('tbEmailAddress') == "") {
				check_failedTest('tbEmailAddress','Please insert your e-mail address.');
				check_gradInquiry_alert = true;
			} else if (check_emailChecker.test($F('tbEmailAddress')) === false) {
				check_failedTest('tbEmailAddress','Please enter a valid e-mail address.');
				check_gradInquiry_alert = true;
			} else {
				check_passedTest('tbEmailAddress');
			}
				
		
		// Country (selected)
		
			if ($('cbxCountry').selectedIndex < 1) {
				check_failedTest('cbxCountry','Please select a country and complete all required information');
				check_gradInquiry_alert = true;
			} else if ($('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "other" && $F('tbCountry') == "") {
				check_passedTest('cbxCountry');
				check_failedTest('tbCountry','Please include the name of your country in the text box above.');
				check_gradinquiry_countryType = 'nonUs';
				check_gradInquiry_alert = true;
			} else {
				check_passedTest('cbxCountry');
				check_passedTest('tbCountry');
				if ($('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "united states of america" || $('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "united states") {
					check_gradinquiry_countryType = 'us';
				} else {
					check_gradinquiry_countryType = 'nonUs';
				}
			}
		
		// General Information (dependent on country select
		if (check_gradinquiry_countryType != "") {
			
			// Address (exists)
			
				if ($F('tbAddressLine1') == "") {
					check_failedTest('tbAddressLine1');
					check_gradInquiry_alert = true;
				} else {
					check_passedTest('tbAddressLine1');
				}
			
			// City (exists)
			
				if ($F('tbCity') == "") {
					check_failedTest('tbCity');
					check_gradInquiry_alert = true;
				} else {
					check_passedTest('tbCity');
				}
				
		}
		
		// Non-US Information:
			
			if (check_gradinquiry_countryType == 'nonUs') {
				
				// Postal Code (exists if NOT US)
					if ($F('tbPostalCode') == "") {
						check_failedTest('tbPostalCode');
						check_gradInquiry_alert = true;
					} else {
						check_passedTest('tbPostalCode');
					}
				
		
		// US Only Information:
			
			} else if (check_gradinquiry_countryType == 'us') {
				
				// State (exists only if US)
					if ($('cbxState').selectedIndex < 1) {
						check_failedTest('cbxState','Please select your state.');
						check_gradInquiry_alert = true;
					} else {
						check_passedTest('cbxState');
					}
				
				// Zip (formated && exists only if US)
				
				
				
					if (!check_zipcode.test($F('zip_code'))) {
						check_failedTest('zip_code','Please enter your 5 digit (or ZIP+4) zip code.');
						check_gradInquiry_alert = true;
					} else {
						check_passedTest('zip_code');
					}
				
				
				// Phone (formated only)
				
				// Fax (formated only)
				
			}
		
		// Interest Question
		
		if ($('cbxInterest').selectedIndex < 1) {
			check_failedTest('cbxInterest','Please select an Interest.');
		} else {
			check_passedTest('cbxInterest');
		}
		
	// Submit if all is well
		
		if (check_gradInquiry_alert === false) {
			$('gradInquiryForm').submit();
			check_passedTest('SendButton');
		} else {
			check_failedTest('SendButton','There is a problem with your submission. Please review the form above and correct any errors.');
		}
}

function check_gradInquiry_reset() {
		// Reset all
			check_countryDisplay_resetvalues('all');
			check_countryDisplay_resetvalues('us');
			check_countryDisplay_resetvalues('nonUs');
			check_countryDisplay_resetvalues('other');
			
			check_passedTest('tbFirstName');
			check_passedTest('tbLastName');
			check_passedTest('rbSex');
			check_passedTest('tbEmailAddress');
			check_passedTest('cbxCountry');
			check_passedTest('tbCountry');
			check_passedTest('tbAddressLine1');
			check_passedTest('tbCity');
			check_passedTest('tbPostalCode');
			check_passedTest('cbxState');
			check_passedTest('zip_code');
			check_passedTest('cbxInterest');
			check_passedTest('SendButton');
			
		// Hide all
			//if (Element.visible('postCountry_all')) { new Effect.BlindUp('postCountry_all'); }
			if (Element.visible('postCountry_us')) { new Effect.BlindUp('postCountry_us'); }
			if (Element.visible('postCountry_nonUs')) { new Effect.BlindUp('postCountry_nonUs'); }
			if (Element.visible('postCountry_other')) { new Effect.BlindUp('postCountry_other'); }
			
}

/*

	PICTURE YORUSELF FUNCTIONS

*/

function check_pictureYourself() {
	
	var check_pictureYourself_alert = false;
	var check_pictureYourself_countryType = '';
	
	// Checks all elements for required and proper formating.
	
		// First name (exists)
		
			if ($F('tbFirstName') == "") {
				check_failedTest('tbFirstName');
				check_pictureYourself_alert = true;
			} else {
				check_passedTest('tbFirstName');
			}
		
		// Last name (exists)
		
			if ($F('tbLastName') == "") {
				check_failedTest('tbLastName');
				check_pictureYourself_alert = true;
			} else {
				check_passedTest('tbLastName');
			}
		
		// Attendees (exists and is numeric)
		
			if ($F('tbAttendees') == "") {
				check_failedTest('tbAttendees');
				check_pictureYourself_alert = true;
			//} else if (isNumber($F('tbAttendees')) = false) {
			//	check_failedTest('tbAttendees');
			//	check_pictureYourself_alert = true;					   				   
			} else {
				check_passedTest('tbAttendees');
			}
		
		
		// E-mail (exists && formated)
		
			
		
			// First check if something is filled in:
			if ($F('tbEmailAddress') == "") {
				check_failedTest('tbEmailAddress','Please insert your e-mail address.');
				check_pictureYourself_alert = true;
			} else if (check_emailChecker.test($F('tbEmailAddress')) === false) {
				check_failedTest('tbEmailAddress','Please enter a valid e-mail address.');
				check_pictureYourself_alert = true;
			} else {
				check_passedTest('tbEmailAddress');
			}
				
		
		// Country (selected)
		
			if ($('cbxCountry').selectedIndex < 1) {
				check_failedTest('cbxCountry','Please select a country and complete all required information');
				check_pictureYourself_alert = true;
			} else if ($('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "other" && $F('tbCountry') == "") {
				check_passedTest('cbxCountry');
				check_failedTest('tbCountry','Please include the name of your country in the text box above.');
				check_pictureYourself_countryType = 'nonUs';
				check_pictureYourself_alert = true;
			} else {
				check_passedTest('cbxCountry');
				check_passedTest('tbCountry');
				if ($('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "united states of america" || $('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "united states") {
					check_pictureYourself_countryType = 'us';
				} else {
					check_pictureYourself_countryType = 'nonUs';
				}
			}
		
		// General Information (dependent on country select
		if (check_pictureYourself_countryType != "") {
			
			// Address (exists)
			
				if ($F('tbAddressLine1') == "") {
					check_failedTest('tbAddressLine1');
					check_pictureYourself_alert = true;
				} else {
					check_passedTest('tbAddressLine1');
				}
			
			// City (exists)
			
				if ($F('tbCity') == "") {
					check_failedTest('tbCity');
					check_pictureYourself_alert = true;
				} else {
					check_passedTest('tbCity');
				}
				
		}
		
		// Non-US Information:
			
			if (check_pictureYourself_countryType == 'nonUs') {
				
				// Postal Code (exists if NOT US)
					if ($F('tbPostalCode') == "") {
						check_failedTest('tbPostalCode');
						check_pictureYourself_alert = true;
					} else {
						check_passedTest('tbPostalCode');
					}
				
		
		// US Only Information:
			
			} else if (check_pictureYourself_countryType == 'us') {
				
				// State (exists only if US)
					if ($('cbxState').selectedIndex < 1) {
						check_failedTest('cbxState','Please select your state.');
						check_pictureYourself_alert = true;
					} else {
						check_passedTest('cbxState');
					}
				
				// Zip (formated && exists only if US)
				
				
				
					if (!check_zipcode.test($F('zip_code'))) {
						check_failedTest('zip_code','Please enter your 5 digit (or ZIP+4) zip code.');
						check_pictureYourself_alert = true;
					} else {
						check_passedTest('zip_code');
					}
				
				
				// Phone (formated only)
				
				// Fax (formated only)
				
			}
		
		// RSVP Date
		
		if ($('eventDate').selectedIndex < 1) {
			check_failedTest('eventDate','Please select an date to RSVP for.');
			check_pictureYourself_alert = true;
		} else {
			check_passedTest('eventDate');
		}
		
		// High School check
		
		/*if ($F('tbSchool') == "") {
			check_failedTest('tbSchool','Please include the name of your High School.');
			check_pictureYourself_alert = true;
		} else {
			check_passedTest('tbSchool');
		}*/
			
		
	// Submit if all is well
		
		if (check_pictureYourself_alert === false) {
			$('pictureYourselfForm').submit();
			check_passedTest('SendButton');
		} else {
			check_failedTest('SendButton','There is a problem with your submission. Please review the form above and correct any errors.');
		}
}

function check_pictureYourself_reset() {
		
		// Reset all
			check_countryDisplay_resetvalues('all');
			check_countryDisplay_resetvalues('us');
			check_countryDisplay_resetvalues('nonUs');
			check_countryDisplay_resetvalues('other');
			
			check_passedTest('eventDate');
			check_passedTest('tbFirstName');
			check_passedTest('tbLastName');
			check_passedTest('tbEmailAddress');
			check_passedTest('cbxCountry');
			check_passedTest('tbCountry');
			check_passedTest('tbAddressLine1');
			check_passedTest('tbCity');
			check_passedTest('tbPostalCode');
			check_passedTest('cbxState');
			check_passedTest('zip_code');
			check_passedTest('SendButton');
			check_passedTest('tbSchool');
			
		// Hide all
			//if (Element.visible('postCountry_all')) { new Effect.BlindUp('postCountry_all'); }
			if (Element.visible('postCountry_us')) { new Effect.BlindUp('postCountry_us'); }
			if (Element.visible('postCountry_nonUs')) { new Effect.BlindUp('postCountry_nonUs'); }
			if (Element.visible('postCountry_other')) { new Effect.BlindUp('postCountry_other'); }
			
}

/*

	GRADUATE OPEN HOUSE RSVP

*/

function check_gradOHRSVP() {
	
	var check_gradOHRSVP_alert = false;
	var check_gradOHRSVP_countryType = '';
	
	// Checks all elements for required and proper formating.
	
		// First name (exists)
		
			if ($F('tbFirstName') == "") {
				check_failedTest('tbFirstName');
				check_gradOHRSVP_alert = true;
			} else {
				check_passedTest('tbFirstName');
			}
		
		// Last name (exists)
		
			if ($F('tbLastName') == "") {
				check_failedTest('tbLastName');
				check_gradOHRSVP_alert = true;
			} else {
				check_passedTest('tbLastName');
			}
		
		/* Gender (selected)
		
			if ($('rbSex_m').checked === false && $('rbSex_f').checked === false) {
				check_failedTest('rbSex','Please select your gender.');
				check_gradOHRSVP_alert = true;
			} else {
				check_passedTest('rbSex');
			}
		*/
		
		// E-mail (exists && formated)
		
			if ($F('tbEmailAddress') == "") {
				check_failedTest('tbEmailAddress','Please insert your e-mail address.');
				check_gradOHRSVP_alert = true;
			} else if (check_emailChecker.test($F('tbEmailAddress')) === false) {
				check_failedTest('tbEmailAddress','Please enter a valid e-mail address.');
				check_gradOHRSVP_alert = true;
			} else {
				check_passedTest('tbEmailAddress');
			}
				
		
		// Country (selected)
		
			if ($('cbxCountry').selectedIndex < 1) {
				check_failedTest('cbxCountry','Please select a country and complete all required information');
				check_gradOHRSVP_alert = true;
			} else if ($('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "other" && $F('tbCountry') == "") {
				check_passedTest('cbxCountry');
				check_failedTest('tbCountry','Please include the name of your country in the text box above.');
				check_gradOHRSVP_countryType = 'nonUs';
				check_gradOHRSVP_alert = true;
			} else {
				check_passedTest('cbxCountry');
				check_passedTest('tbCountry');
				if ($('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "united states of america" || $('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "united states") {
					check_gradOHRSVP_countryType = 'us';
				} else {
					check_gradOHRSVP_countryType = 'nonUs';
				}
			}
		
		// General Information (dependent on country select
		if (check_gradOHRSVP_countryType != "") {
			
			// Address (exists)
			
				if ($F('tbAddressLine1') == "") {
					check_failedTest('tbAddressLine1');
					check_gradOHRSVP_alert = true;
				} else {
					check_passedTest('tbAddressLine1');
				}
			
			// City (exists)
			
				if ($F('tbCity') == "") {
					check_failedTest('tbCity');
					check_gradOHRSVP_alert = true;
				} else {
					check_passedTest('tbCity');
				}
				
		}
		
		// Non-US Information:
			
			if (check_gradOHRSVP_countryType == 'nonUs') {
				
				// Postal Code (exists if NOT US)
					if ($F('tbPostalCode') == "") {
						check_failedTest('tbPostalCode');
						check_gradOHRSVP_alert = true;
					} else {
						check_passedTest('tbPostalCode');
					}
				
		
		// US Only Information:
			
			} else if (check_gradOHRSVP_countryType == 'us') {
				
				// State (exists only if US)
					if ($('cbxState').selectedIndex < 1) {
						check_failedTest('cbxState','Please select your state.');
						check_gradOHRSVP_alert = true;
					} else {
						check_passedTest('cbxState');
					}
				
				// Zip (formated && exists only if US)
				
				
				
					if (!check_zipcode.test($F('zip_code'))) {
						check_failedTest('zip_code','Please enter your 5 digit (or ZIP+4) zip code.');
						check_gradOHRSVP_alert = true;
					} else {
						check_passedTest('zip_code');
					}
				
				
				// Phone (formated only)
				
				// Fax (formated only)
				
			}
		
		// Interest Question
		
		if ($('cbxInterest').selectedIndex < 1) {
			check_failedTest('cbxInterest','Please select an Interest.');
			check_gradOHRSVP_alert = true;
		} else {
			check_passedTest('cbxInterest');
		}
		
		// Number of Party
		
		if ($('tbPartySize').options[$('tbPartySize').selectedIndex].value < 0) {
			check_failedTest('tbPartySize','Please select the amount of people in your party including yourself.');
			check_gradOHRSVP_alert = true;
		} else {
			check_passedTest('tbPartySize');
		}

		// RSVP Date
		
		if ($('cbxSession').selectedIndex < 1) {
			check_failedTest('cbxSession','Please select an date to RSVP for.');
			check_pictureYourself_alert = true;
		} else {
			check_passedTest('cbxSession');
		}

		
	// Submit if all is well
		
		if (check_gradOHRSVP_alert === false) {
			$('gradOHRSVPForm').submit();
			check_passedTest('SendButton');
		} else {
			check_failedTest('SendButton','There is a problem with your submission. Please review the form above and correct any errors.');
		}
}

function check_gradOHRSVP_reset() {
		// Reset all
			check_countryDisplay_resetvalues('all');
			check_countryDisplay_resetvalues('us');
			check_countryDisplay_resetvalues('nonUs');
			check_countryDisplay_resetvalues('other');
			
			check_passedTest('tbFirstName');
			check_passedTest('tbLastName');
			check_passedTest('rbSex');
			check_passedTest('tbEmailAddress');
			check_passedTest('cbxCountry');
			check_passedTest('tbCountry');
			check_passedTest('tbAddressLine1');
			check_passedTest('tbCity');
			check_passedTest('tbPostalCode');
			check_passedTest('cbxState');
			check_passedTest('zip_code');
			check_passedTest('cbxInterest');
			check_passedTest('cbxSession');
			check_passedTest('SendButton');
			
		// Hide all
			//if (Element.visible('postCountry_all')) { new Effect.BlindUp('postCountry_all'); }
			if (Element.visible('postCountry_us')) { new Effect.BlindUp('postCountry_us'); }
			if (Element.visible('postCountry_nonUs')) { new Effect.BlindUp('postCountry_nonUs'); }
			if (Element.visible('postCountry_other')) { new Effect.BlindUp('postCountry_other'); }
			
}


/*

	UNDERGRADUATE INQUIRY
	
*/



function check_undergradInquiry() {
	
	var check_undergradInquiry_alert = false;
	var check_undergradInquiry_countryType = '';
	
	// Checks all elements for required and proper formating.
	
		// First name (exists)
		
			if ($F('tbFirstName') == "") {
				check_failedTest('tbFirstName');
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('tbFirstName');
			}
		
		// Last name (exists)
		
			if ($F('tbLastName') == "") {
				check_failedTest('tbLastName');
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('tbLastName');
			}
		
		// Gender (selected)
		
			if ($('rbSex_m').checked === false && $('rbSex_f').checked === false) {
				check_failedTest('rbSex','Please select your gender.');
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('rbSex');
			}
		
		// E-mail (exists && formated)
		
			
		
			// First check if something is filled in:
			if ($F('tbEmailAddress') == "") {
				check_failedTest('tbEmailAddress','Please insert your e-mail address.');
				check_undergradInquiry_alert = true;
			} else if (check_emailChecker.test($F('tbEmailAddress')) === false) {
				check_failedTest('tbEmailAddress','Please enter a valid e-mail address.');
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('tbEmailAddress');
			}
				
		// Date of Birth
		
			if ($('tbDateOfBirth_month').selectedIndex < 1 || $('tbDateOfBirth_day').selectedIndex < 1 || $('tbDateOfBirth_year').selectedIndex < 1) {
				check_failedTest('tbDateOfBirth','Please select your date of birth.');
				check_undergradInquiry_alert = true;
			} else if (!checkDate('tbDateOfBirth')) {
				check_failedTest('tbDateOfBirth','This date does not exist. Please check your date of birth.');
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('tbDateOfBirth');
			}
		
		// Enroll Date
			
			if ($('cbxEnrollDate').selectedIndex < 1) {
				check_failedTest('cbxEnrollDate','Please select your intended enrollment date.');
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('cbxEnrollDate');
			}
			
		// Enroll Type
		
			if ($('rbEnrollType_t').checked === false && $('rbEnrollType_f').checked === false) {
				check_failedTest('rbEnrollType','Please select your enrollment type.');
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('rbEnrollType');
			}
			
		// US Citizen?
		
			if ($('rbCitizen_y').checked === false && $('rbCitizen_n').checked === false) {
				check_failedTest('rbCitizen','Please select your citizen status.');
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('rbCitizen');
			}
			
		// Residence Status (if not US Citizen)
		
			if ($('rbResident_y').checked === false && $('rbResident_n').checked === false && $('rbCitizen_n').checked === true) {
				check_failedTest('rbResident','Please select your U.S. resident status.');
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('rbResident');
			}
			
		// Country (selected)
		
			if ($('cbxCountry').selectedIndex < 1) {
				check_failedTest('cbxCountry','Please select a country and complete all required information');
				check_undergradInquiry_alert = true;
			} else if ($('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "other" && $F('tbCountry') == "") {
				check_passedTest('cbxCountry');
				check_failedTest('tbCountry','Please include the name of your country in the text box above.');
				check_undergradInquiry_countryType = 'nonUs';
				check_undergradInquiry_alert = true;
			} else {
				check_passedTest('cbxCountry');
				check_passedTest('tbCountry');
				if ($('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "united states of america" || $('cbxCountry').options[$('cbxCountry').selectedIndex].value.toLowerCase() == "united states") {
					check_undergradInquiry_countryType = 'us';
				} else {
					check_undergradInquiry_countryType = 'nonUs';
				}
			}
		
		// General Information (dependent on country select
		if (check_undergradInquiry_countryType != "") {
			
			// Address (exists)
			
				if ($F('tbAddressLine1') == "") {
					check_failedTest('tbAddressLine1');
					check_undergradInquiry_alert = true;
				} else {
					check_passedTest('tbAddressLine1');
				}
			
			// City (exists)
			
				if ($F('tbCity') == "") {
					check_failedTest('tbCity');
					check_undergradInquiry_alert = true;
				} else {
					check_passedTest('tbCity');
				}
				
		}
		
		// Non-US Information:
			
			if (check_undergradInquiry_countryType == 'nonUs') {
				
				// Postal Code (exists if NOT US)
					if ($F('tbPostalCode') == "") {
						check_failedTest('tbPostalCode');
						check_undergradInquiry_alert = true;
					} else {
						check_passedTest('tbPostalCode');
					}
				
		
		// US Only Information:
			
			} else if (check_undergradInquiry_countryType == 'us') {
				
				// State (exists only if US)
					if ($('cbxState').selectedIndex < 1) {
						check_failedTest('cbxState','Please select your state.');
						check_undergradInquiry_alert = true;
					} else {
						check_passedTest('cbxState');
					}
				
				// Zip (formated && exists only if US)
				
				
				
					if (!check_zipcode.test($F('zip_code'))) {
						check_failedTest('zip_code','Please enter your 5 digit (or ZIP+4) zip code.');
						check_undergradInquiry_alert = true;
					} else {
						check_passedTest('zip_code');
					}
				
				
				// Phone (formated only)
				
				// Fax (formated only)
				
			}
		
		// Interest Question
		
		if ($('cbxInterest').selectedIndex < 1) {
			check_failedTest('cbxInterest','Please select an Interest.');
		} else {
			check_passedTest('cbxInterest');
		}
		
		// Sports question
		
			if ($('rbSports_y').checked === false && $('rbSports_n').checked === false) {
				check_failedTest('rbSports','Please select your sport preference.');
				check_undergradInquiry_alert = true;
			} else if ($('rbSports_y').checked === true) {
				
				var check_sportsDisplay_resetvalues_arrayCount = 0;
				
				// Check sports to see if at least one is selected.
				for (i = 0; i < check_sportsDisplay_resetvalues_array.length; i++) {
					
					if ($(check_sportsDisplay_resetvalues_array[i]).checked === true) {
						check_sportsDisplay_resetvalues_arrayCount++;
					}
				}
				
				if (check_sportsDisplay_resetvalues_arrayCount < 1) {
					check_failedTest('rbSports','Please select at least one sport you are interested in.');
					check_undergradInquiry_alert = true;
				} else {
					check_passedTest('rbSports');
				}
				
			} else {
				check_passedTest('rbSports');
			}
		
		
	// Submit if all is well
		
		if (check_undergradInquiry_alert === false) {
			$('undergradInquiryForm').submit();
			check_passedTest('SendButton');
		} else {
			check_failedTest('SendButton','There is a problem with your submission. Please review the form above and correct any errors.');
		}
}

function check_undergradInquiry_reset() {
		// Reset all
			check_countryDisplay_resetvalues('all');
			check_countryDisplay_resetvalues('us');
			check_countryDisplay_resetvalues('nonUs');
			check_countryDisplay_resetvalues('other');
			
			check_passedTest('tbFirstName');
			check_passedTest('tbLastName');
			check_passedTest('rbSex');
			check_passedTest('tbEmailAddress');
			check_passedTest('tbDateOfBirth');
			check_passedTest('cbxEnrollDate');
			check_passedTest('rbEnrollType');
			check_passedTest('tbSchoolName');
			check_passedTest('tbYog');
			check_passedTest('rbCitizen');
			check_passedTest('rbResident');
			check_passedTest('cbxCountry');
			check_passedTest('tbCountry');
			check_passedTest('tbAddressLine1');
			check_passedTest('tbAddressLine2');
			check_passedTest('tbCity');
			check_passedTest('tbPostalCode');
			check_passedTest('cbxState');
			check_passedTest('zip_code');
			check_passedTest('cbxInterest');
			check_passedTest('cbxFirstContact');
			check_passedTest('rbSports');
			check_passedTest('SendButton');
			
			$('rbSports_y').checked = false;
			$('rbSports_n').checked = true;
			check_sportsDisplay_resetvalues();
			
			
		// Hide all
			//if (Element.visible('postCountry_all')) { new Effect.BlindUp('postCountry_all'); }
			if (Element.visible('postCountry_us')) { new Effect.BlindUp('postCountry_us'); }
			if (Element.visible('postCountry_nonUs')) { new Effect.BlindUp('postCountry_nonUs'); }
			if (Element.visible('postCountry_other')) { new Effect.BlindUp('postCountry_other'); }
			
}

function check_sportsDisplay_Other() {
	
	// Hide Sports
		if (Element.visible('postSports') && $('rbSports_y').checked === false) {
			new Effect.BlindUp('postSports');
			check_passedTest('rbSports');
		} else if (!Element.visible('postSports') && $('rbSports_y').checked === true) {
			new Effect.BlindDown('postSports');
		} else {
			// Null
		}
		
}

function check_sportsDisplay_resetvalues() {
	
	// Clear out values
		
		for (i = 0; i < check_sportsDisplay_resetvalues_array.length; i++) {
			
			$(check_sportsDisplay_resetvalues_array[i]).checked = false;
			
		}
	// Hide Sports
		check_sportsDisplay_Other();
	
	
}

function check_postCitizenDisplay() {
	
	// Check US Citizen
	if ($('rbCitizen_n').checked === true) {
		
		if (!Element.visible($('postCitizen_residance'))) {
			
			// Display Resident status
			new Effect.BlindDown('postCitizen_residance');
			$('rbResident_y').checked = false;
			$('rbResident_n').checked = false;
		}
		
	} else {
		
		if (Element.visible($('postCitizen_residance'))) {
			
			// Hide resident status
			new Effect.BlindUp('postCitizen_residance',{afterFinish: function(x) { $('rbResident_y').checked = false;$('rbResident_n').checked = true; } });
		}
		
		// Clear settings
		
		
	}
		
}

/*

	GENERAL FORM FUNCTIONS

*/

function check_countryDisplay() {
	
	var check_countryDisplay_selected = $F('cbxCountry').toLowerCase();
	
	//alert(check_countryDisplay_selected);
	
	
	// Clear out the warrning if visible
	check_passedTest('cbxCountry');
	check_passedTest('tbCountry');
	
	
	// Check if US, 'Other', or Specific country is picked.
		
	if (check_countryDisplay_selected == "united states of america" || check_countryDisplay_selected == "united states" || check_countryDisplay_selected == "us") {
		
		// Turn on all US elements
		
		if (Element.visible('postCountry_all') === false) {
			
			new Effect.BlindDown('postCountry_all');
			
		}
		
		if (Element.visible('postCountry_us') === false) {
			
			new Effect.BlindDown('postCountry_us');
			
		}
		
		// Turn off all non-US elements
		
		if (Element.visible('postCountry_nonUs')) {
			
			// Hide Effect
				new Effect.BlindUp('postCountry_nonUs');
			
			// Reset values
				check_countryDisplay_resetvalues('nonUs');
			
		}
		
		if (Element.visible('postCountry_other')) {
			
			// Hide Effect
				new Effect.BlindUp('postCountry_other');
			
			// Resent values
				check_countryDisplay_resetvalues('other');
			
		}
		
	} else if (check_countryDisplay_selected != "") {
		
		
		// Option for 'other' country
		if (check_countryDisplay_selected == "other" && Element.visible('postCountry_other') === false) {
			
			// Show Effect
			new Effect.BlindDown('postCountry_other');
			
		} else if (check_countryDisplay_selected != "other" && Element.visible('postCountry_other')) {
			
			// Hide Effect
				new Effect.BlindUp('postCountry_other');
			
			// Resent values
				check_countryDisplay_resetvalues('other');
				
		}
		// Turn ON all Non-US Elements
		if (Element.visible('postCountry_all') === false) {
			
			new Effect.BlindDown('postCountry_all');
			
		}

		
		if (Element.visible('postCountry_nonUs') === false) {
			
			// Show Effect
			new Effect.BlindDown('postCountry_nonUs');
			
			// Reset values
				check_countryDisplay_resetvalues('nonUs');
			
		}
		
		
		// Turn OFF all US elements
		
		if (Element.visible('postCountry_us')) {
			
			// Hide Effect
				new Effect.BlindUp('postCountry_us');
			
			// Reset Values
				check_countryDisplay_resetvalues('us');
			
		}
		
		
	} else {
		
		var tempVar1 = check_getFormName();
		eval("check_"+tempVar1+"_reset()");
		//check_gradInquiry_reset();
		
	}
			 
}

function check_countryDisplay_resetvalues(type) {
	
	// Resets values for area stated.
	
	if (type == "all") {
		
		// For 'all' div
			$('tbAddressLine1').value = $('tbAddressLine1').defaultValue;
				check_passedTest('tbAddressLine1');
			$('tbCity').value = $('tbCity').defaultValue;
				check_passedTest('tbCity');
		
	} else if (type == "us") {
		
		// For 'us' div
			$('cbxState').selectedIndex = 0;
				check_passedTest('cbxState');
			$('zip_code').value = $('zip_code').defaultValue;
				check_passedTest('zip_code');
			
			if ($('phone_number') != undefined) {
				$('phone_number').value = $('phone_number').defaultValue;
					check_passedTest('phone_number');
			}
			
			if ($('fax_number') != undefined) {
				$('fax_number').value = $('fax_number').defaultValue;
					check_passedTest('fax_number');
			}
			
		
	} else if (type == "nonUs") {
		
		// For 'nonUs' div
			$('tbPostalCode').value = $('tbPostalCode').defaultValue;
				check_passedTest('tbPostalCode');
		
	} else if (type == "other") {
		
		// For 'other' div
			$('tbCountry').value = $('tbCountry').defaultValue;
				check_passedTest('tbCountry');
		
	} else {
		
		alert("type not stated");
		
	}
	
}


function check_failedTest(id,message) {
	
	var message
	
	//alert("Failed: "+id);
	
	if (message == undefined && $(id).title != undefined) {
		message = $(id).title;
	} else if (message == undefined && $('id').title == undefined) {
		message = "Please complete this information.";
	}
	
	// Applies error and applies error message.
	
	$(id+'_warning').innerHTML = message;
	if (Element.visible(id+'_warning') === false) {
		new Effect.BlindDown(id+'_warning');
	} else {
		new Effect.Highlight(id+'_warning', {duration:5.0});
	}
	
}


function check_passedTest(id) {
	
	// Clear error message.
	
	if (Element.visible(id+'_warning')) {
		new Effect.BlindUp(id+'_warning', { afterFinish: function (x) {$(id+'_warning').innerHTML = "";} });
	}
	
}


function check_getFormName() {
	if ($('formName') != undefined) {
		return $F('formName');
		alert("Formname declaired: "+$F('formName'));
	} else {
		alert("Formname Missed!");
		return "";
	}
}

function checkDate(name) {
	//var x = document.forms[0].elements;
	//var day = parseInt(x[name+"_day"].options[x[name+"_day"].selectedIndex].value);
	//var month = parseInt(x[name+"_month"].options[x[name+"_month"].selectedIndex].value);
	//var year = parseInt(x[name+"_year"].options[x[name+"_year"].selectedIndex].value);
	var day = parseInt($(name+"_day").options[$(name+"_day").selectedIndex].value);
	var month = parseInt($(name+"_month").options[$(name+"_month").selectedIndex].value);
	var year = parseInt($(name+"_year").options[$(name+"_year").selectedIndex].value);
	
	if (!day || !month || !year)
		return false;
	
	if (year/4 == parseInt(year/4))
		monthLength[1] = 29;
	
	if (day > monthLength[month-1])
		return false;
	
	monthLength[1] = 28;
	
	var now = new Date();
	now = now.getTime(); //NN3
	
	var dateToCheck = new Date();
	dateToCheck.setYear(year);
	dateToCheck.setMonth(month-1);
	dateToCheck.setDate(day);
	var checkDate = dateToCheck.getTime();
	
	var futureDate = (now < checkDate);
	var pastDate = (now > checkDate);
	
	return true;
}


/*
	Undergrad Open House
*/

function check_ug_openhouse() {
	
	var check_ug_openhouse_alert = false;
	var check_ug_openhouse_countryType = '';
	
	// Checks all elements for required and proper formating.
	
		// First name (exists)
		
			if ($F('tbFirstName') == "") {
				check_failedTest('tbFirstName');
				check_ug_openhouse_alert = true;
			} else {
				check_passedTest('tbFirstName');
			}
		
		// Last name (exists)
		
			if ($F('tbLastName') == "") {
				check_failedTest('tbLastName');
				check_ug_openhouse_alert = true;
			} else {
				check_passedTest('tbLastName');
			}
		
		// Gender (selected)
		
			if ($('rbSex_m').checked === false && $('rbSex_f').checked === false) {
				check_failedTest('rbSex','Please select your gender.');
				check_ug_openhouse_alert = true;
			} else {
				check_passedTest('rbSex');
			}
		
		// E-mail (exists && formated)
		
			
		
			// First check if something is filled in:
			if ($F('tbEmailAddress').length < 5) {
				check_failedTest('tbEmailAddress','Please insert your e-mail address.');
				check_ug_openhouse_alert = true;
			} else if (check_emailChecker.test($F('tbEmailAddress')) === false) {
				check_failedTest('tbEmailAddress','Please enter a valid e-mail address.');
				check_ug_openhouse_alert = true;
			} else {
				check_passedTest('tbEmailAddress');
			}
				
		
		// Country (selected)
		
			if ($('cbxCountry').selectedIndex < 1) {
				check_failedTest('cbxCountry','Please select a country and complete all required information');
				check_ug_openhouse_alert = true;
			} else if ($F('cbxCountry').toLowerCase() == "other" && $F('tbCountry') == "") {
				check_passedTest('cbxCountry');
				check_failedTest('tbCountry','Please include the name of your country in the text box above.');
				check_ug_openhouse_countryType = 'nonUs';
				check_ug_openhouse_alert = true;
			} else {
				check_passedTest('cbxCountry');
				check_passedTest('tbCountry');
				
				if ($F('cbxCountry').toLowerCase() == "united states of america" || $F('cbxCountry').toLowerCase() == "united states" || $F('cbxCountry').toLowerCase() == "us" ) {
					check_ug_openhouse_countryType = 'us';
				} else {
					check_ug_openhouse_countryType = 'nonUs';
				}
			}
		
		// General Information (dependent on country select
		if (check_ug_openhouse_countryType != "") {
			
			// Address (exists)
			
				if ($F('tbAddressLine1') == "") {
					check_failedTest('tbAddressLine1');
					check_ug_openhouse_alert = true;
				} else {
					check_passedTest('tbAddressLine1');
				}
			
			// City (exists)
			
				if ($F('tbCity') == "") {
					check_failedTest('tbCity');
					check_ug_openhouse_alert = true;
				} else {
					check_passedTest('tbCity');
				}
				
		}
		
		// Non-US Information:
			
			if (check_ug_openhouse_countryType == 'nonUs') {
				
				// Postal Code (exists if NOT US)
					if ($F('tbPostalCode') == "") {
						check_failedTest('tbPostalCode');
						check_ug_openhouse_alert = true;
					} else {
						check_passedTest('tbPostalCode');
					}
				
		
		// US Only Information:
			
			} else if (check_ug_openhouse_countryType == 'us') {
				
				// State (exists only if US)
					if ($('cbxState').selectedIndex < 1) {
						check_failedTest('cbxState','Please select your state.');
						check_ug_openhouse_alert = true;
					} else {
						check_passedTest('cbxState');
					}
				
				// Zip (formated && exists only if US)
				
				
				
					if (!check_zipcode.test($F('zip_code'))) {
						check_failedTest('zip_code','Please enter your 5 digit (or ZIP+4) zip code.');
						check_ug_openhouse_alert = true;
					} else {
						check_passedTest('zip_code');
					}
				
				
				// Phone (formated only)
					if (!regex_phone_us.test($F('phone_number')) && $F('phone_number').length > 0 ) {
						check_failedTest('phone_number','Please enter your phone number with area code.');
						check_ug_openhouse_alert = true;
					} else {
						check_passedTest('phone_number');
					}
								
			}
		
		// Session question
			if ($F('cbxSession') != "O" && $F('cbxSession') != "N" ) {
				check_failedTest('cbxSession','Please select an open house date to attend.');
				check_ug_openhouse_alert = true;
			} else {
				check_passedTest('cbxSession');
			}
		
		// Interest Question
			if ($('cbxInterest').selectedIndex < 1) {
				check_failedTest('cbxInterest','Please select an Interest.');
				check_ug_openhouse_alert = true;
			} else {
				check_passedTest('cbxInterest');
			}
		
		// Other Interests / Information
			if ($F('cbxEnrollDate') == "none") {
				check_failedTest('cbxEnrollDate','Please select the date you intend to enroll at Emerson.');
				check_ug_openhouse_alert = true;
			} else {
				check_passedTest('cbxEnrollDate');
			}
			
			if ($F('rbApplicationType') == "none") {
				check_failedTest('rbApplicationType','Please select your application type.<br />Transfer is defined as currently or have been enrolled in a college/university.<br />International is for all applicants outside of the United States.');
				check_ug_openhouse_alert = true;
			} else {
				check_passedTest('rbApplicationType');
			}
		
	// Submit if all is well
		
		if (check_ug_openhouse_alert === false) {
			$($F('formName')+'Form').submit();
			check_passedTest('SendButton');
		} else {
			check_failedTest('SendButton','There is a problem with your submission. Please review the form above and correct any errors.');
		}
}



function check_ug_openhouse_reset() {
		// Reset all
			check_countryDisplay_resetvalues('all');
			check_countryDisplay_resetvalues('us');
			check_countryDisplay_resetvalues('nonUs');
			check_countryDisplay_resetvalues('other');
			
			check_passedTest('tbFirstName');
			check_passedTest('tbLastName');
			check_passedTest('tbEmailAddress');
			check_passedTest('cbxCountry');
			check_passedTest('tbCountry');
			check_passedTest('tbAddressLine1');
			check_passedTest('tbCity');
			check_passedTest('tbPostalCode');
			check_passedTest('cbxState');
			check_passedTest('zip_code');
			check_passedTest('cbxInterest');
			check_passedTest('SendButton');
			
		// Hide all
			//if (Element.visible('postCountry_all')) { new Effect.BlindUp('postCountry_all'); }
			if (Element.visible('postCountry_us')) { new Effect.BlindUp('postCountry_us'); }
			if (Element.visible('postCountry_nonUs')) { new Effect.BlindUp('postCountry_nonUs'); }
			if (Element.visible('postCountry_other')) { new Effect.BlindUp('postCountry_other'); }
			
}




/*
	Undergrad Junior Sneak Peek
*/

function check_ug_juniorSneakPeek() {
	
	var check_ug_juniorSneakPeek_alert = false;
	var check_ug_juniorSneakPeek_countryType = '';
	
	// Checks all elements for required and proper formating.
	
		// First name (exists)
		
			if ($F('tbFirstName') == "") {
				check_failedTest('tbFirstName');
				check_ug_juniorSneakPeek_alert = true;
			} else {
				check_passedTest('tbFirstName');
			}
		
		// Last name (exists)
		
			if ($F('tbLastName') == "") {
				check_failedTest('tbLastName');
				check_ug_juniorSneakPeek_alert = true;
			} else {
				check_passedTest('tbLastName');
			}
		
		// Gender (selected)
		
			//if ($('rbSex_m').checked === false && $('rbSex_f').checked === false) {
			//	check_failedTest('rbSex','Please select your gender.');
			//	check_ug_juniorSneakPeek_alert = true;
			//} else {
			//	check_passedTest('rbSex');
			//}
		
		// E-mail (exists && formated)
		
			
		
			// First check if something is filled in:
			if ($F('tbEmailAddress').length < 5) {
				check_failedTest('tbEmailAddress','Please insert your e-mail address.');
				check_ug_juniorSneakPeek_alert = true;
			} else if (check_emailChecker.test($F('tbEmailAddress')) === false) {
				check_failedTest('tbEmailAddress','Please enter a valid e-mail address.');
				check_ug_juniorSneakPeek_alert = true;
			} else {
				check_passedTest('tbEmailAddress');
			}
				
		
		// Country (selected)
		
			if ($('cbxCountry').selectedIndex < 1) {
				check_failedTest('cbxCountry','Please select a country and complete all required information');
				check_ug_juniorSneakPeek_alert = true;
			} else if ($F('cbxCountry') == "OTHER" && $F('tbCountry') == "") {
				check_passedTest('cbxCountry');
				check_failedTest('tbCountry','Please include the name of your country in the text box above.');
				check_ug_juniorSneakPeek_countryType = 'nonUs';
				check_ug_juniorSneakPeek_alert = true;
			} else {
				check_passedTest('cbxCountry');
				check_passedTest('tbCountry');
				
				if ($F('cbxCountry').toLowerCase() == "united states of america" || $F('cbxCountry').toLowerCase() == "united states" || $F('cbxCountry').toLowerCase() == "us" ) {
					check_ug_juniorSneakPeek_countryType = 'us';
				} else {
					check_ug_juniorSneakPeek_countryType = 'nonUs';
				}
			}
		
		// General Information (dependent on country select
		if (check_ug_juniorSneakPeek_countryType != "") {
			
			// Address (exists)
			
				if ($F('tbAddressLine1') == "") {
					check_failedTest('tbAddressLine1');
					check_ug_juniorSneakPeek_alert = true;
				} else {
					check_passedTest('tbAddressLine1');
				}
			
			// City (exists)
			
				if ($F('tbCity') == "") {
					check_failedTest('tbCity');
					check_ug_juniorSneakPeek_alert = true;
				} else {
					check_passedTest('tbCity');
				}
				
		}
		
		// Non-US Information:
			
			if (check_ug_juniorSneakPeek_countryType == 'nonUs') {
				
				// Postal Code (exists if NOT US)
					if ($F('tbPostalCode') == "") {
						check_failedTest('tbPostalCode');
						check_ug_juniorSneakPeek_alert = true;
					} else {
						check_passedTest('tbPostalCode');
					}
				
		
		// US Only Information:
			
			} else if (check_ug_juniorSneakPeek_countryType == 'us') {
				
				// State (exists only if US)
					if ($('cbxState').selectedIndex < 1) {
						check_failedTest('cbxState','Please select your state.');
						check_ug_juniorSneakPeek_alert = true;
					} else {
						check_passedTest('cbxState');
					}
				
				// Zip (formated && exists only if US)
				
				
				
					if (!check_zipcode.test($F('zip_code'))) {
						check_failedTest('zip_code','Please enter your 5 digit (or ZIP+4) zip code.');
						check_ug_juniorSneakPeek_alert = true;
					} else {
						check_passedTest('zip_code');
					}
				
				
				// Phone (formated only)
					if (!regex_phone_us.test($F('phone_number')) && $F('phone_number').length > 0 ) {
						check_failedTest('phone_number','Please enter your phone number with area code.');
						check_ug_juniorSneakPeek_alert = true;
					} else {
						check_passedTest('phone_number');
					}
								
			}
		
		// Session question
			//if ($F('cbxSession') != "O" && $F('cbxSession') != "N" ) {
			//	check_failedTest('cbxSession','Please select an open house date to attend.');
		//		check_ug_juniorSneakPeek_alert = true;
		//	} else {
		//		check_passedTest('cbxSession');
		//	}
		
		// Interest Question
			if ($('cbxInterest').selectedIndex < 1) {
				check_failedTest('cbxInterest','Please select an Interest.');
				check_ug_juniorSneakPeek_alert = true;
			} else {
				check_passedTest('cbxInterest');
			}
		
		// Other Interests / Information
			if ($F('cbxEnrollDate') == "none") {
				check_failedTest('cbxEnrollDate','Please select the date you intend to enroll at Emerson.');
				check_ug_juniorSneakPeek_alert = true;
			} else {
				check_passedTest('cbxEnrollDate');
			}
			
		//	if ($F('rbApplicationType') == "none") {
		//		check_failedTest('rbApplicationType','Please select your application type.<br />Transfer is defined as currently or have been enrolled in a college/university.<br />International is for all applicants outside of the United States.');
		//		check_ug_juniorSneakPeek_alert = true;
		//	} else {
		//		check_passedTest('rbApplicationType');
		//	}
		
	// Submit if all is well
		
		if (check_ug_juniorSneakPeek_alert === false) {
			$($F('formName')+'Form').submit();
			check_passedTest('SendButton');
		} else {
			check_failedTest('SendButton','There is a problem with your submission. Please review the form above and correct any errors.');
		}
}


/*
	Next Step Scholarship Form
*/

function check_nextstep() {
	
	var check_nextstep_alert = false;
	
	// Checks all elements for required and proper formating.
	
		// First name (exists)
		
			if ($F('tbFirstName') == "") {
				check_failedTest('tbFirstName');
				check_nextstep_alert = true;
			} else {
				check_passedTest('tbFirstName');
			}
		
		// Last name (exists)
		
			if ($F('tbLastName') == "") {
				check_failedTest('tbLastName');
				check_nextstep_alert = true;
			} else {
				check_passedTest('tbLastName');
			}
		
		
		// E-mail (exists && formated)
		
			// First check if something is filled in:
			if ($F('tbEmailAddress') == "") {
				check_failedTest('tbEmailAddress','Please insert your e-mail address.');
				check_nextstep_alert = true;
			} else if (check_emailChecker.test($F('tbEmailAddress')) === false) {
				check_failedTest('tbEmailAddress','Please enter a valid e-mail address.');
				check_nextstep_alert = true;
			} else {
				check_passedTest('tbEmailAddress');
			}
				
				
		// College Check
		
		if ($F('enrolled_college') == "") {
			check_failedTest('enrolled_college','Please select your college.');
			check_nextstep_alert = true;
		} else {
			check_passedTest('enrolled_college');
		}
		
		// Essay
		
		if ($F('essay') == "") {
			check_failedTest('essay','Please paste your essay in the text box above.');
			check_nextstep_alert = true;
		} else {
			check_passedTest('essay');
		}
			
		
	// Submit if all is well
		
		if (check_nextstep_alert === false) {
			$('nextstepForm').submit();
			check_passedTest('SendButton');
		} else {
			check_failedTest('SendButton','There is a problem with your submission. Please review the form above and correct any errors.');
		}
}

function check_nextstep_reset() {
		
		// Reset all
			
			check_passedTest('tbFirstName');
			check_passedTest('tbLastName');
			check_passedTest('tbEmailAddress');
			check_passedTest('essay');
			check_passedTest('SendButton');
			
}
