// JavaScript Document
function echeck(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 Format")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid E-mail Format")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid E-mail Format")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1)
		 {
		    alert("Invalid E-mail Format")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
		    alert("Invalid E-mail Format")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
		    alert("Invalid E-mail Format")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
		    alert("Invalid E-mail Format")
		    return false
		 }
	}

function FormValidate(theForm)
{
	if (theForm.HOWHEARD.selectedIndex == 0)
	{
		alert("Please select How your heard about us");
		theForm.HOWHEARD.focus();
		return (false);
	}	
	if (theForm.NAME.value == "")
	{
		alert("Please Enter First & Last Name");
		theForm.NAME.focus();
		return (false);
	}	
	if (theForm.NAME.value.length < 2)
	{
		alert("Please Enter First & Last Name");
		theForm.NAME.focus();
		return (false);
	}
	
	if ((theForm.EMAIL.value==null)||(theForm.EMAIL.value==""))
	{
		alert("Please Enter your Email");
		theForm.EMAIL.focus();
		return (false);
	}
	
	if (echeck(theForm.EMAIL.value)==false)
	{
		theForm.EMAIL.focus();
		return (false);
	}
	
	if(theForm.PHONE.value == "") 
	{       
	alert("Please specify phone number");
	theForm.PHONE.focus();       
	return false;   
	}    
	if(!ValidateNo(theForm.PHONE.value,"1234567890+- ")) 
	{       
	alert("Please Enter Only Number");        
	theForm.PHONE.focus();       
	return false;   
	}
	
	if (theForm.ADDRESS.value == "")
	{
		alert("Please enter a value for the \"ADDRESS\" field.");
		theForm.ADDRESS.focus();
		return(false);
	}
	
	if (theForm.ADDRESS.value.length < 5)
	{
		alert("Please enter at least 5 characters in the \"ADDRESS\" field.");
		theForm.ADDRESS.focus();
		return (false);
	}

	if (theForm.CITY.value == "")
	{
		alert("Please enter a value for the \"CITY\" field.");
		theForm.CITY.focus();
		return(false);
	}
	
	if (theForm.ZIP.value == "")
	{
		alert("Please enter a value for the \"ZIP\" field.");
		theForm.ZIP.focus();
		return(false);
	}
	
	
	if (theForm.FEET.value == "")
	{
		alert("Please enter at least 2 digits in the \"FEET\" field.");
		theForm.FEET.focus();
		return (false);
	 }
	 if (theForm.FEET.value.length < 2)
	 {
		alert("Please enter at least 2 digits in the \"FEET\" field.");
		theForm.FEET.focus();
		return (false);
	  }
	
	return (true);
}

