// JavaScript Document
var doc=document.frmEnquiry
function chk_frm()
{
	//alert(doc.cat.value);
	if(doc.cat.value=="")
	{
		alert("Please Select Type");
		doc.cat.focus();
		return false;
	}
	if(doc.name.value=="")
	{
		alert("Please Enter Your Name");
		doc.name.focus();
		return false;
	}
	if(doc.company.value=="")
	{
		alert("Please Enter Company Name");
		doc.company.focus();
		return false;
	}
	
	if(doc.address.value=="")
	{
		alert("Please Enter Address");
		doc.address.focus();
		return false;
	}
	if(doc.city.value=="")
	{
		alert("Please Enter City");
		doc.city.focus();
		return false;
	}
	if(doc.zip.value.match(/[A-Za-z`~!#$%^*()_:;"'|<>?]+/))
	{
		alert("Please enter Only numberic values");
		doc.zip.focus();
		doc.zip.value='';
		return false;
	}
	if(doc.country.value=="")
	{
		alert("Please Enter Country");
		doc.country.focus();
		return false;
	}
	if(doc.phone.value=="")
	{
		alert("Please Enter Phone Number");
		doc.phone.value = "";
		doc.phone.focus();
		return false;
	}
	if(doc.phone.value.match(/[A-Za-z`~!#$%^*()_:;"'|<>?]+/))
	{
		alert("Please enter Only numberic values");
		doc.phone.focus();
		doc.phone.value='';
		return false;
	}
	if(doc.fax.value.match(/[A-Za-z`~!#$%^*()_:;"'|<>?]+/))
	{
		alert("Please enter Only numberic values");
		doc.fax.focus();
		doc.fax.value='';
		return false;
	}
	if(doc.email.value=="")
	{
		alert("Please Enter Email");
		doc.email.focus();
		return false;
	}
	if(echeck(doc.email.value)==false)
	{
		doc.email.value="";
		doc.email.focus();
		return false;
	}
	if(doc.inquiry.value=="")
	{
		alert("Please Enter Enquiry");
		doc.inquiry.focus();
		return false;
	}
	doc.hidAdd.value="Add";
	doc.submit();
	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("Please enter valid email id");
	   return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Please enter valid email id");
	   return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Please enter valid email id");
		return false;
	}
	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Please enter valid email id");
		return false;
	 }
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Please enter valid email id");
		return false;
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
		alert("Please enter valid email id");
		return false;
	 }

	 if (str.indexOf(" ")!=-1){
		alert("Please enter valid email id");
		return false;
	 }
	  return true;
}



