/*	
GRAVYTRAIN LIMITED
Form Validator
Version 1.1

Instructions

Include this file like this: <script src="js/validateform.js" type="text/javascript"></script>

In the Form tag add :
onSubmit=" return checkWholeForm(this)">

Normal textbox example:	
why += isEmpty(form.name.value, "Full Name");
	
RadioButton Example:
why += radioChecked(form.homeType, "Property Type");
	
DropDownBox Example:
why += checkDropdown(form.Title.value, "Title");
With Drop down boxes if you the first item in the list is something like 'Select...' please its value is 0 - So for example: value="0". I would also recommend adding values to the other items. 	

CheckBox Example:
why += checkBoxChecked(form.terms, " Terms and Conditions");
Notice that there is no .value after the checkbox name unlike the in the other validators.  
	
*/
function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }


function ageCalculation()
{
	var DOBday = document.getElementById("DOBday").value;
	var DOBmonth = document.getElementById("DOBmonth").value;
	var DOByear = document.getElementById("DOBYear").value;
	
	var d = new Date();
	var curr_date = d.getDate();
	var curr_month = d.getMonth() + 1;
	var curr_year = d.getFullYear();
	
	var age = curr_year - DOByear;
	
	if(curr_month < DOBmonth)
	{
		age = age - 1;
	}
	
	else if(curr_month == DOBmonth)
	{
		if(curr_date < DOBday)
		{
			age = age - 1;
		}	
	}
	
	return age;
}

function checkForm(){
	
	var emails = "motortrade12";
	
	var postcodeStr = document.getElementById("PostCode").value;
	var startsWith = postcodeStr.substring(0,2);
	startsWith = startsWith.toUpperCase();
	var startsWithFirstLetter = postcodeStr.substring(0,1);
	startsWithFirstLetter = startsWithFirstLetter.toUpperCase();	
	var no = postcodeStr.substring(1,2);
	
	// Set Time
	
	var d = new Date();
	var timeHours = parseInt(d.getHours());
	
	// Weekend Filter
	
	var currentDay = d.getDay();
	var curr_date = d.getDate();
	var curr_month = d.getMonth() + 1;
	var curr_year = d.getFullYear();
	
	var notWeekend = true;
	
	if(currentDay == 0 || currentDay == 6)
		{
			notWeekend = false;
		}
	
var age = ageCalculation(age);	
	//age 25 - 75
	var twentyFiveOrOver = false;
		var DOBday = document.getElementById("DOBday").value;
		var DOBmonth = document.getElementById("DOBmonth").value;
		var DOByear = document.getElementById("DOBYear").value;
		
		var yrDiff = curr_year - DOByear;
	
	var ageMin26 = false;
	var ageMin30 = false;
	
	// Min age 26
	if(age >=26)
	{
		ageMin26 = true;
	}
	
	// Min age 30
	if(age >=30)
	{
		ageMin30 = true;
	}
	
	// Age 30 - 65
	var Between30And65 = false;
	
		if ((yrDiff > 30) && (yrDiff < 65)){
			Between30And65 = true;	
		}
		else if (yrDiff == 30){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				Between30And65 = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	Between30And65 = true	
				}		
			}			
		}
		else if (yrDiff == 65){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				Between30And65 = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	Between30And65 = true	
				}		
			}			
		}
		
		
	// Minimum age 25
		if ((yrDiff > 25) && (yrDiff < 75)){
			twentyFiveOrOver = true;	
		}
		else if (yrDiff == 25){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentyFiveOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentyFiveOrOver = true	
				}		
			}			
		}
		else if (yrDiff == 75){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentyFiveOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentyFiveOrOver = true	
				}		
			}			
		}
		
		// Minimum age 23
		var twentyThreeOrOver = false;
		
		if ((yrDiff > 23) && (yrDiff < 75)){
			twentyThreeOrOver = true;	
		}
		else if (yrDiff == 23){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentyThreeOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentyThreeOrOver = true	
				}		
			}			
		}
		else if (yrDiff == 75){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentyThreeOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentyThreeOrOver = true	
				}		
			}			
		}
		
	// Minimum age 21
	var twentyOneOrOver = false;
	
		if ((yrDiff > 21) && (yrDiff < 75)){
			twentyOneOrOver = true;	
		}
		else if (yrDiff == 21){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentyOneOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentyOneOrOver = true	
				}		
			}			
		}
		else if (yrDiff == 75){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentyOneOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentyOneOrOver = true	
				}		
			}			
		}
		
		//licence Held Since - min 1 year
	var licHeldSince1 = false;
	var licHeldSince2 = false;
	
	var licHeldFor = document.getElementById("licence_Held_For").value
	
	if (licHeldFor != "Under 1 Year")
		{
			licHeldSince1 = true;	
		}
		
	//licence Held Since - min 2 years
	
	if (licHeldFor != "Under 1 Year" && licHeldFor != "1 Year") 
		{
			licHeldSince2 = true;	
		}
		
		
		//Residence 1+ Years
		
		var residence1Year = true;
		var residence3Years = true;
		var residence5Years	= true;
		var livedFor = document.getElementById("Residence").value;
		
		if (livedFor == "Less Than A Year")
		{
			residence1Year = false;	
		}
		
		if (livedFor == "Less Than A Year" || livedFor == "1 Year" || livedFor == "2 Years")
		{
			residence3Years = false;	
		}
		
		if (livedFor == "Less Than A Year" || livedFor == "1 Year" || livedFor == "2 Years" || livedFor == "3 Years" || livedFor == "4 Years")
		{
			residence5Years = false;	
		}
		
		
		//Road Risk Only
		
		var roadRiskOnly = false;
		var selectedCover = document.getElementById("CoverRequired").value ;
		
		if (selectedCover == "Road Risk Only")
			{
				roadRiskOnly = true;	
			}
			
			
		// No Drivers Under 25
		
		var noDriversUnder25 = false;
		
		if (document.getElementById("Drivers_Under25").value == "None")
			{
				noDriversUnder25 = true;	
			}
			
		
		// NCB Filters
		var ncbMotorTrade = document.getElementById("MTrade_NCB").value;
		var ncbPrivateCar = document.getElementById("Car_NCB").value;
		
		var ncbMin1year = true;
		
		if (ncbMotorTrade == "None")
			{
				ncbMin1year = false;
			}
		
		var ncbMin2years = true;
		
		if (ncbMotorTrade == "None" || ncbMotorTrade == "1 Year")
			{
				ncbMin2years = false;
			}
			
			
		// Number Of Driver Filters
		
		var NumberOfDrivers = parseInt(document.getElementById("Number_Of_Drivers").value);
		
		var Max7Drivers = true;
		var Max5Drivers = true;
		var Max4Drivers = true;
		var Max3Drivers = true;
		var Max2Drivers = true;
		
		if (NumberOfDrivers > 7)
			{
				Max7Drivers = false;	
			}
		
		if (NumberOfDrivers > 5)
			{
				Max5Drivers = false;	
			}
			
		if (NumberOfDrivers > 4)
			{
				Max4Drivers = false;	
			}
			
		if(NumberOfDrivers > 3)
			{
				Max3Drivers = false;
			}
		
		if(NumberOfDrivers > 2)
			{
				Max2Drivers = false;
			}
			
	

		// Do not want to receive London Postcode
		var NolondonPostcode = true;
		
		if(startsWithFirstLetter == "E" || startsWithFirstLetter == "N" || startsWithFirstLetter == "W")
			{
				if((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
					{
						NolondonPostcode = false;	
					}
			}			
		
		if(startsWith == "SE" || startsWith == "WC" || startsWith == "EC" || startsWith == "NW" || startsWith == "SW")
			{
				NolondonPostcode = false;	
			}



//Start of Partner Filters

		// Staveley Head Filters
		
		if (roadRiskOnly && residence3Years && licHeldSince1 && noDriversUnder25 && twentyFiveOrOver && Max4Drivers)
			{
				emails += ",motortrade15";	
			}
		
/*
		// Quote Me Today
		
		if ( (twentyFiveOrOver) && (roadRiskOnly == false) && (noDriversUnder25) && (startsWith != "BT") )
			{
				emails += ",motortrade20";	

			}
*/
		
/*			
		// Quoteline Filters
		
		quotelinePostcodes = true;
		
		if(startsWith == "BD" || startsWith == "BL" || startsWith == "SW" || startsWith == "UB")
			{
				quotelinePostcodes = false;
			}
			
		if(startsWithFirstLetter == "B" ||startsWithFirstLetter == "E" || startsWithFirstLetter == "L" || startsWithFirstLetter == "N" || startsWithFirstLetter == "W")
			{
				if((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
					{
						quotelinePostcodes = false;	
					}
			}
		   		
		if (roadRiskOnly && quotelinePostcodes && noDriversUnder25 && licHeldSince1)
			{
				emails += ",motortrade3";	
			}
	*/
			
			
		
		// RSA (Road Runner)
		
		rsaPostcodes = false;
		
		if(startsWith == "WR" || startsWith == "CB" || startsWith == "EH" || startsWith == "DD" || startsWith == "AB" || startsWith == "TD" || startsWith == "IM" || startsWith == "LD" || startsWith == "PH" || startsWith == "SE" || startsWith == "CR" || startsWith == "BA" || startsWith == "ML" || startsWith == "KT" || startsWith == "SG" || startsWith == "SM" || startsWith == "CW" || startsWith == "IV" || startsWith == "SW" || startsWith == "TS" || startsWith == "CA" || startsWith == "CM" || startsWith == "NW" || startsWith == "FK" || startsWith == "DY" || startsWith == "KA" || startsWith == "WD" || startsWith == "NN" || startsWith == "SO" || startsWith == "BN" || startsWith == "DT" || startsWith == "DH" || startsWith == "RH" || startsWith == "YO" || startsWith == "GU" || startsWith == "SS" || startsWith == "TN" || startsWith == "CT" || startsWith == "PL" || startsWith == "SN" || startsWith == "TW" || startsWith == "CO" || startsWith == "HR" || startsWith == "LN" || startsWith == "TR" || startsWith == "BS" || startsWith == "MK" || startsWith == "UB" || startsWith == "WS" || startsWith == "PE" || startsWith == "NR" || startsWith == "GL" || startsWith == "HG" || startsWith == "SY" || startsWith == "ST" || startsWith == "KY" || startsWith == "PO" || startsWith == "ME" || startsWith == "EX" || startsWith == "SL" || startsWith == "BR" || startsWith == "IP" || startsWith == "LL" || startsWith == "DA" || startsWith == "DE" || startsWith == "AL" || startsWith == "CV" || startsWith == "WA" || startsWith == "NG" || startsWith == "CH" || startsWith == "HA" || startsWith == "WF" || startsWith == "DN" || startsWith == "SR" || startsWith == "TA" || startsWith == "RG" || startsWith == "HU" || startsWith == "LA" || startsWith == "SA" || startsWith == "EN" || startsWith == "RM" || startsWith == "TQ" || startsWith == "NP" || startsWith == "SP" || startsWith == "WN" || startsWith == "NE" || startsWith == "CF" || startsWith == "DL" || startsWith == "FY" || startsWith == "TF")
			{
				rsaPostcodes = true;
			}
			
		if(startsWithFirstLetter == "S" ||startsWithFirstLetter == "G" || startsWithFirstLetter == "N" || startsWithFirstLetter == "W")
			{
				if((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
					{
						rsaPostcodes = true;	
					}
			}
		
		if (residence1Year && licHeldSince1 && Max7Drivers && rsaPostcodes)
			{
				emails += ",motortrade4";	
			}


		
		// Crowthorne
		
		if (licHeldSince1 && twentyOneOrOver && roadRiskOnly == false)
			{
				emails += ",motortrade5";	
			}
			

		// Barry Grainger
		
			// Time Filter
			
				var BGtime = false;
			if(currentDay == 1 || currentDay == 2 || currentDay == 3 || currentDay == 4)
			{
			if(timeHours >= 9 && timeHours < 17)
				{
					BGtime = true;
				}
			}
			// Friday time - no leads after 5pm until 9am Monday
			if(currentDay == 5)
			{
				if(timeHours >= 9 && timeHours < 17)
				{
					BGtime = true;
				}
				
			}
				
			var barrrygraingerPostcodes = true;
			
			
			if(startsWith == "BB"  || startsWith == "BD" || startsWith == "EC" || startsWith == "LS" || startsWith == "OL" || startsWith == "WC")
				{
					barrrygraingerPostcodes = false;
				}
				
			if(startsWithFirstLetter == "B" ||startsWithFirstLetter == "E" || startsWithFirstLetter == "L" || startsWithFirstLetter == "M")
				{
					if((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
						{
							barrrygraingerPostcodes = false;	
						}
				}
			
		if(startsWithFirstLetter == "G")
			{
				if((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5"))
					{
						barrrygraingerPostcodes = false;	
					}
			}
		
		if (twentyFiveOrOver && licHeldSince2 && startsWith != "BT" && noDriversUnder25 && barrrygraingerPostcodes && BGtime && Max3Drivers && ncbMin1year && roadRiskOnly)
			{
				emails += ",motortrade6";	
			}



			
/*		
		// XYZ Insurance
		
		if (twentyFiveOrOver && licHeldSince1 && startsWith != "BT")
			{
				emails += ",motortrade7";	
			}
*/
			

			
	
		
		// Peacock
		
		//Time Filter (Mon - Fri, 9am - 5pm)
		
		var PeacockTime = false;
		
		if(timeHours >= 9 && timeHours < 17)
			{
				PeacockTime = true;
			}
		
		if(PeacockTime && roadRiskOnly && notWeekend)
			{
				emails += ",motortrade8";	
			}
	


			
	
/*
		//Lionheart Insurance
		
		if (roadRiskOnly && licHeldSince1)
			{
				emails += ",motortrade10";
			}

*/
	
			

			

			
		// Insurance Factory
		
		var IFtime = false;
		
		if(currentDay < 6 && currentDay > 0)
			{
				if(timeHours >= 9 && timeHours < 19)
					{
						IFtime = true;
					}
			}
		else if(currentDay == 6)
			{
				if(timeHours >= 9 && timeHours < 16)
					{
						IFtime = true;
					}
			}
			
		if (roadRiskOnly && twentyFiveOrOver && startsWith != "BT" && noDriversUnder25 && IFtime)
			{
				emails += ",motortrade13";
			}
			
			
	/*
	// Norton Insurance
	
	if (twentyFiveOrOver && licHeldSince1 && ncbMin1year && noDriversUnder25 && roadRiskOnly)
		{
			emails += ",motortrade14";	
		}
	
		*/





/* Paused as of 28th June 2010 
	//Trident Insurance
	
	var TridentPostcode = true ;
	
	if(startsWith == "BD" || startsWith == "BB")
		{
			TridentPostcode = false;
		}
	
	if(startsWithFirstLetter == "L" || startsWithFirstLetter == "B" || startsWithFirstLetter == "W")
			{
				if((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
					{
						TridentPostcode = false;	
					}
			}
	
	if(Between30And65 && TridentPostcode && roadRiskOnly)
		{
			emails += ",motortrade17";	
		}
*/


	

	
	


		
	//1 Answer
 	/*
	var OneAnswerPostcode = false;
	
	if(startsWith == "AB" || startsWith == "AL" || startsWith == "BA" || startsWith == "BH" ||  startsWith == "BS" || startsWith == "CA" || startsWith == "CB" || startsWith == "CF" || startsWith == "CM" || startsWith == "CO" || startsWith == "CT" || startsWith == "CW" || startsWith == "DD" || startsWith == "DE" || startsWith == "DG" || startsWith == "DL" || startsWith == "DN" || startsWith == "DT" || startsWith == "EH" || startsWith == "EX" || startsWith == "FK" || startsWith == "GL" || startsWith == "GY" || startsWith == "HD" || startsWith == "HG" || startsWith == "HR" || startsWith == "IM" || startsWith == "IP" || startsWith == "IV" || startsWith == "KA" || startsWith == "KW" || startsWith == "KY" || startsWith == "LA" || startsWith == "LD" || startsWith == "LL" || startsWith == "LN" || startsWith == "MK" || startsWith == "NG" || startsWith == "NN" || startsWith == "NP" || startsWith == "NR" || startsWith == "OX" || startsWith == "PE" || startsWith == "PH" || startsWith == "PL" || startsWith == "RH" || startsWith == "SA" || startsWith == "SN" || startsWith == "SO" || startsWith == "SY" || startsWith == "TA" || startsWith == "TD" || startsWith == "TF" || startsWith == "TQ" || startsWith == "TR" || startsWith == "WF" || startsWith == "WR" || startsWith == "YO" || startsWith == "ZE")
		{
			OneAnswerPostcode = true;
		}

	if(Between30And65 && residence5Years && ncbMin1year && Max2Drivers && roadRiskOnly && OneAnswerPostcode)
		{
			emails += ",motortrade21";
		}
	*/	
		
	
	//1 Answer	
		// If user selects Road Risk only and the time is between 9am-2pm otherwise Premises is acceptable 24hrs 
		var coverRequired = false;
	    var oneAnswerSelectedCover = document.getElementById("CoverRequired").value ;
		
		if ((oneAnswerSelectedCover == "Road Risk Only") &&  (startsWith == "BN" || startsWith == "TN") || oneAnswerSelectedCover == "Premises")
			{
				coverRequired = true;	
			}
	
		
	
		if(noDriversUnder25 && twentyFiveOrOver && coverRequired && licHeldSince1)
			{
				emails += ",motortrade19";
			}

		
		
	//Fresh Insurance
	var FreshTime = false;
	
	if(timeHours >= 9 && timeHours < 17 && notWeekend)
			{
				FreshTime = true;
			}
	
	
	if(twentyFiveOrOver && roadRiskOnly && noDriversUnder25 && document.getElementById('Residence').value != "Less Than A Year" && FreshTime)
		{
			emails += ",motortrade22";	
		}

	
	// Coversure Insurance – Tamworth Branch 
	
	var TamCoverTime = false;
	
	if(timeHours >= 9 && timeHours < 13 && notWeekend)
			{
				TamCoverTime = true;
			}
	
	
	var TamworthPostcode = true ;
	
	if(startsWith == "BD" || startsWith == "BL" || startsWith == "BT")
		{
			TamworthPostcode = false;
		}
	
	if(startsWithFirstLetter == "L" || startsWithFirstLetter == "M")
			{
				if((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
					{
						TamworthPostcode = false;	
					}
			}
	
	/*
	
	if(roadRiskOnly && NolondonPostcode && twentyFiveOrOver && TamworthPostcode && TamCoverTime)
	{
			emails += ",motortrade24";	
	}
	
	*/
	
	// Coversure (Huntingdon Branch)
	var CoverHuntPost = true;
	
	if(startsWith == "UB" || startsWith == "BD")
	{
		CoverHuntPost = false;
	}
	
	
	if(startsWithFirstLetter == "M" || startsWithFirstLetter == "B" || startsWithFirstLetter == "L" || startsWithFirstLetter == "G")
			{
				if((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
					{
						CoverHuntPost = false;	
					}
			}
	
	var ncbEitherSelected = false;
	if(ncbPrivateCar != "None" || ncbMotorTrade != "None")
	{
		ncbEitherSelected = true;
	}
	
	if(roadRiskOnly && ageMin30 && licHeldSince2 && ncbEitherSelected && CoverHuntPost)
	{
			emails += ",motortrade25";	
	}
	
	document.getElementById("recipient_bcc").value = emails;
	document.getElementById("reference").value = emails;
		 
	


}


function checkWholeForm(form) {
	var age = ageCalculation(age);
    var why = "";

	why += checkDropdown(form.ApplicantTitle.value, " Title");
	why += isEmpty(form.FullName.value, " Full Name");
	why += isEmpty(form.DaytimeNumber.value, " Contact Number");
	//why += isEmpty(form.Surname.value, " Surname");
	why += checkDOB();	
	why += checkDropdown(form.Residence.value, " UK Resident For");
	why += isEmpty(form.AppAddress.value, " Address");
	why += isEmpty(form.PostCode.value, " Postcode");
	why += isEmpty(form.email.value, " Email");	
	why += isEmpty(form.licence_Held_For.value, " Full UK licence Held Since");	
	why += checkPolicyDate();
	why += checkDropdown(form.CoverRequired.value, " Cover Required");
	why += checkDropdown(form.MTrade_NCB.value, " Motor Trade No Claims Bonus");
	why += checkDropdown(form.Car_NCB.value, " Car No Claims Bonus");
	why += checkDropdown(form.Number_Of_Drivers.value, " Number Of Drivers");
	why += checkDropdown(form.Drivers_Under25.value, " How many of your drivers are 25 years of age and under?");
	why += checkDropdown(form.Claims_Convictions.value, " Do any drivers have any claims and convictions in the past 5 years?");
	//why += checkDropdown(form.YearsEstablished.value, " How long has your business been established for?");
	//why += isEmpty(form.Nature_Of_Business.value, " What is the nature of your business?");
	

 if (why != "") {
       alert("Please fill in the following fields: \n"+why);
       return false;
    }
	
	else if(age < 26 || age > 90){
		alert('Unfortunately we are unable to submit your details as none of our partners will offer you cover due \nto your age. Please check your Date of Birth to make sure it has been entered correctly.');
		return false;
	}
	
	else if(why == ""){
	return true;
	}
}


function isEmpty(strng, str){
var error = "";
  if (strng.length == 0){
     error = "-"+str+"\n";
  }
return error;	  
}

function checkDOB(){
var error = "";
if ( (document.getElementById("DOBday").value == "") || (document.getElementById("DOBmonth").value == "0") || (document.getElementById('DOBYear').value == "") )
		{
			error = "- Enter A Valid DOB"+"\n";
		}
	return error;
}

function checkPolicyDate(){
var error = "";
if ( (document.getElementById("PolicyDate").value == "") || (document.getElementById("PolicyMonth").value == "0") || (document.getElementById('PolicyYear').value == "") )
		{
			error = "- Enter A Valid Cover Start Date"+"\n";
		}
	return error;
}

function checkDropdown(choice, str){
    var error = "";
	if (choice == "0"){
       error = "-"+str+"\n";
    }    
return error;
}

function radioChecked(radiobutton, str){
var error = "";
  for(i=0; i<radiobutton.length; i++){
 	 if(radiobutton[i].checked == true){
		 error = "";
		 break;
	 }
  	 else{
		 error = "-"+str+"\n";
	}
  }
return error;	  
}

function checkBoxChecked(checkbox, str){
    var error = "";
	if (!checkbox.checked){
       error = "-"+str+"\n";
    }    
return error;
}

