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_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
function checkDates()
{
	var x = document.forms[0].elements;
	var day1 = parseInt(x["day1"].options[x["day1"].selectedIndex].value);
	var month1 = parseInt(x["month1"].options[x["month1"].selectedIndex].value);
	var day2 = parseInt(x["day2"].options[x["day2"].selectedIndex].value);
	var month2 = parseInt(x["month2"].options[x["month2"].selectedIndex].value);
	if (day1 > monthLength[month1-1] || day2 > monthLength[month2-1]) {
		alert("Please enter only legitimate dates");
		return false;
	}
	if (! checkEmail()) {return false}
	return true;
}

function checkEmail()
{
  var Em = document.forms["sample_form"].elements["email"].value;
 Em = Em.replace(/(\.\.)/g, ".");      // multiple period to one
 Em = Em.replace(/(\@\@)/g, "\@");    // multiple at-signs to one
 Em = Em.replace(/\\+/g, "");        // change backslash to null
 Em = Em.replace(/[\s]+/g, "");     // mult blanks/tabs/newline/cr/ff to nul
 Em = Em.toLowerCase();
 document.forms["sample_form"].elements["email"].value = Em;
 if (Em.length <= 5) {alert("This email address is too short.  Need full email address, such as joe\@ibm.com"); return false}
 if (Em.search(  /,|\/|\\|(@.*@)|(\.\.)|(\.$)/  ) != -1) {alert("Illegal characters, or characters out of order"); return false} 
 if (Em.search(  /^[\w\-\._]+[\%\+]?[\w\-\._]*\@[0-9a-zA-Z\-]+\.[0-9a-zA-Z\-\.]+$/  ) != -1) {
 	return true;
 } else {
     alert("Address has an error.");
     return false;
 }
}
