 /*	
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 checkDOBIsQuotable(){

	var dob = document.getElementById("DOB").value
	var dob_array = dob.split("/");
	
	var d = new Date();
	var curr_date = d.getDate(); 
	var curr_month = d.getMonth() + 1;
	var curr_year = d.getFullYear();
	
	var yrDiff = curr_year - DOByear;
	if (yrDiff < 23){
		alert("Currently we are unable to offer quotes for individuals under 23.");		
	}
	else if (yrDiff == 23){
		//check month
		var mDiff = curr_month - DOBmonth;
		if (mDiff < 0){
			alert("Currently we are unable to offer quotes for individuals under 23.");		
							
		}
		if (mDiff == 0){
			var dDiff = curr_date - DOBday;
			if (dDiff < 0){
				alert("Currently we are unable to offer quotes for individuals under 23.");		
			}		
		}			
	}

}

function checkForm(){
	
	var emails = "gravytrain"; // <-- taxi4 & taxi11 go here
	
	var postcodeStr = document.getElementById("Base_Postcode").value;
	var startsWith = postcodeStr.substring(0,2);
	var postcode3 = postcodeStr.substring(0,3);
	var postcode4 = postcodeStr.substring(0,4);
	startsWith = startsWith.toUpperCase();
	var startsWithFirstLetter = postcodeStr.substring(0,1);
	startsWithFirstLetter = startsWithFirstLetter.toUpperCase();	
	var no = postcodeStr.substring(1,2);
	
	//age 23 - 75
	var twentyThreeOrOver = false;
		var DOBday = document.getElementById("DOB_day").value;
		var DOBmonth = document.getElementById("DOB_month").value;
		var DOByear = document.getElementById("DOB_year").value;
		
		var DriverCover = document.getElementById("Drivers").value;
		
		var d = new Date();
		var curr_date = d.getDate();
		var curr_month = d.getMonth() + 1;
		var curr_year = d.getFullYear();
		
		var yrDiff = curr_year - DOByear;
		
		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	
				}		
			}			
		}
		
		
		
		//age 23 - 65
	var twentyThree65 = false;
		
		var yrDiff = curr_year - DOByear;
		
		if ((yrDiff > 23) && (yrDiff < 65)){
			twentyThree65 = true;	
		}
		else if (yrDiff == 23){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentyThree65 = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentyThree65 = true	
				}		
			}			
		}
		else if (yrDiff == 65){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentyThree65 = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentyThree65 = true	
				}		
			}			
		}
		
		
		
		//age 26 - 75
	var twentySixOrOver = false;
		
		var yrDiff = curr_year - DOByear;
		
		if ((yrDiff > 26) && (yrDiff < 75)){
			twentySixOrOver = true;	
		}
		else if (yrDiff == 26){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentySixOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentySixOrOver = true	
				}		
			}			
		}
		else if (yrDiff == 75){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				twentySixOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	twentySixOrOver = true	
				}		
			}			
		}	
		
	//age 30 - 60
	var thirtyOrOver = false;
		
		var yrDiff = curr_year - DOByear;
		
		if ((yrDiff > 30) && (yrDiff < 60)){
			thirtyOrOver = true;	
		}
		else if (yrDiff == 30){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				thirtyOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	thirtyOrOver = true	
				}		
			}			
		}
		else if (yrDiff == 75){
			//check month
			var mDiff = curr_month - DOBmonth;
			
			if (mDiff > 0){
				thirtyOrOver = true				
			}
			if (mDiff == 0){
				var dDiff = curr_date - DOBday;
				
				if (dDiff > 0){
				 	thirtyOrOver = true	
				}		
			}			
		}	
	
					
	//License Held Since - min 3 years
	var licHeldSince = false;
		
	var licHeldFor = document.getElementById("License_Held_For").value
	
	if (licHeldFor != "Under 1 Year" && licHeldFor != "1 Year" && licHeldFor != "2 Years")
		{
			licHeldSince = true;	
		}
		
	//License Held Since - min 2 years
	
	var licHeldSince2 = false;
	
	if (licHeldFor != "Under 1 Year" && licHeldFor != "1 Year") 
		{
			licHeldSince2 = true;	
		}
		
	//License Held Since - min 4 years
	
	var licHeldSince4 = false;
	
	if (licHeldFor != "Under 1 Year" && licHeldFor != "1 Year" && licHeldFor != "2 Year" && licHeldFor != "3 Year") 
		{
			licHeldSince4 = true;	
		}
		
	//License Held Since - min 5 years
	
	var licHeldSince5 = false;
	
	if (licHeldFor != "Under 1 Year" && licHeldFor != "1 Year" && licHeldFor != "2 Year" && licHeldFor != "3 Year" && licHeldFor != "4 Year") 
		{
			licHeldSince5 = true;	
		}
	
		
		
		//Residence 5+ Years
		
		var residence5Years = false;
		var residence4Years = false;
		var residence3Years = false;
		
		var livedFor = document.getElementById("Residence").value ;
		
		if (livedFor >= 5 || livedFor == "Since Birth")
		{
			residence5Years = true;	
		}
		
		// Residence 3 Years
		
		if (livedFor >= 3 || livedFor == "Since Birth")
		{
			residence3Years = true;	
		}
		
		// Residence 4 Years
		
		if (livedFor >= 4 || livedFor == "Since Birth")
		{
			residence4Years = true;	
		}
		
		
		//Taxi Badge Held For 1 Year
		
		var TaxiBadge1Year = true;
		var TaxiBadgeLenth = document.getElementById("TaxiBadge_Held_For").value ;
		
		if (TaxiBadgeLenth == "Under 1 Year")
			{
				TaxiBadge1Year = false;	
			}
		
		//Taxi Badge For 2 Years
		
		var TaxiBadge2Year = true;
		
		if (TaxiBadgeLenth == "Under 1 Year" || TaxiBadgeLenth == "1 Year")
			{
				TaxiBadge2Year = false;	
			}
			
		// Taxi Min NCB 
		var TaxiNCB = document.getElementById('Taxi_No_Claims').value;
		
			//Min 3 YEars
			var min3YearsNCB = true;
			
			if(TaxiNCB == "None" || TaxiNCB == "1 Year" || TaxiNCB == "2 Years")
				{
					var min3YearsNCB = false;	
				}
				
			
		
			//Taxi NCB max 2 years
			
			var max2YearsTaxiNCB = false;
			
			
			if(TaxiNCB == "None" || TaxiNCB == "1 Year" || TaxiNCB == "2 Years")
				{
					max2YearsTaxiNCB = true;
				}
				
			//Taxi min 5 Years
			
			var min5YearsTaxiNCB = false;
			
			if(TaxiNCB == "5 Years" || TaxiNCB == "6 Years" || TaxiNCB == "7 Years" || TaxiNCB == "8 Years" || TaxiNCB == "9 Years" || TaxiNCB == "10 Years" || TaxiNCB == "10+ Years")
				{
					min5YearsTaxiNCB = true;
				}
				
			
			//Taxi min 8 Years
			
			var min8YearsTaxiNCB = false;
			
			if(TaxiNCB == "8 Years" || TaxiNCB == "9 Years" || TaxiNCB == "10 Years" || TaxiNCB == "10+ Years")
				{
					min8YearsTaxiNCB = true;
				}
				
				
			// Number Of Passengers
			
			var numberOfPassengers = document.getElementById("Number_Of_Passengers").value ;
			
				// Min 5 Passengers
				
				var passengers5 = true;
				
				if(numberOfPassengers == "1" || numberOfPassengers == "2" || numberOfPassengers == "3" || numberOfPassengers == "4")
					{
						passengers5 = false;	
					}
							
		
		// London Postcode
		var londonPostcode = false;
		
		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"))
					{
						londonPostcode = true;	
					}
			}
			
		
		if(startsWith == "SE" || startsWith == "WC" || startsWith == "EC" || startsWith == "NW" || startsWith == "SW")
			{
				londonPostcode = true;	
			}
			
		
		// Northern Postcode
		var northernPostcode = false;
		
		if(startsWithFirstLetter == "B" || startsWithFirstLetter == "L" || startsWithFirstLetter == "M" || startsWithFirstLetter == "S")
			{
				if((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
						{
							northernPostcode = true;	
						}
			}
			
		if(startsWith == "BB" || startsWith == "BD" || startsWith == "BL" || startsWith == "CH" || startsWith == "CV" || startsWith == "CW" || startsWith == "DE" || startsWith == "DL" || startsWith == "DN" || startsWith == "DY" || startsWith == "FY" || startsWith == "HD" || startsWith == "HG" || startsWith == "HU" || startsWith == "HX" || startsWith == "IP" || startsWith == "LA" || startsWith == "LE" || startsWith == "LL" || startsWith == "LN" || startsWith == "LS" || startsWith == "NG" || startsWith == "NR" || startsWith == "OL" || startsWith == "PE" || startsWith == "PR" || startsWith == "SK" || startsWith == "ST" || startsWith == "SY" || startsWith == "TF" || startsWith == "TS" || startsWith == "WA" || startsWith == "WF" || startsWith == "WN" || startsWith == "WS" || startsWith == "WV" || startsWith == "YO")
		  {
		  		northernPostcode = true;	
		  }
		  
		  
		  //Scottish Postcode
		  
		  var scottishPostcode = false;
		  
		  if( startsWith == "AB" || startsWith == "DD" || startsWith == "DG" || startsWith == "EH" || startsWith == "FK" || startsWith == "HS" || startsWith == "IV" || startsWith == "KA" || startsWith == "KW" || startsWith == "KY" || startsWith == "ML" || startsWith == "PA" || startsWith == "PH" || startsWith == "TD" || startsWith == "ZE" )
				{
					scottishPostcode = true;
				}
		
		if (startsWithFirstLetter == "G")
			{
					if ((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
					{
						scottishPostcode = true;
					}	
			}



	//Barry Granger
	var grangerPostcodes = false;
	
	if ( startsWith == "AL" || startsWith == "BA" || startsWith == "BH" || startsWith == "BN" || startsWith == "BR" || startsWith == "BS" || startsWith == "CB" || startsWith == "CF" || startsWith == "CH" || startsWith == "CM" || startsWith == "CO" ||startsWith == "CR" || startsWith == "CT" || startsWith == "CV" || startsWith == "DA" || startsWith == "DT" || startsWith == "DY" || startsWith == "EN" || startsWith == "EX" || startsWith == "GL" || startsWith == "GU" || startsWith == "HA" || startsWith == "HP" || startsWith == "HR" || startsWith == "IP" || startsWith == "KT" || startsWith == "LD" || startsWith == "LL" || startsWith == "LN" || startsWith == "LU" || startsWith == "ME" || startsWith == "MK" || startsWith == "NG" || startsWith == "NP" || startsWith == "NN" || startsWith == "NR" || startsWith == "OX" || startsWith == "PE" || startsWith == "PL" || startsWith == "PO" || startsWith == "RG" || startsWith == "RH" || startsWith == "SA" || startsWith == "SG" || startsWith == "SL" || startsWith == "SM" || startsWith == "SN" || startsWith == "SO" || startsWith == "SP" || startsWith == "SY" || startsWith == "TA" || startsWith == "TN" || startsWith == "TQ" || startsWith == "TR" || startsWith == "WD" || startsWith == "WR")
		{
			grangerPostcodes = true;
		} 
	
	if (startsWithFirstLetter == "B")
		{
				if ((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6") || (no == "7") || (no == "8") || (no == "9"))
				{
					grangerPostcodes = true;
				}	
		}
	
	if( twentySixOrOver && licHeldSince2 && TaxiBadge2Year && residence3Years && document.getElementById("Taxi_No_Claims").value != "None" && grangerPostcodes)
		{
			emails += ",taxi2";	
		}
		


	//DNA
	
	if(document.getElementById("Vehicle_Use").value == "Public Hire" && min3YearsNCB)
		{
			emails += ",taxi4";			
		}

	
/*	
	//Choice Quote
	var validChoiceQuotePostCode = true;

	// No London postcodes
	if ((startsWith == "EC") || (startsWith == "WC") || (startsWith == "NW")|| (startsWith == "SE") || (startsWith == "SW")) 
		{
			validChoiceQuotePostCode = false;
		}

	else if (startsWithFirstLetter == "E" || startsWithFirstLetter == "W"|| startsWithFirstLetter == "N") 
		{
			if ((no == "1") || (no == "2") || (no == "3") || (no == "4") || (no == "5") || (no == "6")|| (no == "7") || (no == "8") || (no == "9")) 
				{
					validChoiceQuotePostCode = false;
				}
		}
	
	// Must have either taxi or private car no claims bonus.
	if (document.getElementById('Taxi_No_Claims').value == "None" && document.getElementById('Private_No_Claims').value == "None") 
		{
			validChoiceQuotePostCode = false;
		}

	if (validChoiceQuotePostCode) {
		emails += ",taxi5";
	}
*/
	
	
	//EGroup
	if ((startsWith == "AB") || (startsWith == "BA") || (startsWith == "BH") || (startsWith == "BN") || (startsWith == "BS") || (startsWith == "CA") || (startsWith == "CB") || (startsWith == "CF") || (startsWith == "CO") || (startsWith == "CT") || (startsWith == "CW") || (startsWith == "DD") || (startsWith == "DG") || (startsWith == "DH") || (startsWith == "DN") || (startsWith == "DT") || (startsWith == "EH") || (startsWith == "EX") || (startsWith == "FK") || (startsWith == "GL") || (startsWith == "GU") || (startsWith == "HG") || (startsWith == "HR") || (startsWith == "IV") || (startsWith == "KA") || (startsWith == "KT") || (startsWith == "KW") || (startsWith == "KY") || (startsWith == "HP") || (startsWith == "LA") || (startsWith == "LD") || (startsWith == "LL") || (startsWith == "LN") || (startsWith == "NP") || (startsWith == "NN") || (startsWith == "NR") || (startsWith == "OX") || (startsWith == "PH") || (startsWith == "PE") || (startsWith == "PL") || (startsWith == "PO") || (startsWith == "RG") || (startsWith == "SA") || (startsWith == "SG") || (startsWith == "SN") || (startsWith == "SO") || (startsWith == "SP") || (startsWith == "SY") || (startsWith == "TA") || (startsWith == "TF") || (startsWith == "TN") || (startsWith == "TQ") || (startsWith == "TR") || (startsWith == "WR") || (startsWith == "YO"))
	
		{
		 	if (twentyThreeOrOver)
				 {
					emails += ",taxi14";
				 }
		}
	
	
/*	
	//JMI
	
	if (startsWith != "BT" && startsWith != "WS" && twentyThree65 && licHeldSince2 && DriverCover != "AnyDriver" && DriverCover != "Insured and 2 Named Drivers")
		{
			emails += ",taxi3";		
		}
		
*/	

/*		
			//Insure Taxi
		
	if (startsWith == "AB" || postcode4 == "NE66" || startsWith == "TD" || postcode3 == "BA1" || postcode3 == "BA2" || postcode3 == "BA3" || startsWith == "FY" || postcode3 == "BN1" || postcode3 == "BN2" || postcode3 == "CM1" || postcode3 == "CM2" || postcode3 == "CM3" || startsWith == "CO" || postcode3 == "CH1" || postcode3 == "CH2" || postcode3 == "CH3" || postcode3 == "CH4" || postcode3 == "PR6" || postcode3 == "PR7" || postcode4 == "CW12" || postcode3 == "CW1" || postcode3 == "CW2" || postcode3 == "CW3" || postcode3 == "CW5" || postcode4 == "CH65" || postcode4 == "CH66" || postcode3 == "CH5" || postcode3 == "CH6" || postcode3 == "CH7" || postcode3 == "GL1" || postcode3 == "GL2" || postcode3 == "GL3" || postcode3 == "GL4" || postcode3 == "GU1" || postcode3 == "GU2" || postcode3 == "GU3" || postcode3 == "GU4" || postcode3 == "GU5" || postcode4 == "LS15" || postcode3 == "HG1" || postcode3 == "HG2" || postcode3 == "HG3" || startsWith == "HU" || postcode4 == "SK10" || postcode4 == "SK11" || postcode4 == "SK22" || postcode4 == "SK23" || startsWith == "LN" || startsWith == "NR" || postcode3 == "OX1" || postcode3 == "OX2" || postcode3 == "OX3" || postcode3 == "OX4" || startsWith == "PL" || postcode3 == "PR1" || postcode3 == "PR2" || postcode3 == "PR3" || postcode3 == "PR4" || postcode3 == "PR5" || postcode3 == "SP1" || postcode3 == "SP2" || postcode3 == "SP3" || postcode3 == "SP4" || postcode3 == "SP5" || postcode3 == "L20" || postcode3 == "L21" || postcode3 == "L22" || postcode3 == "L23" || postcode3 == "L30" || postcode3 == "L31" || postcode3 == "L37" || postcode3 == "L38" || postcode4 == "PR25" || postcode4 == "PR26" || postcode3 == "AL1" || postcode3 == "AL2" || postcode3 == "AL3" || postcode3 == "AL4" || postcode3 == "WA9" || postcode4 == "WA10" || postcode3 == "WA1" || postcode3 == "WA2" || postcode3 == "WA3" || postcode3 == "WA4" || postcode3 == "WA5" || postcode3 == "WN1" || postcode3 == "WN2" || postcode3 == "WN3" || postcode3 == "WN4" || postcode3 == "WN5" || postcode3 == "WN6" || startsWith == "WR" || postcode4 == "LL11" || postcode4 == "LL12" || postcode4 == "LL13" || postcode4 == "LL14" || postcode3 == "YO1" || postcode4 == "YO10" || postcode4 == "YO26" || postcode4 == "YO41" || postcode4 == "YO60" || postcode4 == "YO91" || postcode4 == "YO19" || postcode4 == "YO30" || postcode4 == "YO42" || postcode4 == "YO61" || postcode4 == "YO93" || postcode4 == "YO23" || postcode4 == "YO31" || postcode4 == "YO43" || postcode4 == "YO62" || postcode4 == "YO32" || postcode4 == "YO51" || postcode4 == "YO90" || postcode4 == "SO14" || postcode4 == "SO15" || postcode4 == "SO16" || postcode4 == "SO17" || postcode4 == "SO18" || postcode3 == "SN1" || postcode3 == "SN2" || postcode3 == "SN3" || postcode3 == "SN4" || postcode3 == "SN5" || postcode3 == "SN6" || startsWith == "SK" || postcode3 == "TA1" || postcode3 == "TA2" || postcode3 == "TA3" || postcode3 == "TQ1" || postcode3 == "TQ2" || postcode3 == "TR1" || postcode3 == "TR2" || postcode3 == "TR3"  )
		{
			emails += ",taxi";	
		}
*/				


	//Quoteline Direct
		
		var quotelinePostcode = true;
		
	if ( (startsWith == "SW") || (startsWith == "NW") || (startsWith == "WC") || (startsWith == "WF") || (startsWith == "EC") || (startsWith == "SE") || (startsWith == "AB") || (startsWith == "DD") || (startsWith == "DG") || (startsWith == "EH") || (startsWith == "FK") || (startsWith == "IV") || (startsWith == "KA") || (startsWith == "KW") || (startsWith == "KY") || (startsWith == "ML") || (startsWith == "PA") || (startsWith == "PH") || (startsWith == "TD") )
		{
			quotelinePostcode = false;
		}
	
   if ( (startsWithFirstLetter == "B") || (startsWithFirstLetter == "E") || (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")) 
			{
				quotelinePostcode = false;
			}
		}
		
	if (quotelinePostcode && max2YearsTaxiNCB)
		{
			emails += ",taxi7";
		}
		
																			 																	  

		
		
	//Stavely Head
	
	if ( (startsWith != "BT") && (twentyThree65) && (licHeldSince) && (document.getElementById("Drivers").value != "AnyDriver") && (residence5Years) )
		{
			emails += ",taxi8";	 
		}
		

		
	// Metcalfe Insurance
	
	if ( /*startsWith == "CW" || startsWith == "DN" ||*/ startsWith == "SK" /*|| startsWith == "ST" || startsWith == "YO" */)
		{
			emails += ",taxi9";	
		}
		
		
	// Ashbourne Insurance
	
	var ashPostcode = false;
	
	if(startsWith == "CM" || startsWith == "SG" || startsWith == "EN")    
		{
			ashPostcode = true;	
		}
	
	
	if ( ashPostcode && twentySixOrOver && (DriverCover != "Insured and 2 Named Drivers") && (DriverCover != "AnyDriver") )
		{
			emails += ",taxi10";
		}
		
		
	
	// Graysons Insurance
	
	var graysonPostcode = false;
	
	if(startsWith == "AL" || startsWith == "BA" || startsWith == "BH" || startsWith == "BN" || startsWith == "BS" || startsWith == "CB" || startsWith == "CO" || startsWith == "CM" || startsWith == "CT" || startsWith == "DT" || startsWith == "EX" || startsWith == "GL" || startsWith == "GU" || startsWith == "HP" || startsWith == "IP" || startsWith == "LU" || startsWith == "ME" || startsWith == "MK" || startsWith == "NN" || startsWith == "NR" || startsWith == "OX" || startsWith == "PE" || startsWith == "PL" || startsWith == "PO" || startsWith == "RG" || startsWith == "RH" || startsWith == "SG" || startsWith == "SL" || startsWith == "SN" || startsWith == "SO" || startsWith == "SP" || startsWith == "SS" || startsWith == "TA" || startsWith == "TN" || startsWith == "TQ" || startsWith == "TR")    
		{
			graysonPostcode = true;	
		}
		
	if(graysonPostcode && licHeldSince2 && residence3Years && twentySixOrOver)
		{
			emails += ",taxi11";
		}

	

	// Insurance Factory
	
	if (startsWith != "BT")
		{
			emails += ",taxi13";
		}
		
		
	//Freeway Insurance
	
	var freewayPostcode = true;
	
	if(startsWith == "BR" || startsWith == "CR" || startsWith == "DA" || startsWith == "EN" || startsWith == "HA" || startsWith == "IG" || startsWith == "KT" || startsWith == "RM" || startsWith == "SM" || startsWith == "TN" || startsWith == "TW" || startsWith == "UB" || londonPostcode)
		{
			freewayPostcode = false;
		}
	
	if(twentySixOrOver && licHeldSince5 && document.getElementById("Drivers").value == "Insured Only" && TaxiBadge1Year && freewayPostcode)
		{
			emails += ",taxi15";
		}


	// D Miller Insurance
	
	if(northernPostcode || scottishPostcode)
		{
			if(twentySixOrOver && licHeldSince2 && min8YearsTaxiNCB)
				{
					emails += ",taxi16";
				}
		}

		
	
	// XYZ Insurance
	
	if(twentySixOrOver && licHeldSince2 && startsWith != "BT" && passengers5 && document.getElementById("Taxi_Type").value != "Saloon Up To 5 Passengers" && min5YearsTaxiNCB)

		{
			emails += ",taxi17";
		}
	
	
	// A Plan
	
	var aPlanPostcode = false;
	
	if (startsWith == "BH" || startsWith == "SO" || startsWith == "DT" || startsWith == "PO" || startsWith == "PE" || startsWith == "BS" || startsWith == "EX" || startsWith == "TQ" || startsWith == "TN" || startsWith == "PL" || startsWith == "AB" || startsWith == "DD" || startsWith == "IP" || startsWith == "BA" || startsWith == "GL" || startsWith == "WR" || startsWith == "OX" || startsWith == "NN" || startsWith == "LL" || startsWith == "DG" || startsWith == "EH" || startsWith == "RH" || startsWith == "YO")
		{
			aPlanPostcode = true;
		}
	
	if (thirtyOrOver && residence4Years && TaxiBadge1Year && licHeldSince4 && aPlanPostcode)
		{
			emails += ",taxi18";	
		}
		
/*	
	// Milestone Insurance
	
	if(startsWith != "BT" && twentyThreeOrOver && document.getElementById("Taxi_No_Claims").value != "None")
		{
			emails += ",taxi19";	
		}
*/
		
		
	  	//emails = filterTimeEmail(emails);
		
		
		document.getElementById("recipient_bcc").value = emails;
		document.getElementById("reference").value = emails;
		 
	


}

function filterTimeEmail(emails){

	var currentTime = new Date();
	var hours = currentTime.getHours();
	var returnEmails= "gravytrain";
	
	var odds = "taxi2,taxi5,taxi8,taxi9,taxi10,taxi13,taxi14,taxi6";
	var evens = "taxi2,taxi5,taxi6,taxi7,taxi9,taxi10,taxi14";
	
	var tokens = emails.split( "," );

	for(var i=0; i<tokens.length; i++){
		if( hours % 2 == 0 )
		{
			if (evens.search(tokens[i])!=-1){
				returnEmails+=("," + tokens[i]);
			}
		
		}else{
			if (odds.search(tokens[i])!=-1){
				returnEmails+=("," + tokens[i]);
			}
		}
		
	}
	
	return 	returnEmails;	
}
	
function checkWholeForm(form) {

    var why = "";

	why += checkDropdown(form.Title.value, " Title");
	why += isEmpty(form.Name.value, " Name");
	why += checkDOB();	
	why += checkDropdown(form.Residence.value, " UK Resident For");
	why += isEmpty(form.Home_Address.value, " Home Address");
	why += isEmpty(form.Home_Postcode.value, " Home Postcode");
	why += isEmpty(form.email.value, " Email");
	why += isEmpty(form.Home_Number.value, " Home Telephone Number");
	why += isEmpty(form.Mobile_Number.value, " Mobile/Work Telephone Number");
	why += checkDropdown(form.Other_Occupation.value, " Other Occupation");
	why += isEmpty(form.Base_Postcode.value, " Base / Rank Postcode");
	why += checkDropdown(form.License_Held_For.value, " Full UK License Held For");
	why += checkDropdown(form.TaxiBadge_Held_For.value, " Taxi / PCV Badge Held For");
	why += isEmpty(form.Licensing_Authority.value, " Name Of Licensing Authority");
	
	why += isEmpty(form.Start_Date_Of_Cover.value, " Required Start Date Of Cover");
	why += checkDropdown(form.Level_Of_Cover.value, " Level Of Cover");
	why += checkDropdown(form.Drivers.value, " Drivers");
	why += checkDropdown(form.Taxi_No_Claims.value, " Taxi No Claims Bonus");
	why += checkDropdown(form.Private_No_Claims.value, " Private No Claims Bonus");
	why += checkDropdown(form.Accidents_Losses.value, " Accidents/Losses in last 5 years");
	why += checkDropdown(form.Convictions.value, " Convictions in last 5 years");
	
	why += isEmpty(form.Vehicle_Registration.value, " Vehicle Registration");
	why += checkDropdown(form.Vehicle_Use.value, " Vehicle Use");
	why += checkDropdown(form.Number_Of_Passengers.value, " Number Of Passengers");
	why += isEmpty(form.Vehicle_Make.value, " Vehicle Make");
	why += isEmpty(form.Vehicle_Model.value, " Vehicle Model");
	why += checkDropdown(form.Taxi_Type.value, " Taxi Type");
	why += isEmpty(form.Year_Of_Manufacture.value, " Year Of Manufacturer");
	why += isEmpty(form.Current_Value.value, " Current Value");
	
	

 if (why != "") {
       alert("Please fill in the following fields: \n"+why);
       return false;
    }
	else if(why == ""){
	return true;
	}
}

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


function isEmpty(strng, str){
var error = "";
  if (strng.length == 0){
     error = "-"+str+"\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;
}

