<!--
//************************************************************
// Validate form fields - checks for blank fields only
// Written by Rory Lysaght (rory@maclysaght.com)
//************************************************************

function submit_page(f1) {
f1 = document.forms['form_contact']; 
isErr = false;
msg1 = "Please fill in ";
msg2 = " \n \n Fields with a * must be filled in.";

// Check Address fields
if(isBlank(f1._contact_name)) {alert(msg1 + "Your Name" + msg2); isErr = true;}
if(isErr == false && isBlank(f1._contact_email) == true) {alert(msg1 + "Your Email Address." + msg2); isErr = true;}
if(isErr == false && eCheck(f1._contact_email.value) == false) {alert("That doesn't seem to be a valid email address \n \n Please check Your Email Address." + msg2); isErr = true;}
if(isErr == false && isBlank(f1._contact_comments) == true) {alert(msg1 + "a short Message." + msg2); isErr = true;}
if (isErr == false) {
	return true;
  }
else {
	return false;
  }
}

// Check for a blank field
function isBlank(theField) {
    if(theField.value == "")
        return true;
    else
        return false;
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function eCheck(str) {
//alert(str);
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail address");
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    //alert("Invalid E-mail address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    //alert("Invalid E-mail address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    //alert("Invalid E-mail address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail address")
		    return false
		 }

 		 return true					
	}

function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

// -->