function fncValidateForm(objForm) {
	var strEmptyMsg = "";
	var strErrorMsg = "";
	var intErrors = 0;
	
	function validate(str, text) {
		if (str.indexOf("@") >= 0 || str.indexOf(":") >= 0 || str.indexOf(";") >= 0 || str.split("http").length-1 > 1) {
			strErrorMsg += " --> "+text+"\n";
			intErrors++;
		}
	}
	
	//validates email address
	var reString = /^(\w+([-.]\w)*)+[@]\w+(([-]\w+)*[.]\w+)+$/;
	var regex = new RegExp(reString);
	var strValidSample = "aaa.bbbbbb@cccc.ddd";
	var strEmail = new String(objForm.email.value);
	
	if (strValidSample.search(regex) == -1) {
		// this is netscape 4.x or early IE 5.0x
		// we'll check for a @, the presence of spaces, a length of at least 6 (a@b.co is the smallest valid email string), the presence of a .
		if((strEmail.indexOf("@") == -1) || (strEmail.indexOf(" ") > -1) || (strEmail.length < 6) || (strEmail.length == 0)  || (strEmail.indexOf(".") == -1)) {
			strEmptyMsg += " --> Email\n";
			intErrors++;
		}
	} else {
		if (objForm.email.value.search(regex) == -1 || strEmail.length == 0) {
			strEmptyMsg += " --> Email\n";
			intErrors++;
		}
	}
	
	// get variables from the form
	var strName = new String(objForm.name.value);
	var strPhone = new String(objForm.phone.value);
	var strFax= new String(objForm.fax.value);
	var strAddress = new String(objForm.address.value);
	// house
	var strHouseYearBuilt = new String(objForm.house_year_built.value);
	var strHouse_no_units = new String(objForm.house_no_units.value);
	var strArea_home = new String(objForm.area_home.value);
	var strExcess_value_house = new String(objForm.excess_value_house.value);
	var strHouse_claim_free_year = new String(objForm.house_claim_free_year.value);
	var strHouse_claim_details = new String(objForm.house_claim_details.value);
	var strHouse_replacement_value = new String(objForm.house_replacement_value.value);
	// contents
	var strValue_content = new String(objForm.value_content.value);
	var strExcess_value_content = new String(objForm.excess_value_content.value);
	var strClaim_free_year = new String(objForm.claim_free_year.value);
	var strContent_claim_details = new String(objForm.content_claim_details.value);
	// motor vehicle
	var strYear_model_motor = new String(objForm.year_model_motor.value);
	var strSum_insured_motor = new String(objForm.sum_insured_motor.value);
	var strMotor_driver_age = new String(objForm.motor_driver_age.value);
	var strMotor_engine_size = new String(objForm.motor_engine_size.value);
	var strMotor_license_details = new String(objForm.motor_license_details.value);
	var strMotor_previous_insurance = new String(objForm.motor_previous_insurance.value);
	var strCover_type = new String(objForm.cover_type.value);
	var strMotor_claim_details = new String(objForm.motor_claim_details.value);
	// classic cars
	var strYear_model_classic = new String(objForm.year_model_classic.value);
	var strClassic_sum_insured = new String(objForm.classic_sum_insured.value);
	var strClassic_driver_age = new String(objForm.classic_driver_age.value);
	var strReasons_not_fit_criteria = new String(objForm.reasons_not_fit_criteria.value);
	// boat
	var strBoat_built_year = new String(objForm.boat_built_year.value);
	var strBoat_make = new String(objForm.boat_make.value);
	var strBoat_name = new String(objForm.boat_name.value);
	var strBoat_value = new String(objForm.boat_value.value);
	var strBoat_construction = new String(objForm.boat_construction.value);
	var strBoat_speed = new String(objForm.boat_speed.value);
	var strBoat_length = new String(objForm.boat_length.value);
	// travel
	var strDestination = new String(objForm.destination.value);
	var strDate_leaving = new String(objForm.date_leaving.value);
	var strDate_returning = new String(objForm.date_returning.value);
	var strExcess = new String(objForm.excess.value);
	// general
	var strComments = new String(objForm.comments.value);
	
	// check all compulsory fields to see if empty
	if (strName.length == 0) {
		strEmptyMsg += " --> Name\n";
		intErrors++;
	}
	if (strPhone.length == 0) {
		strEmptyMsg += " --> Phone\n";
		intErrors++;
	}
	// check all fields to see if they contain disallowed characters
	validate(strName, 'Name');
	validate(strPhone, 'Phone');
	validate(strFax, 'Fax');
	validate(strAddress, 'Address');
	// house
	validate(strHouseYearBuilt, 'Year built');
	validate(strHouse_no_units, 'No of units');
	validate(strArea_home, 'Area of home');
	validate(strExcess_value_house, 'Excess');
	validate(strHouse_claim_free_year, 'Claim free years');
	validate(strHouse_claim_details, 'Details');
	validate(strHouse_replacement_value, 'Replacement value');
	// contents
	validate(strValue_content, 'Value of content');
	validate(strExcess_value_content, 'Excess');
	validate(strClaim_free_year, 'Claim free years');
	validate(strContent_claim_details, 'Details');
	// motor vehicle
	validate(strYear_model_motor, 'Year, Make & Model');
	validate(strSum_insured_motor, 'Sum insured for');
	validate(strMotor_driver_age, 'Age of main driver');
	validate(strMotor_engine_size, 'Engine size');
	validate(strMotor_license_details, 'License details');
	validate(strMotor_previous_insurance, 'Previous insurance');
	validate(strCover_type, 'Type of cover required');
	validate(strMotor_claim_details, 'Any accidents, claims, convictions');
	// classic cars
	validate(strYear_model_classic, 'Year, Make & Model');
	validate(strClassic_sum_insured, 'Sum insured for');
	validate(strClassic_driver_age, 'Age of main driver');
	validate(strReasons_not_fit_criteria, 'Details');
	// boat
	validate(strBoat_built_year, 'Year built');
	validate(strBoat_make, 'Make');
	validate(strBoat_name, 'Name');
	validate(strBoat_value, 'Value');
	validate(strBoat_construction, 'Construction');
	validate(strBoat_speed, 'Speed');
	validate(strBoat_length, 'Length');
	// travel
	validate(strDestination, 'Where are you going');
	validate(strDate_leaving, 'Leaving date');
	validate(strDate_returning, 'Returning date');
	validate(strExcess, 'Excess');
	// general
	validate(strComments, 'Comments');
	
	// checking any checboxes which need to be checked
	if (objForm.consent.checked != true) {
	strEmptyMsg += " --> Please tick the consent checkbox\n";
	intErrors++
	}
	
	// if there are any errors show these
	if(intErrors > 0) {
		var message = '';
		if(strEmptyMsg != '') message = message + "Please fill in the following fields:\n" + strEmptyMsg + "\n";
		if(strErrorMsg != '') message = message + "Please remove the characters : ; or @ and any instances of 'http' in the following fields:\n" + strErrorMsg + "\n";
		
		alert(message);
		return false;
	} else {
		// return true if all ok and send email
		return true;
	}

}

function checkhouse() {
	if (document.contact.house_insurance.checked)
		{ document.getElementById('houseinsurance').style.display='block'; }
	else { document.getElementById('houseinsurance').style.display='none'; }					 
}

function checkcontents() {
	if (document.contact.content_insurance.checked)
		{ document.getElementById('contentinsurance').style.display='block'; }
	else { document.getElementById('contentinsurance').style.display='none'; }
}

function checkmotor() {
	if (document.contact.motor_vehicle_insurance.checked)
		{ document.getElementById('motorinsurance').style.display='block'; }
	else { document.getElementById('motorinsurance').style.display='none'; } 
}

function checkclassic() {
	if (document.contact.classic_cars_insurance.checked)
		{ document.getElementById('classicinsurance').style.display='block'; }
	else { document.getElementById('classicinsurance').style.display='none'; }
}

function checkboat() {
	if (document.contact.boat_insurance.checked)
		{ document.getElementById('boatinsurance').style.display='block'; }
	else {  document.getElementById('boatinsurance').style.display='none'; }					 
}

function checktravel() {
	if (document.contact.travel_insurance.checked)
		{ document.getElementById('travelinsurance').style.display='block'; }
	else { document.getElementById('travelinsurance').style.display='none'; }
}