// JavaScript Document
function enquiry_page(form1){
if(document.form1.name.value == "" )
	{
		alert("Please enter a value for the \"Your Name\" field.");
    	document.form1.name.focus();
    	return (false);
  	}
if (document.form1.name.value.length < 3)
  {
    alert("Please enter at least 3 characters in the \"Your Name\" field.");
    document.form1.name.focus();
    return (false);
  }
if(document.form1.email.value == "" )
	{
		alert("Please enter a value for the \"E-mail\" field.");
    	document.form1.email.focus();
    	return (false);
  	}
if(!checkmailid(document.form1.email.value))
	{	
	alert("Please enter a valid 'email id'");
	document.form1.email.select();
	document.form1.email.focus(); 
	return(false)
	}
if(document.form1.address.value == "" )
	{
		alert("Please enter a value for the \"Address\" field.");
    	document.form1.address.focus();
    	return (false);
  	}
if(document.form1.phone.value == "" )
	{
		alert("Please enter a value for the \"Phone\" field.");
    	document.form1.phone.focus();
    	return (false);
  	}
if(!checkphone(document.form1.phone.value))
	{
		alert("Please enter valid \"Phone\" No.");
		document.form1.phone.select();
    	document.form1.phone.focus();
    	return (false);
  	}
if(document.form1.ques.value == "" )
	{
		alert("Please enter a value for the \"Question/Comments\" field.");
    	document.form1.ques.focus();
    	return (false);
  	}
}

function checkmailid(mailid)
{
       if (mailid!="" )
         {   
            var b = mailid;
			var c = b.length;				//  to find thelength of the email id
 			var d = b.indexOf("@");         //  to check for the occurance of "@"
 			var e = b.indexOf("@",d+1); 	//  to confirm "@" occurs only once
			var f = b.indexOf(".");			//  to check for the occurance of "."
 			var g = b.lastIndexOf(".");		//  to Check for the last occurance of "." in the string 					
			var h = b.indexOf(".",d+1);		//  to Check for the last occurance of "." in the string after "@"
			var i = b.indexOf(",");			//  To check for the Occurance Of "," in the string
			var j = b.indexOf(" ");       	//  to check for the occurance of tho sace
                                             //**small modification in below line to avoid the successive occurance of the "." using h==g-1

			if(d==-1 || g==c-1 || d==0 || f==0 || h==d+1 ||  h==c-1 || d==c-1 || e!=-1 || h==-1 ||  i!=-1 || j!=-1 || h==g-1)
  				{ 
   					return(false);
   				}
			else
			{
			return(true);
			}
   			}
 }
 
 function checkphone(val,currency){
  if(!val) {
	  return(false);
  }
  
  if(isNaN(val)){
	  return(false);
  }
		else
			{
			return(true);
			}			
}


