var tl_loc0=(window.location.protocol == "https:")? "https://secure.comodo.net/trustlogo/javascript/trustlogo.js" : "http://www.trustlogo.com/trustlogo/javascript/trustlogo.js";
document.writeln('<scr' + 'ipt language="JavaScript" src="'+tl_loc0+'" type="text\/javascript">' + '<\/scr' + 'ipt>');



function liability(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var res = document.getElementById("quotewindow");	
	var thetime = "?thetime="+new Date().getTime();
	var thestring = '';
	var numpeople = parseFloat(document.forms.liabilityform.manual_emp.value) + parseFloat(document.forms.liabilityform.clerical_emp.value);
	
	if (numpeople > 10){
		res.innerHTML = '';
		alert('You cannot insure more than ten people under this type of policy');
	} else {
		try {
			if (document.forms.liabilityform.the_occupation) {
				var thestring = thestring+"&the_occupation="+document.forms.liabilityform.the_occupation.value
			}
		} catch (err) {}
		try {
			if (document.forms.liabilityform.manual_pub) {
				var thestring = thestring+"&manual_pub="+document.forms.liabilityform.manual_pub.value
			}
		} catch (err) {}
		try {
			if (document.forms.liabilityform.cover_value) {
				var thestring = thestring+"&cover_value="+document.forms.liabilityform.cover_value.value
			}
		} catch (err) {}
		try {
			if (document.forms.liabilityform.public_claim) {
				var thestring = thestring+"&public_claim="+document.forms.liabilityform.public_claim.value
			}
		} catch (err) {}
		try {
			if (document.forms.liabilityform.manual_emp) {
				var thestring = thestring+"&manual_emp="+document.forms.liabilityform.manual_emp.value
			}
		} catch (err) {}
		try {
			if (document.forms.liabilityform.clerical_emp) {
				var thestring = thestring+"&clerical_emp="+document.forms.liabilityform.clerical_emp.value
			}
		} catch (err) {}		

		try {
			if (document.forms.liabilityform.employee_claim) {
				var thestring = thestring+"&employee_claim="+document.forms.liabilityform.employee_claim.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.liabilityform.convictions) {
				var thestring = thestring+"&convictions="+document.forms.liabilityform.convictions.value
			}
		} catch (err) {}		
	
		try {
			if (document.forms.liabilityform.the_country) {
				var thestring = thestring+"&the_country="+document.forms.liabilityform.the_country.value
			}
		} catch (err) {}
		
		liveSearchReq.open("GET","liability_price.html"+thetime+thestring,false);
		liveSearchReq.send(null);
	
		if (liveSearchReq.readyState == 4) {
			res.innerHTML = liveSearchReq.responseText;
		}
		scrollTo(0,2000);
	}
}


function getaddress(){
	scrollTo(0,520);	

	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var res = document.getElementById("pgcontent");	
	var thetime = "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","address_details.html"+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		res.innerHTML = liveSearchReq.responseText;
	}
}



function saveaddy(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if(document.forms.addressform.firstname.value == '' | document.forms.addressform.surname.value == '' | document.forms.addressform.comp_name.value == '' | document.forms.addressform.comp_landline.value == '' | document.forms.addressform.comp_mobile.value == '' | document.forms.addressform.comp_email.value == '' | document.forms.addressform.address1.value == '' | document.forms.addressform.address_town.value == '' | document.forms.addressform.address_county.value == ''  | document.forms.addressform.address_postcode.value == ''){
		alert('Please complete all the required fields.\n\nRequired fields are marked with asteriks (*)');
	}else{
		var res = document.getElementById("pgcontent");	
		var thetime = "?thetime="+new Date().getTime();
		var thestring = '';
	
		try {
			if (document.forms.addressform.titlename) {
				var thestring = thestring+"&titlename="+document.forms.addressform.titlename.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.firstname.value) {
				var thestring = thestring+"&firstname="+document.forms.addressform.firstname.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.surname.value) {
				var thestring = thestring+"&surname="+document.forms.addressform.surname.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.comp_name.value) {
				var thestring = thestring+"&comp_name="+document.forms.addressform.comp_name.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.comp_type) {
				var thestring = thestring+"&comp_type="+document.forms.addressform.comp_type.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.comp_landline.value) {
				var thestring = thestring+"&comp_landline="+document.forms.addressform.comp_landline.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.comp_mobile.value) {
				var thestring = thestring+"&comp_mobile="+document.forms.addressform.comp_mobile.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.comp_email.value) {
				var thestring = thestring+"&comp_email="+document.forms.addressform.comp_email.value
			}
		} catch (err) {}
	
		try {
			if (document.forms.addressform.address1.value) {
				var thestring = thestring+"&address1="+document.forms.addressform.address1.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.address2.value) {
				var thestring = thestring+"&address2="+document.forms.addressform.address2.value
			} else (thestring = thestring+"&address2=")
		} catch (err) {}
		
		try {
			if (document.forms.addressform.address3.value) {
				var thestring = thestring+"&address3="+document.forms.addressform.address3.value
			} else (thestring = thestring+"&address3=")
		} catch (err) {}
		
		try {
			if (document.forms.addressform.address_town.value) {
				var thestring = thestring+"&address_town="+document.forms.addressform.address_town.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.address_county.value) {
				var thestring = thestring+"&address_county="+document.forms.addressform.address_county.value
			}
		} catch (err) {}

		try {
			if (document.forms.addressform.address_postcode.value) {
				var thestring = thestring+"&address_postcode="+document.forms.addressform.address_postcode.value
			}
		} catch (err) {}
		
		try {
			if (document.forms.addressform.address_country.value != 'XXXXX') {
				var thestring = thestring+"&address_country="+document.forms.addressform.address_country.value
			} else {
				var stopit = true;
			}
		} catch (err) {}
		
		if (stopit) {
			alert('We can only sell insurance in UK Territories.\n\nWe cannot insure you if you are outside these territories.');
		} else {
			liveSearchReq.open("GET","save_addy.html"+thetime+thestring,false);
			liveSearchReq.send(null);

			if (liveSearchReq.readyState == 4) {
				res.innerHTML = liveSearchReq.responseText;
			}
		}
	}
}


function checkrequired(){
	if (document.forms.theform.name.value == '' | document.forms.theform.address.value == '' | document.forms.theform.postcode.value == '' | document.forms.theform.tel.value == '' | document.forms.theform.email.value == '' | document.forms.theform.dob.value == '' | document.forms.theform.insureday.value == '' | document.forms.theform.insuremonth.value == '' | document.forms.theform.insureyear.value == '') {
		alert('Required data missing.  Please complete all required fields.');
		scrollTo(0,0);
		return false;
	} else {
		return true;
	}
}

function checkcover() {
	var res = document.getElementById("extraqs");	
	
	if (document.forms.theform.car_cover_type.value == 'named_drivers') {
		// add extra fields for another person
		if (window.XMLHttpRequest) {
			liveSearchReq = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
		}
		

		var thetime = "?thetime="+new Date().getTime();
		liveSearchReq.open("GET","more_qs.html"+thetime,false);
		liveSearchReq.send(null);
	
		if (liveSearchReq.readyState == 4) {
			res.innerHTML = liveSearchReq.responseText;
		}
		alert('If you need more than 2 named drivers on your policy please call us.\nThank you.')
	} else {
		res.innerHTML = '';
	}
}


function alternatepay(){
	if (window.XMLHttpRequest) {
		liveSearchReq = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var res = document.getElementById("alternate");	
	var thetime = "?thetime="+new Date().getTime();
	liveSearchReq.open("GET","alternate_pay.html"+thetime,false);
	liveSearchReq.send(null);

	if (liveSearchReq.readyState == 4) {
		res.innerHTML = liveSearchReq.responseText;
	}
}
