// Form Validation

function validate()
{

		///*validation name field*///

		if (document.queryform.uname.value=="")
		{
		 alert("Please enter your name.")
	     document.queryform.uname.focus();
		  return false;
	   	}
		
	 	if(document.queryform.uname.value!="")
		{
		var alphaExp = /^[a-zA-Z""]+$/; 
		 if(document.queryform.uname.value.search(alphaExp)==-1)
		 {
        	 alert("Invalid character in name field.")
	   		document.queryform.uname.value="";
			document.queryform.uname.focus();

		   return false;
			 }
		 }
		
	   
         /*validation email field*/
		 
		 
 var emailID=document.queryform.email
	
	if ((emailID.value==null)||(emailID.value==""))
	{
		alert("E-mail ID  is blank, please fill it.")
		document.emailID.value="";
		emailID.focus()
		  return false;
	}
	if (echeck(emailID.value)==false)
	{
		emailID.value=""
			alert("Please enter your E-mail ID in right format.")
		emailID.focus()
		  return false;
	}
		
		
		/*validation enquiry field*/
			
	

	/*############## end ##################*/	
	 
	 /*validation phone field*/
	if(document.queryform.phone.value=="")
		{
		 alert("Please enter your telephone number.");
		 	   		document.queryform.phone.value="";
		   document.queryform.phone.focus();
		  return false;

		}
		
		if(document.queryform.phone.value!="")
		{
		var telechk = /^[" "0-9+()-]+$/;
		 if(document.queryform.phone.value.search(telechk)== -1)
		 	{
		 alert("Invalid phone number.");
		document.queryform.phone.value="";
	  	document.queryform.phone.focus();
		return false;

			}
		}
		/*end*/
		
		
		///*validation country field*///

		if (document.queryform.country.selectedIndex == 0)
		{
		 alert("Please select country name.")
	     document.queryform.country.focus();
		  return false;
	   	}
		
		///*validation select product field*///
		
	 	if (document.queryform.sproduct.selectedIndex==-1)
		{
		 alert("Please select any product.")
	     document.queryform.sproduct.focus();
		  return false;
	   	}
		
		///*validation comment field*///
		
		if (document.queryform.comment.value=="")
		{
		 alert("Please enter your comment.")
		  document.queryform.comment.value="";
	     document.queryform.comment.focus();
		  return false;
	   	}
}
		
	   
		
	 
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
        var loc;
        var pos;        
		
		loc=(str.search(/@/));
	    pos=(str.slice(0,loc));
		
        if(!isNaN(pos))
		{
			alert("Invalid Email Id ")
		   return false
		}
	   
		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){
		    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					
	}
	
	
	