
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function doform(){

	if (document.infoform.name.value == '' || document.infoform.name.value == null || document.infoform.name.value == 'enter name'){
		alert('Please enter your name and try again.');
		document.infoform.name.focus();

		document.getElementById('name').style.backgroundColor="#ffffff";
		document.getElementById('name').style.border="5px solid #A22B37";
		//document.getElementById('name').style.color="#ffffff;";
		
		document.getElementById('school').style.backgroundColor="#EEF7E6";
		document.getElementById('school').style.border="1px solid #449630";
		//document.getElementById('school').style.color="#448844;";
		document.getElementById('email').style.backgroundColor="#EEF7E6";
		document.getElementById('email').style.border="1px solid #449630";
		//document.getElementById('email').style.color="#448844;";
		document.getElementById('phone').style.backgroundColor="#EEF7E6";
		document.getElementById('phone').style.border="1px solid #449630";
		//document.getElementById('phone').style.color="#448844;";
		
		return false;
	}

	
	if (document.infoform.school.value == '' || document.infoform.school.value == null || document.infoform.school.value == 'enter school'){
		alert('Please enter your school\'s name and try again.');
		document.infoform.school.focus();
		
		document.getElementById('school').style.backgroundColor="#ffffff";
		document.getElementById('school').style.border="5px solid #A22B37";
		//document.getElementById('school').style.color="#ffffff;";
		
		document.getElementById('name').style.backgroundColor="#EEF7E6";
		document.getElementById('name').style.border="1px solid #449630";
		//document.getElementById('name').style.color="#448844;";
		document.getElementById('email').style.backgroundColor="#EEF7E6";
		document.getElementById('email').style.border="1px solid #449630";
		//document.getElementById('email').style.color="#448844;";
		document.getElementById('phone').style.backgroundColor="#EEF7E6";
		document.getElementById('phone').style.border="1px solid #449630";
		//document.getElementById('phone').style.color="#448844;";
		
		return false;
	}

/*
	if (document.infoform.phone.value == ' '|| document.infoform.phone.value == null){
		alert('Please enter your phone number and try again.');
		document.infoform.phone.focus();
		return false;
	}
*/

	if (document.infoform.email.value == '' || document.infoform.email.value == null || document.infoform.email.value == 'enter e-mail'){
		alert('Please enter a valid e-mail address and try again.');
		document.infoform.email.focus();
		
		document.getElementById('email').style.backgroundColor="#ffffff";
		document.getElementById('email').style.border="5px solid #A22B37";
		//document.getElementById('email').style.color="#ffffff;";
		
		document.getElementById('name').style.backgroundColor="#EEF7E6";
		document.getElementById('name').style.border="1px solid #449630";
		//document.getElementById('name').style.color="#448844;";
		document.getElementById('school').style.backgroundColor="#EEF7E6";
		document.getElementById('school').style.border="1px solid #449630";
		//document.getElementById('school').style.color="#448844;";
		document.getElementById('phone').style.backgroundColor="#EEF7E6";
		document.getElementById('phone').style.border="1px solid #449630";
		//document.getElementById('phone').style.color="#448844;";
		
		return false;
	}
	
	with (document.infoform.email){
	apos=value.indexOf("@")
	dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) {
			alert('Please enter a valid e-mail address and try again.');
			document.infoform.email.focus();
			return false;
		}
	}
	
	
	document.infoform.submit();
	//alert('validation passed');
}





// constants to define the title of the alert and button text.
var ALERT_TITLE = "Oops!";
var ALERT_BUTTON_TEXT = "Ok";

// over-ride the alert method only if this a newer browser.
// Older browser will see standard alerts
if(document.getElementById) {
	window.alert = function(txt) {
		createCustomAlert(txt);
	}
}

function createCustomAlert(txt) {
	// shortcut reference to the document object
	d = document;

	// if the modalContainer object already exists in the DOM, bail out.
	if(d.getElementById("modalContainer")) return;

	// create the modalContainer div as a child of the BODY element
	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
	mObj.id = "modalContainer";
	 // make sure its as tall as it needs to be to overlay all the content on the page
	mObj.style.height = document.documentElement.scrollHeight + "px";

	// create the DIV that will be the alert 
	alertObj = mObj.appendChild(d.createElement("div"));
	alertObj.id = "alertBox";
	// MSIE doesnt treat position:fixed correctly, so this compensates for positioning the alert
	if(d.all && !window.opera) alertObj.style.top = document.documentElement.scrollTop + "px";
	// center the alert box
	alertObj.style.left = (d.documentElement.scrollWidth - alertObj.offsetWidth)/2 + "px";

	// create an H1 element as the title bar
	h1 = alertObj.appendChild(d.createElement("h1"));
	h1.appendChild(d.createTextNode(ALERT_TITLE));

	// create a paragraph element to contain the txt argument
	msg = alertObj.appendChild(d.createElement("p"));
	msg.innerHTML = txt;
	
	// create an anchor element to use as the confirmation button.
	btn = alertObj.appendChild(d.createElement("a"));
	btn.id = "closeBtn";
	btn.appendChild(d.createTextNode(ALERT_BUTTON_TEXT));
	btn.href = "#";
	// set up the onclick event to remove the alert when the anchor is clicked
	btn.onclick = function() { removeCustomAlert();return false; }

	
}

// removes the custom alert from the DOM
function removeCustomAlert() {
	document.getElementsByTagName("body")[0].removeChild(document.getElementById("modalContainer"));
}

