// Copyright Darren Crabb DG Newmedia Ltd.

function mailme() {
window.location="mailto:?Subject=I thought this page might be of interest to you&Body="+window.location;
}

function makenew(filename, width, height) {
	window.open(filename, "blank", "toolbar=no, scrollbars=yes, width=" + width + ", height=" + height + "")
}

function validate_required(field,alerttxt) {
	with (field) {
		if (value==null||value=="") {
			alert(alerttxt);
			return false
		} else {
			return true
		}
	}
}
function validate_form(thisform) {
	with (thisform) {
		if (validate_required(phone,"Please enter your phone number!")==false) {
		phone.focus();return false
		}
	}
}

function intschoolsphc() {
	
	form = this.document.pmhc;
	
	if (form.firstname.value == "" || form.firstname.value == "") {
		alert("Please state your first name!"); form.firstname.focus(); return false; 
	}
		
	if (form.surname.value == "" || form.surname.value == "") {
		alert("Please state your surname!"); form.surname.focus(); return false; 		
	}	
	
	if (form.telephone.value == "" || form.telephone.value == "") {
		alert("Please state your telephone number!"); form.telephone.focus(); return false; 		
	}	
	
	if (form.email.value == "" || form.email.value == "") {
		alert("Please state your email address!"); form.email.focus(); return false; 		
	}	
	
	if (form.country.value == "" || form.country.value == "") {
		alert("Please state your country!"); form.country.focus(); return false; 		
	}	
	
	if (form.nationality.value == "" || form.nationality.value == "") {
		alert("Please state your nationality!"); form.nationality.focus(); return false; 		
	}	
	
	if (form.position.value == "" || form.position.value == "") {
		alert("Please state your position or job title!"); form.position.focus(); return false; 		
	}		
	
	if (form.name1.value == "" || form.name1.value == "") {
		alert("Please enter at least 1 person to be insured!"); form.name1.focus(); return false; 		
	}	
	
	if (form.dob1.value == "" || form.dob1.value == "") {
		alert("Please enter at least 1 person to be insured!"); form.dob1.focus(); return false; 		
	}	
	if (form.area.value == "" || form.area.value == "") {
		alert("Please state which area of cover you require!"); form.area.focus(); return false; 		
	}	
	return true;
}

function validateLifeForm() {
        form = this.document.form1;
        if (form.email == "" || form.Telephone == "") {
                alert("Please provide at least a telephone number or your email address.");
        return false
        } else {
                return true; 
        }
}

function validatePet() {
	form = this.document.form1;
	if(form.title.value == ""){ alert("Please state your Title."); form.title.focus(); return false; }
	if(form.fname.value == ""){ alert("Please state your First name."); form.fname.focus(); return false; }
	if(form.lname.value == ""){ alert("Please state your Last name."); form.lname.focus(); return false; }
	if(form.add1.value == ""){ alert("Please state your Address."); form.add1.focus(); return false; }
	if(form.postcode.value == ""){ alert("Please state your Postcode / BFPO number."); form.postcode.focus(); return false; }
	if(form.country.value == ""){ alert("Please state your Country of residence."); form.country.focus(); return false; }
	if(form.telephone.value == ""){ alert("Please state your Telephone."); form.telephone.focus(); return false; }
	if(form.name1.value == ""){ alert("Please state your Pet's name."); form.name1.focus(); return false; }
	if(form.type1.value == ""){ alert("Please state your Pet's type."); form.type1.focus(); return false; }
	if(form.breed1.value == ""){ alert("Please state your Pet's breed."); form.breed1.focus(); return false; }
	if(form.gender1.value == ""){ alert("Please state your Pet's gender."); form.gender1.focus(); return false; }
	if(form.dob1.value == ""){ alert("Please state your Pet's DOB."); form.dob1.focus(); return false; }
	if(form.price1.value == ""){ alert("Please state the Purchase price."); form.price1.focus(); return false; }
	return true;
}

function validateExpatHealth() {
	
	form = this.document.form1;
	
	if (form.title.value == "") {
		alert("Please state your Title!"); form.title.focus(); return false; 
	}
	if (form.name.value == "") {
		alert("Please state your Name!"); form.name.focus(); return false; 
	}
	if (form.dob.value == "") {
		alert("Please state your Date of birth!"); form.dob.focus(); return false; 
	}
	if (form.occupation.value == "") {
		alert("Please state your Occupation!"); form.occupation.focus(); return false; 
	}
	if (form.nationality.value == "") {
		alert("Please state your Nationality!"); form.nationality.focus(); return false; 
	}
	if (form.countryofresidence.value == "") {
		alert("Please state your Country of residence!"); form.countryofresidence.focus(); return false; 
	}
	if (form.countryofcover.value == "") {
		alert("Please state the country in which you require cover!"); form.countryofcover.focus(); return false; 
	}
	if (form.nationality.value == form.countryofresidence.value && form.countryofcover.value == form.nationality.value) {
		alert("We regret that we are unable to provide health insurance for those residing in their native country."); 
		return false; 
	}
	if (form.telephone.value == "") {
		alert("Please state a Daytime telephone number!"); form.telephone.focus(); return false; 
	}
	if (form.email.value == "") {
		alert("Please state your Email address!"); form.email.focus(); return false; 
	}
	if (form.area.value == "") {
		alert("Please select an Area of coverage!"); form.area.focus(); return false; 
	}
	if (form.policytype.value == "") {
		alert("Please select a Policy type!"); form.policytype.focus(); return false; 
	}
	if (form.policytype[1].checked && form.otherinsured.value == "") {
		alert("Please give details of all other persons to be insured!"); form.otherinsured.focus(); return false; 
	}
	if (form.policytype[2].checked && form.otherinsured.value == "") {
		alert("Please give details of all other persons to be insured!"); form.otherinsured.focus(); return false; 
	}
	if (form.policytype[3].checked && form.otherinsured.value == "") {
		alert("Please give details of all other persons to be insured!"); form.otherinsured.focus(); return false; 
	}	
	if (form.source.value == "") {
		alert("Please select a Source!"); form.source.focus(); return false; 
	}	
	if (form.source.value == "other" && form.other.value == "") {
		alert("Please state where you heard about JBI!"); form.other.focus(); return false; 
	}	
	//log referrer if any
	if(document.referrer != '') {
		var ref = document.getElementById('referrer');
		ref.value = document.referrer;
	}
	return true;
}

function validateWasons() {
		
	form = this.document.form1;
	
	if(form.title.value == "") {
		alert("Please state your title.");
		form.title.focus();
		return false;
	}
	if(form.fname.value == "") {
		alert("Please state your first name.");
		form.fname.focus();
		return false;
	}
	if(form.lname.value == "") {
		alert("Please state your last name.");
		form.lname.focus();
		return false;
	}
	if(form.country.value == "") {
		alert("Please state your country of residence.");
		form.country.focus();
		return false;
	}
	if(form.nationality.value == "") {
		alert("Please state your nationality.");
		form.nationality.focus();
		return false;
	}	
	if(form.country.value == form.nationality.value) {
		alert("Please note that we can not provide cover for those requiring coverage in their native country.");
		form.country.focus();
		return false;
	}	
	if(form.email.value == "") {
		alert("Please state your email address.");
		form.email.focus();
		return false;
	}
	if(form.email2.value == "") {
		alert("Please confirm your email address.");
		form.email2.focus();
		return false;
	}
	if(form.email.value != form.email2.value) {
		alert("Your confirmed email address does not match.");
		form.email2.focus();
		return false;
	}	
	if(form.source.value == "") {
		alert("Please state where you heard about us.");
		form.source.focus();
		return false;
	}	
	return true;
}

function fullbroker_form() {
	
	form = this.document.form1;
	
	if(form.title.value == "") {
		alert("Please state your title");
		form.title.focus();
		return false;
	}
	if(form.lastname.value == "") {
		alert("Please state your last name");
		form.lastname.focus();
		return false;
	}
	if(form.dobdd.value == "" || form.dobmm.value == "" || form.dobyyyy.value == "") {
		alert("Please complete your date of birth");
		return false;
	}
	if(form.occupation.value == "") {
		alert("Please state your occupation");
		form.occupation.focus();
		return false;
	}
	if(form.nationality.value == "") {
		alert("Please state your nationality");
		form.nationality.focus();
		return false;
	}
	if(form.countryresidence.value == "") {
		alert("Please state your country of residence");
		form.countryresidence.focus();
		return false;
	}
	if(form.countrycover.value == "") {
		alert("Please state the country in which you require coverage");
		form.countrycover.focus();
		return false;
	}
	if(form.nationality.value == form.countrycover.value) {
		alert("We regret that we can not offer insurance for residents in their home country.");
		return false;
	}
	if(form.email.value == "") {
		alert("Please enter your email address");
		form.email.focus();
		return false;
	}
	if(form.emailconf.value == "") {
		alert("Please confirm your email address");
		form.emailconf.focus();
		return false;
	}
	if(form.email.value != form.emailconf.value) {
		alert("The email addresses you have eneered do not match");
		form.emailconf.focus();
		return false;
	}
	if(form.policytype.value == "") {
		alert("Please state the policy type that you are interested in");
		form.policytype.focus();
		return false;
	}
	if(form.policytype.value == "Couple" || form.policytype.value == "Family") {
		if(form.otherinsured.value == ""){
			alert("Please gives names and dates of birth's for other applicants");
			form.otherinsured.focus();
			return false;
		}
	}
	if(form.medicalconditions[0].checked == 0 &&  form.medicalconditions[1].checked == 0) {
		alert("Please confirm whether you have any medical conditions");
		form.medicalconditions.focus();
		return false;
	}
}

function exphc_form() {
	
	form = this.document.form1;
	
	if(form.dobdd.value == "" || form.dobmm.value == "" || form.dobyyyy.value == "") {
		alert("Please complete your date of birth");
		return false;
	}
	if(form.nationality.value == "") {
		alert("Please state your nationality");
		return false;
	}
	if(form.countryresidence.value == "") {
		alert("Please state your country of residence");
		return false;
	}
	if(form.countrycover.value == "") {
		alert("Please state the country in which you require coverage");
		return false;
	}
	if(form.policytype.value == "") {
		alert("Please state the policy type");
		return false;
	}
	if(form.medicalconditions[0].checked == 0 &&  form.medicalconditions[1].checked == 0) {
		alert("Please confirm whether you have any medical conditions");
		return false;
	}
	return true;
}