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.firstname.value==""){
	alert("Please enter 'Name' !");
	  document.form1.firstname.focus();
	  return false;
	 }
	if(document.form1.lastname.value==""){
	alert("Please enter 'Last Name' !");
	  document.form1.lastname.focus();
	  return false;
	 }	 
	if(document.form1.companyname.value==""){
	alert("Please enter 'Company Name' !");
	  document.form1.companyname.focus();
	  return false;
	}
    if (echeck(document.form1.email.value)==false){
	  document.form1.email.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.zip.value==""){
	alert("Please enter 'Zip' !");
	  document.form1.zip.focus();
	  return false;
	}
	 if(document.form1.phone.value=="" || !parseInt(document.form1.phone.value) ){
	  alert("Please enter a valid 'Telephone' !");
	  document.form1.phone.focus();
	  return false;
	 }	
	if(document.form1.employees.value==""){
	alert("Please enter 'How many employees do you have' !");
	  document.form1.employees.focus();
	  return false;
	}
	if(document.form1.vendingmachines.value==""){
	alert("Please enter 'How many vending machines do you have' !");
	  document.form1.vendingmachines.focus();
	  return false;
	}	
	if(document.form1.coffeebrewing.value==""){
	alert("Please enter 'How many coffee brewing stations do you have' !");
	  document.form1.coffeebrewing.focus();
	  return false;
	}
	
	if(document.form1.comments.value==""){
	alert("Please enter 'Comments' !");
	  document.form1.comments.focus();
	  return false;
	 }	 	 
	   function do_reset() {
          document.from1.reset();
          return true;
     } 
}






















