// JavaScript Document

/*
Used for IE block level hover
*/
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


/*
	Used to get rid of email spamming from crawlers/bots...
*/
function sendMailTo(name, company, domain) {
   locationstring = 'mai' + 'lto:' + name + '@' + company + '.' + domain;
   window.location.replace(locationstring);
}
   
/*
Appends a random number to the url of variuos images located in the images folder

@param	none
@return	string (url)
*/
function loadRandImg() {
	var i = Math.round(5 * Math.random());
	var ref = 'images/randimg' + i;

	document.getElementById('randomimg').setAttribute('src', ref + '.jpg');
}

function showdiv(divID) {
	elm = document.getElementById(divID);
	
	if(elm.style.display == 'none')
		elm.style.display = 'block';
}

function hidediv(divID) {
	elm = document.getElementById(divID);
	
	if(elm.style.display == 'block')
		elm.style.display = 'none';
}

function focField(me, msg) {
	if(me.value == msg){
		me.value = '';
		me.style.color = '#fff';
		me.style.background = '#555599';
	}
}

function bluField(me, msg) {
	var  str = me.className.substring(0,3);
	
	if(me.value == '') {
		me.value = msg;
		if(str == 'req'){
			me.style.color = '#999';
			me.style.background = '#333366';
		}
		else {
			me.style.color = '#666';
			me.style.background = '#fff';
		}
	}
	else {
		if(str == 'req'){
			me.style.background = '#333366';
		}
		else {
			me.style.color = '#333366';
			me.style.background = '#fff';
		}
	}
}

function contactVal(frm){
	/* Since most spam email that comes through the contact us form includes 
	   multiple anchor links/references, a simple solution is to not validate
	   and messages that have anchor tags in them.  Captcha can't be displayed
	   because this host lacks the gd library compile with their version of php
	*/
	if(/^<a|^<A/.test(frm.message.value) == true)
		return false;
		
	if(frm.name.value == '' || frm.name.value == 'name:') {
		alert("Please enter your name!");
		frm.name.focus();
		frm.name.value = '';
		frm.name.style.color = '#fff';
		frm.name.style.background = '#555599';		
		return false;
	}
	
	if(frm.email.value == '' || frm.email.value == 'e-mail address:') {
		alert("Please enter your e-mail address!");
		frm.email.focus();
		frm.email.value = '';
		frm.email.style.color = '#fff';
		frm.email.style.background = '#555599';	
		return false;
	}
	if(frm.message.value == '' || frm.message.value == 'questions/comments:') {
		alert("Please enter a question or comment!");
		frm.message.focus();
		frm.message.value = '';
		frm.message.style.color = '#fff';
		frm.message.style.background = '#555599';	
		return false;
	}
	
	return true;
}

function requestVal(frm) {
	/* Since most spam email that comes through the request form includes 
	   multiple anchor links/references, a simple solution is to not validate
	   and messages that have anchor tags in them.  Captcha can't be displayed
	   because this host lacks the gd library compile with their version of php
	*/
	if(/^<a|^<A/.test(frm.questions.value) == true)
		return false;
		
	if(frm.name.value == '' || frm.name.value == 'name:') {
		alert("Please enter your name!");
		frm.name.focus();
		frm.name.value = '';
		frm.name.style.color = '#fff';
		frm.name.style.background = '#555599';		
		return false;
	}

	if(frm.address.value == '' || frm.address.value == 'address:') {
		alert("Please enter your address!");
		frm.address.focus();
		frm.address.value = '';
		frm.address.style.color = '#fff';
		frm.address.style.background = '#555599';		
		return false;
	}
	
	if(frm.citystatezip.value == '' || frm.citystatezip.value == 'city, state zip:') {
		alert("Please enter your city, state and zip code!");
		frm.citystatezip.focus();
		frm.citystatezip.value = '';
		frm.citystatezip.style.color = '#fff';
		frm.citystatezip.style.background = '#555599';		
		return false;
	}
	
	if(frm.applicantname.value == '' || frm.applicantname.value == 'applicant name(s):') {
		alert("Please enter the applicant(s) name!");
		frm.applicantname.focus();
		frm.applicantname.value = '';
		frm.applicantname.style.color = '#fff';
		frm.applicantname.style.background = '#555599';		
		return false;
	}
	
	if(frm.programgrade.value == '' || frm.programgrade.value == 'program/grade interested in:') {
		alert("Please enter the program/grade you are interested in!");
		frm.programgrade.focus();
		frm.programgrade.value = '';
		frm.programgrade.style.color = '#fff';
		frm.programgrade.style.background = '#555599';		
		return false;
	}
	
	return true;
}

function alumniVal(frm) {
	if(frm.name.value == '' || frm.name.value == 'name:') {
		alert("Please enter your name!");
		frm.name.focus();
		frm.name.value = '';
		frm.name.style.color = '#fff';
		frm.name.style.background = '#555599';		
		return false;
	}

	if(frm.address.value == '' || frm.address.value == 'address:') {
		alert("Please enter your address!");
		frm.address.focus();
		frm.address.value = '';
		frm.address.style.color = '#fff';
		frm.address.style.background = '#555599';		
		return false;
	}
	
	if(frm.citystatezip.value == '' || frm.citystatezip.value == 'city, state zip:') {
		alert("Please enter your city, state and zip code!");
		frm.citystatezip.focus();
		frm.citystatezip.value = '';
		frm.citystatezip.style.color = '#fff';
		frm.citystatezip.style.background = '#555599';		
		return false;
	}
	
	if(frm.email.value == '' || frm.email.value == 'e-mail address:') {
		alert("Please enter your e-mail address!");
		frm.email.focus();
		frm.email.value = '';
		frm.email.style.color = '#fff';
		frm.email.style.background = '#555599';	
		return false;
	}
	
	if(frm.suvclassof.value == '' || frm.suvclassof.value == 'suv class of:') {
		alert("Please enter your suv class!");
		frm.suvclassof.focus();
		frm.suvclassof.value = '';
		frm.suvclassof.style.color = '#fff';
		frm.suvclassof.style.background = '#555599';	
		return false;
	}
	
	return true;
}