//*****************************************************
// Function for Checking/ Validation of Company Enquiry
// Developer: Avanish Kumar
// Email: Kumar.Avanish@Gmail.com
//*****************************************************
function advt_Validator(theform)
{   

// Name
if(theform.txtName.value=="")
		{	
		alert("Please Enter Your Name.");
		theform.txtName.focus();
		return (false);
		}
//EMAIL ID VALIDATION
	if(theform.txtEmail.value == "") 
	   {
	   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

// Phone Number
if (theform.txtPhone.value=="")
	{
		alert("Please Provide Contact Telephone No.");
		theform.txtPhone.focus();
		return false;
	}// Phone No Validation-1	

    var checkOK = "0123456789";
	var checkStr = theform.txtPhone.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 Numbers In Phone No. Field.");
	theform.txtPhone.focus();
	return (false);
	}//Phone No Validation No-2 Final
 		

//Mobile Phone Validation
	if(theform.txtMobile.value == "") 
	   {
	   alert("Please Provide Mobile No for Quick Contacts.");
	   theform.txtMobile.focus();
	   return false;
	   }	   
	//Mobile No Field Only Numbers Validation
	var checkOK = "0123456789";
	var checkStr = theform.txtMobile.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 Numbers In MOBILE NO. Field.");
	theform.txtMobile.focus();
	return (false);
	}//Mobile No. Validation No-2 Final
	

//Send From
	if (theform.txtSendFrom.value=="")
    {
    alert("Please Provide Shifting Source City.");
	theform.txtSendFrom.focus();
    return false;
    }

//Source To
	if (theform.txtSendTo.value=="")
    {
    alert("Please Provide Shifting Destination City.");
	theform.txtSendTo.focus();
    return false;
    }

//Details
	if (theform.txtDetails.value=="")
    {
    alert("Please Provide Brief Details of Requirements.");
	theform.txtDetails.focus();
    return false;
    }
	
//Shifting Date
	if (theform.txtShiftDate.value=="")
    {
    alert("Please Provide Expected Date Of Shifting.");
	theform.txtShiftDate.focus();
    return false;
    }

}// Function Ended