function checkForm(){
	
	var emails = "gt,salon13"; // ,salon8 paused 21 July ,salon16 paused 27th July
	
	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 d = new Date();
	var currentDay = d.getDay();
	
	var notWeekend = true;
	
	if(currentDay == 0 || currentDay == 6)
		{
			notWeekend = false;
		}
	
	
	
	//Number Of Claims
	
	var numberOfClaims = document.getElementById("InsuranceClaims5Years").value ;
	var max2Claims = false;
	
	if (numberOfClaims == "None" || numberOfClaims == "1" || numberOfClaims == "2")
		{
			max2Claims = true;
		}
		
	// SME Insurance
		
		if(startsWith != "BT" )
					{
						emails += ",salon2";
					}

	//First4 & Hensure
	
	if(startsWith != "BT")
		{
			emails += ",salon3";
		}


/*
	//Coversure
	
	if(document.getElementById('TypeOfBusiness').value == "Hairdressing" || document.getElementById('TypeOfBusiness').value == "Barbers")
		{
			emails += ",salon5";
		}
*/

/*		
	//Premier Direct
		
		if(max2Claims)
			{
				emails += ",salon7";
			}
*/


	//Baronworth
	
	if(document.getElementById("TypeOfBusiness").value != "Freelance" && document.getElementById("SalonOwner").value != "No" && startsWith != "BT")
		{
			emails += ",salon9";	
		}
		
		
	//Yours Insurance
	
	
	var fridayTimes = true;
	if(currentDay == 5 && timeHours > 16)// if day is friday(5) and time is over 4pm then set value to false
	{
		fridayTimes = false;
	}
		
	
	if(startsWith != "BT" && notWeekend && timeHours >= 7 && timeHours < 17 && fridayTimes)
		{
			emails += ",salon12";
		}
		
		
	//Norwich & Peterborough Insurance
		
	
	if(startsWith == "CO" || startsWith =="CM" || startsWith =="SG" || startsWith == "CB" || startsWith == "IP" || startsWith == "NR" || startsWith == "PE" || startsWith == "NN" || startsWith == "LN")
	{
		emails += ",salon15";
	}
	
	// Wheels Insurance
	
	if(notWeekend && (timeHours >= 9 && timeHours < 17))
	{
		emails += ",salon17";
	}
	
	
		
	document.getElementById("recipient_bcc").value = emails;
	document.getElementById("reference").value = emails;
}

function checkWholeForm(form) {
	
    var why = "";
	why += checkDropdown(document.getElementById('Title').value, " Title");
    why += isEmpty(document.getElementById('FullName').value, " Full Name");
	why += isEmpty(document.getElementById('DaytimeNumber').value, " Contact Telephone");	
	why += isEmpty(document.getElementById('email').value, " Email");
	why += isEmpty(document.getElementById('AddressApp').value, " Shop Address");
	why += isEmpty(document.getElementById('Postcode').value, " Shop Postcode");
	why += checkDropdown(document.getElementById('TypeOfBusiness').value, " Type Of Business");
	why += isEmpty(document.getElementById('BusinessName').value, " Business/Trading Name");
	why += checkDropdown(document.getElementById('SalonOwner').value, " Are you the salon owner?");
	
	why += checkStartDate();
	why += checkDropdown(document.getElementById('InsuranceClaims5Years').value, " Number of claims made in the past 5 years?");
	why += checkDropdown(document.getElementById('PublicLiability').value, " Public Liability");
	why += checkDropdown(document.getElementById('EmployersLiability').value, " Employers Liability");
	
	why += checkDropdown(document.getElementById('NumberOfEmployees').value, " Number Of Employees");
	why += isEmpty(document.getElementById('AnnualTurnover').value, " Annual Turnover");
	why += isEmpty(document.getElementById('FixturesAndFittings').value, " Tenants Improvements/Fixtures &amp; Fittings");
	why += isEmpty(document.getElementById('EquipmentValue').value, " Value Of Equipment &amp; Tools Used");
	why += isEmpty(document.getElementById('StockValue').value, " Value of Stock");
	why += checkDropdown(document.getElementById('Alarm').value, " Is There An Alarm System Fitted?");
	
	why += checkDropdown(document.getElementById('YearsEstablished').value, " How long have you been trading for?");
	 
    if (why != "") {
       alert("Please fill in the following fields: \n"+why);
       return false;
    }
}

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;
}
