// Validation by Henrik Petersen / NetKontoret Explained at www.echoecho.com/jsforms.htm
/*Functions: do not change
function emailvalidation(entered, alertbox){
with (entered){
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}

function valuevalidation(entered, min, max, alertbox, datatype){
with (entered){
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function digitvalidation(entered, min, max, alertbox, datatype){
with (entered){
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i")
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function emptyvalidation(entered, alertbox){
with (entered){
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

// Ajax Loader - Modified by Travis Repetto - 2006 - Insert this code at the bottom of the page to have it execute on page load: window.onload=function(){ AjaxMailSend('examplepage.html','ExampleHtmlTagId') }
function AjaxMailSend(url,containerid){
	try { // Browser object detection
		xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
		new ActiveXObject("Microsoft.XMLHTTP");
	}
	catch (e){} // browser doesn't support ajax. handle however you want
	xmlhttp.onreadystatechange = function(){statuschanged(containerid)}; // every time ready status changes, statuschanged() function executes
	xmlhttp.open("GET", url, true); // Usage: open(HTTP method, url, and asynchronous = true or false)
	xmlhttp.send(null); // send the request.
}
function statuschanged(containerid){
	if ((xmlhttp.readyState == 4) && (xmlhttp.status == 200)){ // readyState codes: 0=Uninitialised 1=Loading 2=Loaded 3=Interactive 4=Completed; status code: 200=OK
		document.getElementById(containerid).innerHTML = xmlhttp.responseText; // xmlhttp.responseText object contains the text of 'url'
	}else{ // else, readyState is not yet Completed and status is not yet OK, so here we display loading text
		//document.getElementById(containerid).innerHTML = "Sending...";
	}
}
*/
//End Functions
function emailvalidation(entered, alertbox){
with (entered){
apos=value.indexOf("@");
dotpos=value.lastIndexOf(".");
lastpos=value.length-1;
if (apos<1 || dotpos-apos<2 || lastpos-dotpos>3 || lastpos-dotpos<2)
{if (alertbox) {alert(alertbox);} return false;}
else {return true;}
}
}


function valuevalidation(entered, min, max, alertbox, datatype){
with (entered){
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i") {checkvalue=parseInt(value)};
}
if ((parseFloat(min)==min && checkvalue<min) || (parseFloat(max)==max && checkvalue>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}


function digitvalidation(entered, min, max, alertbox, datatype){
with (entered){
checkvalue=parseFloat(value);
if (datatype)
{smalldatatype=datatype.toLowerCase();
if (smalldatatype.charAt(0)=="i")
{checkvalue=parseInt(value); if (value.indexOf(".")!=-1) {checkvalue=checkvalue+1}};
}
if ((parseFloat(min)==min && value.length<min) || (parseFloat(max)==max && value.length>max) || value!=checkvalue)
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}

function emptyvalidation(entered, alertbox){
with (entered){
if (value==null || value=="")
{if (alertbox!="") {alert(alertbox);} return false;}
else {return true;}
}
}
//Customize Here
//Apply Form

function formvalidation(thisform) {
	with (thisform){
		var strErrorMessage = "Please fill out all required fields";
		if (emptyvalidation(name, strErrorMessage) == false) { name.focus(); return false;};
		if (emptyvalidation(address, strErrorMessage) == false) { address.focus(); return false;};
		if (emptyvalidation(city, strErrorMessage) == false) { city.focus(); return false;};
		if (emptyvalidation(state, strErrorMessage) == false) { state.focus(); return false;};
		if (emailvalidation(email, "Please fill out a correct Email address") == false) { email.focus(); return false;};
		if (emptyvalidation(zip, strErrorMessage) == false) { zip.focus(); return false;};
		if (emptyvalidation(contactby, strErrorMessage) == false) { contactby.focus(); return false;};
		if (emptyvalidation(college, strErrorMessage) == false) { college.focus(); return false;};
		if (emptyvalidation(city, strErrorMessage) == false) { city.focus(); return false;};
		alert("Contact Information sent. Thank you!");
	}
}
																																		 

function formvalidationApplication(thisform){
	with (thisform){
		var strErrorMessage = "Please fill out all required fields";
		if (emptyvalidation(fname, strErrorMessage) == false) { fname.focus(); return false;};
		if (emptyvalidation(lname, strErrorMessage) == false) { lname.focus(); return false;};
		if (emptyvalidation(address, strErrorMessage) == false) { address.focus(); return false;};
		if (emptyvalidation(city, strErrorMessage) == false) { city.focus(); return false;};
		if (emailvalidation(email, "Please fill out a correct Email address") == false) { email.focus(); return false;};
		if (emptyvalidation(state, strErrorMessage) == false) { state.focus(); return false;};
		if (emptyvalidation(phone, strErrorMessage) == false) { phone.focus(); return false;};
		if (emptyvalidation(zip, strErrorMessage) == false) { zip.focus(); return false;};
		if (emptyvalidation(gender, strErrorMessage) == false) { gender.focus(); return false;};
		if (emptyvalidation(ssn, strErrorMessage) == false) { ssn.focus(); return false;};
		if (emptyvalidation(dob, strErrorMessage) == false) { dob.focus(); return false;};
		if (emptyvalidation(college, strErrorMessage) == false) { college.focus(); return false;};
		if (emptyvalidation(major, strErrorMessage) == false) { major.focus(); return false;};
		//if (emptyvalidation(programlength, strErrorMessage) == false) { programlength.focus(); return false;};
		if (emptyvalidation(yearinschool, strErrorMessage) == false) { yearinschool.focus(); return false;}; 
		//if (emptyvalidation(graduatewing, strErrorMessage) == false) { graduatewing.focus(); return false(); }
		if (emptyvalidation(occupancy, strErrorMessage) == false) { occupancy.focus(); return false;};
		if (emptyvalidation(mealplan, strErrorMessage) == false) { mealplan.focus(); return false;};
		if (emptyvalidation(paymentplan, strErrorMessage) == false) { paymentplan.focus(); return false;};
		//if (emptyvalidation(moveindate, strErrorMessage) == false) { moveindate.focus(); return false;};
		if (emptyvalidation(haveacar, strErrorMessage) == false) { havaacar.focus(); return false;};
		if (emptyvalidation(parentname, strErrorMessage) == false) { parentname.focus(); return false;};
		if (emptyvalidation(parentstate, strErrorMessage) == false) { parentstate.focus(); return false;};
		if (emptyvalidation(parentaddress, strErrorMessage) == false) { parentaddress.focus(); return false;};
		if (emptyvalidation(parentzip, strErrorMessage) == false) { parentzip.focus(); return false;};
		if (emptyvalidation(parentcity, strErrorMessage) == false) { parentcity.focus(); return false;};
		if (emptyvalidation(parentphone, strErrorMessage) == false) { parentphone.focus(); return false;};
		if (emptyvalidation(emergencyname, strErrorMessage) == false) { emergencyname.focus(); return false;};
		if (emptyvalidation(emergencyphone, strErrorMessage) == false) {emergencyphone.focus(); return false;};
		if (emptyvalidation(cardtype, strErrorMessage) == false) { cardtype.focus(); return false;};
		if (emptyvalidation(cardnumber, strErrorMessage) == false) { cardnumber.focus(); return false;};
		if (emptyvalidation(cardexpirationdate, strErrorMessage) == false) { cardexpirationdate.focus(); return false;};
		if (emptyvalidation(cardholdername, strErrorMessage) == false) { cardholdername.focus(); return false;};
		if (emptyvalidation(securitycode, strErrorMessage) == false) { securitycode.focus(); return false;};
		if (emptyvalidation(creditcardstreet, strErrorMessage) == false) { creditcardstreet.focus(); return false;};
		if (emptyvalidation(creditcardzip, strErrorMessage) == false) { creditcardzip.focus(); return false;};
		if (emptyvalidation(cardchargeamount, strErrorMessage) == false) { cardchargeamount.focus(); return false;};
		alert("Thank you, your application has been sent");
		/*
		
		if (emptyvalidation(name,"Please fill out your full name.")==false) {name.focus(); return false;};
		if (emailvalidation(email,"Please enter a valid E-mail address.")==false) {email.focus(); return false;};
		if (emptyvalidation(address,"Please enter your address.")==false) {address.focus(); return false;};
		if (emptyvalidation(city,"Please enter your city.")==false) {city.focus(); return false;};
		if (emptyvalidation(state,"Please enter your state.")==false) {state.focus(); return false;};
		if (emptyvalidation(zip,"Please enter your zip.")==false) {zip.focus(); return false;};
		if (emptyvalidation(college,"Please choose your college.")==false) {college.focus(); return false;};
		if (emptyvalidation(comments,"Please enter your comments.")==false) {comments.focus(); return false;};
		*/
		//Ajax added by Travis Repetto 
		/*
		var myPath = "form2mail.asp"
		myPath = myPath + "?name="+name.value
		myPath = myPath + "&company="+company.value
		myPath = myPath + "&phone="+phone.value
		myPath = myPath + "&email="+email.value
		myPath = myPath + "&contactby="+contactby.value
		myPath = myPath + "&address="+address.value
		myPath = myPath + "&city="+city.value
		myPath = myPath + "&state="+state.value
		myPath = myPath + "&zip="+zip.value
		myPath = myPath + "&college="+college.value
		myPath = myPath + "&comments="+comments.value
		AjaxMailSend(myPath,'formsend'); */
	}
}