function checkForm(){
	
	var emails = "gt2,landlord4,landlord10"; // ,landlord3 paused 26 July 2010
	
	var postcodeStr = document.getElementById("Postcode").value;
	var startsWith = postcodeStr.substring(0,2);
	var postcode3 = postcodeStr.substring(0,3);
	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;
		}
		
	
	// Partner Filters
	
	if (startsWith != "BT")
		{
			emails += ",landlord5,landlord8";	
		}
		
		
	// Cheers Insurance
	
	if(startsWith == "TW" || postcode3 == "KT1" || postcode3 == "KT2" || postcode3 == "KT7" || postcode3 == "KT8")
		{
			emails += ",landlord12";	
		}
		
	/*	
	//Bedfords (5pm - 9am)
	
	var bedfordTime = true;
	
	if(timeHours > 9 && timeHours < 17)
		{
			bedfordTime = false;
		}
	
	if(bedfordTime)
		{
			emails += ",landlord14";	
		}
*/

	//Wheels Insurance
	/* Paused 27 August
	if(timeHours >= 9 && timeHours < 17 && notWeekend)
	{
		emails += ",landlord17";
	}
	*/

	document.getElementById("recipient_bcc").value = emails;
	document.getElementById("reference").value = emails;
}
	

function checkWholeForm(form) {
	
	//var em = form.Email.value;
	
    var why = "";
    why += isEmpty(document.getElementById('FullName').value, " Full Name");
	why += isEmpty(document.getElementById('Clients_Address').value, " Your Address");
	why += isEmpty(document.getElementById('Postcode').value, " Postcode");	
	why += isEmpty(document.getElementById('DaytimeNumber').value, " Contact Telephone");
	why += isEmpty(document.getElementById('email').value, " Email");
	
	why += checkStartDate();
	why += checkDropdown(document.getElementById('Property_Unoccupied').value, " Is the Property Currently Unoccupied?");
	why += isEmpty(document.getElementById('Rebuild_Cost').value, " Rebuild Cost Of Property");
	why += isEmpty(document.getElementById('ContentCover').value, " Contents Sum Insured");
	why += checkDropdown(document.getElementById('InsuranceClaims5Years').value, " Have you made any claims in the past 5 years?");
	
	why += isEmpty(document.getElementById('AddressApp').value, " Address Of The Property To Be Insured");
	why += isEmpty(document.getElementById('PropertyPostcode').value, " Postcode Of The Property To Be Insured");
	why += checkDropdown(document.getElementById('NumberOfStories').value, " Number Of Stories");
	why += checkDropdown(document.getElementById('Wall_Type').value, " Wall Type");
	why += checkDropdown(document.getElementById('Roof_Type').value, " Roof Type");
	why += checkDropdown(document.getElementById('Floor_Type').value, " Floor Type");
	why += checkDropdown(document.getElementById('ListedBuilding').value, " Is The Property Listed?");
	why += isEmpty(document.getElementById('ConstructionYear').value, " Year Built");
	 
if (why != "") {
       alert("Please fill in the following fields: \n"+why);
       return false;
    }
	else if(why == ""){
	return true;
	}
}

function checkStartDate(){
var error = "";
if ( (document.getElementById("PolicyDate").value == "") || (document.getElementById("PolicyMonth").value == "0") || (document.getElementById('PolicyYear').value == "") )
		{
			error = "- Please Enter A Valid Policy Start Date"+"\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;
}