//*********************************************************************************
// Function for Checking/ Validation of Advertisement Form for the Interested Companeis
// Developer: Avanish Kumar
// Email: Kumar.Avanish@Gmail.com
//*********************************************************************************
function advt_Validator(theform)
{   
        // Customer Name Required.
		if (frmAdvertise.txtCompName.value=="")
		{
		alert("Please Provide Company Name.");
		frmAdvertise.txtCompName.focus();
		return false;
		}
		
		// Company Address Required Field.
		if (frmAdvertise.txtAddress.value=="")
		{
		alert("Please Provide Company Address.");
		frmAdvertise.txtAddress.focus();
		return false;
		}
		
		//City Field Validation
	    if (frmAdvertise.txtCity.value=="")
        {
        alert("Please Provide Your City Name.");
	    frmAdvertise.txtCity.focus();
        return false;
        }
	
        //State Field Validation
	    if (frmAdvertise.txtState.value=="")
        {
        alert("Please Provide State Name.");
	    frmAdvertise.txtState.focus();
        return false;
        }
	
        //ZIP/ POSTAL CODE
	    if (frmAdvertise.txtPostCode.value=="")
        {
        alert("Please Provide ZIP/ Postal Code Name.");
	    frmAdvertise.txtPostCode.focus();
        return false;
        }

	    if (isNaN(frmAdvertise.txtPostCode.value))
        {
	    alert("Please Enter Only Numbers in Zip-Postal Code Field.");
	    frmAdvertise.txtPostCode.focus();
	    return false;
        }  
	
	
        //Country Field Validation
	    if (frmAdvertise.txtCountry.value=="")
        {
        alert("Please Provide Country Name.");
	    frmAdvertise.txtCountry.focus();
        return false;
        }
		
		// Contact Person Name Required Field.
		if (frmAdvertise.txtContactPerson.value=="")
		{
		alert("Please Provide Contact Person Name.");
		frmAdvertise.txtContactPerson.focus();
		return false;
		}
		
		// Contact Phone No Required Field.
		if (frmAdvertise.txtPhone.value=="")
		{
		alert("Please Provide Contact Phone Number.");
		frmAdvertise.txtPhone.focus();
		return false;
		}
		
		// Validate Phone Number
            var checkOK = "0123456789";
	        var checkStr = frmAdvertise.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.");
    	    frmAdvertise.txtPhone.focus();
    	    return (false);
    	    }//Phone No Validation No-2 Final
		
		
		// Mobile No Required Field.
		if (frmAdvertise.txtMobile.value=="")
		{
		alert("Please Provide Mobile Number.");
		frmAdvertise.txtMobile.focus();
		return false;
		}
		
		// Validate Phone Number
            var checkOK = "0123456789";
	        var checkStr = frmAdvertise.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.");
    	    frmAdvertise.txtMobile.focus();
    	    return (false);
    	    }//Mobile Number Validation No-2 Final		
		
		
		// FAX No Required Field.
		if (frmAdvertise.txtFaxNo.value=="")
		{
		alert("Please Provide FAX Number. Type NA If Not Available");
		frmAdvertise.txtFaxNo.focus();
		return false;
		}
				// Validate Phone Number
            var checkOK = "0123456789";
	        var checkStr = frmAdvertise.txtFaxNo.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 FAX No. Field.");
    	    frmAdvertise.txtFaxNo.focus();
    	    return (false);
    	    }//FAX Number Validation No-2 Final		
		
		// EMail ID Required Field.
		if (frmAdvertise.txtEMail.value=="")
		{
		alert("Please Provide Email ID.");
		frmAdvertise.txtEMail.focus();
		return false;
		}
	
	    // Validate EMail ID
        	if (frmAdvertise.txtEMail.value != "")
	        {
	        // Test if Valid Email Address, Must have @ and .
	        var checkEmail = "@.";
        	var checkStr = frmAdvertise.txtEMail.value;     frmAdvertise.txtEMail
	        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;
			        }// Inner IF
		        }// For Loop
	    }// If Loop

		if (!EmailValid)
		{
		alert("Please Enter Valid Email ID.");
		frmAdvertise.txtEMail.focus();
		return (false);
		} // EMAIL VALIDATION FINISED
		
		// Website URL Required Field.
		if (frmAdvertise.txtWebsite.value=="")
		{
		alert("Please Provide WebSite URL. If No Website, Type NA.");
		frmAdvertise.txtWebsite.focus();
		return false;
		}    
	
	//Advertisement Interests - CheckBox(s)
	if (document.frmAdvertise.chkListing.checked == false && document.frmAdvertise.chkBanner.checked == false)
	{
	 alert("Please Select At Least One Advertisement Options.");
	 return false;
	}

    //Services Requirements Details
    if(frmAdvertise.txtDetails.value=="")
	{
	alert("Please Provide Requirements Detail.");
	frmAdvertise.txtDetails.focus();
	return (false);
	}
	
}// Function Ended