//**************************************
// Validation of Contact Requests
//**************************************
function ContactValidator(theform)
{

//Contact Purpose	
if(theform.selPurpose.value=="")
		{	
		alert("Please Select Contact Purpose.");
		theform.selPurpose.focus();
		return (false);
		}

//Customer Name
		if (theform.txtName.value=="")
		{
		alert("Please Provide Your Name.");
		theform.txtName.focus();
		return false;
		}

//EMAIL ID VALIDATION
	if(theform.txtEmail.value == "") 
	   {
	   alert("Please Provide Your Email ID.");
	   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 Validate
if (theform.txtPhone.value=="")
	{
		alert("Please Provide Your Phone Number. Home LandLine or Office LandLine Number.");
		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("Only Numbers Should Be There in Phone No. Field.");
	theform.txtPhone.focus();
	return (false);
	} 

// Mobile No. Validate
if (theform.txtMobile.value=="")
	{
		alert("Please Provide Your 10 Digit Mobile Number.");
		theform.txtMobile.focus();
		return false;
	} // Phone No Validation-1

    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("Only Numbers Should Be There in Mobile No. Field.");
	theform.txtPhoneMobile.focus();
	return (false);
	} 
	

//Contact Details
	if (theform.txtDescription.value=="")
    {
    alert("Please Enter Brief Details For Your Contact.");
	theform.txtDescription.focus();
    return false;
    }	
}