// JavaScript Document
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];}}
}

	//===========================================================================
	//a common function used to check the validity of email
	function isEmail(elm){
		if(elm.value.indexOf("@")!="-1" && elm.value.indexOf(".")!="-1"){
			return true;
			}
		else {
			return false;
			}
		}
	//===========================================================================
	//a common function used to check the phone number
	function isPhone(elm){
		if(elm.value.length !=12){
			return false;
			}
		for (var i=0; i < elm.value.length; i++){
			if((i> -1 && i < 3) || (i > 3 && i < 7) || ( i > 7 && i < 12)) {
				if (elm.value.charAt(i) < "0" || elm.value.charAt(i) > "9"){
				return false; 
				}
			}
			else if (elm.value.charAt(i) != "-") {
				return false;
				}
			}
			return true;
		}
//===========================================================================

function checkForm( theForm ) 
{
		//validation for name
		if(document.theForm.name.value==""){
			alert('Please fill in your name');
			document.theForm.name.focus();
			return false;
			}
		//validation for city	
		if(document.theForm.city.value==""){
			alert('Please fill in the City');
			document.theForm.city.focus();
			return false;
			}
    	//validation for phone
		if(isPhone(document.theForm.phone)==false){
			alert('Please fill in the phone number \n in this format ###-###-####');
			document.theForm.phone.focus();
			return false;
			}
    	//text validation for email
		if(isEmail(document.theForm.email)==false) {
			alert('Please enter a valid email address');
			document.theForm.email.focus();
			return false;
		}
		// checks validation on contact
		var contactUser0=document.theForm.rdoContact[0].checked;
		var contactUser1=document.theForm.rdoContact[1].checked;
		if(contactUser0==false && contactUser1==false){
			alert('Please select how you would like to be contacted: \n Mark by Phone or by Email');
			return false;
			}
	return true; // Make sure this is  the last "option"
}