<!--
//************************************************************
// Validate form fields - checks for blank fields only
// Written by Rory Lysaght (rory@maclysaght.com)
//************************************************************

function submit_page(f1) {
f1 = document.forms[1];   //forms[0] is search form
isErr = false;
msg1 = "Please fill in ";
msg2 = " \n \n All fields must be filled in.";

// Check Address fields
if(isBlank(f1.strToName)) {alert(msg1 + "Your Friend's Name" + msg2); isErr = true;}
if(isErr == false && isBlank(f1.strToEmail) == true) {alert(msg1 + "Your Friend's Email Address." + msg2); isErr = true;}
if(isErr == false && eCheck(f1.strToEmail.value) == false) {alert("That doesn't seem to be a valid email address - Please check Your Friend's Email Address." + msg2); isErr = true;}
if(isErr == false && isBlank(f1.strFromName) == true) {alert(msg1 + "Your Name." + msg2); isErr = true;}
if(isErr == false && isBlank(f1.strFromEmail) == true) {alert(msg1 + "Your Email Address." + msg2); isErr = true;}
if(isErr == false && eCheck(f1.strFromEmail.value) == false) {alert("That doesn't seem to be a valid email address - Please check Your Own Email Address." + msg2); isErr = true;}
if(isErr == false && isBlank(f1.strMessage) == true) {alert(msg1 + "a short Message for your friend." + 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
 }

// -->
