//****************************************************************
// Function for Checking/ Validation of Company Registration Form
// Developer: Avanish Kumar
// Email: Kumar.Avanish@Gmail.com
//****************************************************************
function ENQ_Validator(theform)
{   	
	// Enquiry Type
	if(theform.selType.value=="")
		{	
		alert("Please Select Enquiry Type.");
		theform.selType.focus();
		return (false);
		}//Enquiry Type		

	if(theform.txtName.value=="")
		{	
		alert("Please Provide Your Name.");
		theform.txtName.focus();
		return (false);
		}//Name Validation
	
	if (theform.txtContact.value=="")
		{
		alert("Please Provide Contact Number (Phone or Mobile)");
		theform.txtContact.focus();
		return false;
		}// Contact No Validation-1		

   
    var checkOK = "0123456789";
	var checkStr = theform.txtContact.value;
	var allValid = true;
	for (i = 0;  i < checkStr.length;  i++)
	{
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
	if (ch == checkOK.charAt(j))
	break;
		if (j == checkOK.length)
		{
		allValid = false;
		break;
		}
	}

	if (!allValid)
	{
	alert("PLease Enter Only Numeric Values In Contact Number.");
	theform.txtContact.focus();
	return (false);
	}//Contact No. Validation No-2 Final 		

	
	
	if(theform.txtEmail.value == "") //EMAIL ID VALIDATION
	   {
	   alert("Please Provide Email ID for Better Communication.");
	   theform.txtEmail.focus();
	   return false;
	   }
   
	if (theform.txtEmail.value != "")
	{
	// Test if Valid Email Address, Must have @ and .
	var checkEmail = "@.";
	var checkStr = theform.txtEmail.value;
	var EmailValid = false;
	var EmailAt = false;
	var EmailPeriod = false;
		for (i = 0;  i < checkStr.length;  i++)
		{
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkEmail.length;  j++)
			{
			if (ch == checkEmail.charAt(j) && ch == "@")
			EmailAt = true;
			if (ch == checkEmail.charAt(j) && ch == ".")
			EmailPeriod = true;
			  if (EmailAt && EmailPeriod)
			  break;
			  if (j == checkEmail.length)
			  break;
			}
		// if both the @ and . were in the string
			if (EmailAt && EmailPeriod)
			{
			EmailValid = true
			break;
			}
		}
	}

		if (!EmailValid)
		{
		alert("Please Enter Valid Email ID.");
		theform.txtEmail.focus();
		return (false);
		}// EMAIL VALIDATION FINISED   

   if (theform.txtDetails.value=="") //Network/ Branch List
   {
	alert("Enter Provide Brief Details About Requirements.");
	theform.txtDetails.focus();
	return false;
   }   
}
// Function Ended