//*********************************************************************
// Validation Advertisement Form for the Member Companeis
//*********************************************************************
function AdvertiseValidator(theform)
{   
	
//Company Name
if(theform.company_name.value=="")
		{	
		alert("Please Provide Company Name.");
		theform.company_name.focus();
		return (false);
		}

//Contact Person
		if (theform.contact_person.value=="")
		{
		alert("Please Provide Name of Contact Person.");
		theform.contact_person.focus();
		return false;
		}

//Designation
		if (theform.designation.value=="")
		{
		alert("Please Provide Your Designation In The Company.");
		theform.designation.focus();
		return false;
		}
//Address
		if (theform.address.value=="")
		{
		alert("Please Provide Your Company Address.");
		theform.address.focus();
		return false;
		}

//City
	if (theform.city.value=="")
    {
    alert("Please Provide Name of City In Which Your Company Is.");
	theform.city.focus();
    return false;
    }
	
//ZIP-POSTAL
	if (theform.pin.value=="")
    {
    alert("Please Provide PIN - Postal Code Name.");
	theform.pin.focus();
    return false;
    }

	if (isNaN(theform.pin.value))
    {
	alert("Please Enter Only Numbers in PIN - Postal Code Field.");
	theform.pin.focus();
	return false;
    }	
	
//State
	if (theform.state.value=="")
    {
    alert("Please Provide Name of State In Which Your Company Is.");
	theform.state.focus();
    return false;
    }	
  
// Phone
if (theform.phone.value=="")
	{
		alert("Please Provide Contact Phone No. Prefer Company LandLine Phone No.");
		theform.phone.focus();
		return false;
	}// Phone No Validation-1	

    var checkOK = "0123456789";
	var checkStr = theform.phone.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 For Phone Number.");
	theform.phone.focus();
	return (false);
	}
 		
//Mobile Phone
	if(theform.mobile.value == "") 
	   {
	   alert("Please Provide Your Mobile Number.");
	   theform.mobile.focus();
	   return false;
	   }	   
	//Mobile No Field Only Numbers Validation
	var checkOK = "0123456789";
	var checkStr = theform.mobile.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 For Mobile Number. Field.");
	theform.mobile.focus();
	return (false);
	}
	
//EMAIL ID
	if(theform.email.value == "") 
	   {
	   alert("Please Provide Email ID. Prefer Company Email ID.");
	   theform.email.focus();
	   return false;
	   }
   
	if (theform.email.value != "")
	{
	// Test if Valid Email Address, Must have @ and .
	var checkEmail = "@.";
	var checkStr = theform.email.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.email.focus();
		return (false);
		}

//Web Site URL
	if (theform.website.value=="")
    {
    alert("Please Give Website URL. Type 'NA' If Not Available.");
	theform.website.focus();
    return false;
    }

// Description
	if (theform.description.value=="")
    {
    alert("Please Provide Brief Details About Your Advertisement Interest.");
	theform.description.focus();
    return false;
    }
	
	
//Advertisement Interest
	if (document.advertise_form.chkCompanyListing.checked == false && document.advertise_form.chkCompanyProfile.checked == false && document.advertise_form.chkHomeBanner.checked == false && document.advertise_form.chkCityBanner.checked == false && document.advertise_form.chkCityFooterBanner.checked == false)
	{
	 alert("At Least One Advertisement Option Must Be Selected.");
	 return false;
	}	
}