
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 ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1){
		    alert("Invalid E-mail ID")
		    return false
		}	
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
 		 return true					
}
 

function validate(){
	
	if(document.form1.name.value==""){
	alert("Please enter 'Name' !");
	  document.form1.name.focus();
	  return false;
	 }
	if(document.form1.company.value==""){
	alert("Please enter 'Company' !");
	  document.form1.company.focus();
	  return false;
	}
	if(document.form1.address.value==""){
	alert("Please enter 'Address' !");
	  document.form1.address.focus();
	  return false;
	}	
	if(document.form1.city.value==""){
	alert("Please enter 'City' !");
	  document.form1.city.focus();
	  return false;
	 }
	if(document.form1.state.value==""){
	alert("Please enter 'State' !");
	  document.form1.state.focus();
	  return false;
	 }
	if(document.form1.country.value==""){
	alert("Please enter 'Country' !");
	  document.form1.country.focus();
	  return false;
	 }
	 if(document.form1.phone.value=="" || !parseInt(document.form1.phone.value) ){
	  alert("Please enter a valid 'Phone' !");
	  document.form1.phone.focus();
	  return false;
	 }	
	 if(document.form1.fax.value=="" || !parseInt(document.form1.fax.value) ){
	  alert("Please enter a valid 'Fax' !");
	  document.form1.fax.focus();
	  return false;
	 }
   if (echeck(document.form1.email.value)==false){
	  document.form1.email.focus();
	  return false;
	 }
	if(document.form1.comments.value==""){
	alert("Please enter 'Comments' !");
	  document.form1.comments.focus();
	  return false;
	 }	 	 
}