// JavaScript Document
function phcheck(pnum)
  {
  var phchar="1234567890 -_+.()";
  for (i=0;i<=pnum.length;i++)
    {	
	if(phchar.indexOf(pnum.charAt(i))==-1)
	  {	  
	  alert("Only Numbers and (+-_. ) are allowed");
	  return false ;
	  }	
	}
  return true ;
  }




function validate()
{	
if(document.form1.name.value=="")
	{	
	alert("Name must be filled out!");
	document.form1.name.focus();
	return false;
	}
	
if(document.form1.phone.value=="")
	{		
	alert("Phone must be filled out!");
	document.form1.phone.focus();
	return false;
	}
	else if (document.form1.phone.value!="")
		{
			if(isNaN(document.form1.phone.value))
			{
			document.form1.phone.value='';
			alert("Enter numbers only");
			document.form1.phone.focus();
			return false;
			}
		}
	
 if(document.form1.email.value=="")
		{
			alert("Email must be filled out!");
			document.form1.email.focus();
			return false;
		}
	if(!echeck(document.form1.email.value))
    {
	document.form1.email.value="";
	document.form1.email.focus();
	return false;
    }	
	if(document.form1.time.value=="")
	{	
	alert("Time must be filled out!");
	document.form1.time.focus();
	return false;
	}
if(document.form1.question.value=="")
	{	
	alert("Quick question must be filled out!");
	document.form1.question.focus();
	return false;
	}
	
	
return true;
}	

 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 email address")
			   return false
			}

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

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

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

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

		 if (str.indexOf(dot,(lat+2))==-1)
			 {
				alert("Invalid email address")
				return false
			 }
		
		 if (str.indexOf(" ")!=-1)
			 {
				alert("Invalid email address")
				return false
			 }
		 return true;
		 }
		 	
