// JavaScript Document

function chk_frm()
{
	var doc=document.form1
	if(doc.name.value=="")
	{
		alert("Please Enter Name");
		doc.name.focus();
		return false;
	}
	
	if(doc.address.value=="")
	{
		alert("Please Enter Address");
		doc.address.focus();
		return false;
	}
	/*if(doc.country.value=="")
	{
		alert("Please Enter Country Name");
		doc.country.focus();
		return false;
	}*/
	if(doc.telephone.value=="")
	{
		alert("Please Enter Phone Number");
		doc.telephone.focus();
		return false;
	}
	
	if(doc.telephone.value.match(/[A-Za-z`~!#$%^*()_:;"'|<>?]+/))
	{
		alert("Please enter Only numberic values in Phone Number");
		doc.telephone.focus();
		return false;
	}
	if(doc.mobile.value.match(/[A-Za-z`~!#$%^*()_:;"'|<>?]+/))
	{
		alert("Please enter Only numberic values in Mobile Number");
		doc.mobile.focus();
		return false;
	}
	if(echeck(doc.email.value)==false)
	{
		doc.email.value="";
		doc.email.focus();
		return false;
	}
	if(doc.comment.value=="")
	{
		alert("Please Enter Comment");
		doc.comment.focus();
		return false;
	}

	doc.hidCheck.value="Add";
	//alert(doc.hidCheck.value);
	doc.action="feedback.php";
	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;
}


