
function sendCV() {
 oForm = document.submitCV;
 oForm2 = document.submitCVCV;
 
 if (oForm.name.value == "") {
 	alert("Please enter your name")
	oForm.name.focus();
 } else if (oForm.email.value == "" || !validateEmail(oForm.email.value)) {
 	alert("Please enter a valid email address")
	oForm.email.focus();
 } else if (oForm.division.value == "") {
 	alert("Please select the division you are intersted in")
	oForm.division.focus();
 } else if (oForm2.file.value == "") {
 	alert("Please press browse and select your C.V.")
	oForm2.file.focus();
 } else if (oForm.h_formValidated.value != "true") {
 	alert("To prevent SPAM we require you to manually enter your name")
	oForm.name.focus();
 } else {
 		oForm2.action += "?h_formValidated=" + oForm.h_formValidated.value +
			"&name=" + oForm.name.value +
			"&email=" + oForm.email.value +
			"&telephone=" + oForm.telephone.value +
			"&division=" + oForm.division[oForm.division.selectedIndex].value;
		
		$("#loadingAni").show().next("form").css("opacity","0.35");
		// return false;

		oForm2.submit();
 }
}

function verifyAppForm() {
 oForm = document.appForm;
 oForm2 = document.appFormCV;
 
 if (oForm.name.value == "") {
 	alert("Please enter your name")
	oForm.name.focus();
 } else if (oForm.email.value == "" || !validateEmail(oForm.email.value)) {
 	alert("Please enter a valid email address")
	oForm.email.focus();
 } else if (oForm2.file.value == "") {
 	alert("Please press browse and select your C.V.")
	oForm2.file.focus();
 } else if (oForm.h_formValidated.value != "true") {
 	alert("To prevent SPAM we require you to manually enter your name")
	oForm.name.focus();
 } else {
 		oForm2.action += "?h_formValidated=" + oForm.h_formValidated.value +
			"&contact=" + oForm.contact.value +
			"&vacancyTitle=" + oForm.vacancyTitle.value +
			"&vacancyRef=" + oForm.vacancyRef.value +
			"&name=" + oForm.name.value +
			"&email=" + oForm.email.value +
			"&telephone=" + oForm.telephone.value +
			"&coverNote=" + oForm.coverNote.value
		
		$("#loadingAni").show().next("form").css("opacity","0.35");
		// return false;

		oForm2.submit();
 }
}


function register() {
	oForm = document.regForm;
	oForm2 = document.regFormCV;

	if (oForm.fname.value == "") {
		alert("You must enter your forename(s).");
		oForm.fname.focus();
	} else if (oForm.sname.value == "") {
		alert("You must enter your surname.");
		oForm.sname.focus();
	} else if (oForm.email.value == "") {
		alert("You must enter a valid email address");
		oForm.email.focus();
	} else if (oForm.password.value == "") {
		alert("Please enter a password.");
		oForm.password.focus();
	} else if (oForm.password.value != oForm.password2.value) {
		alert("Your Passwords do not match, please re-type them.");
		oForm.password.focus();
	} else {

		oForm2.action += "?h_formValidated=" + oForm.h_formValidated.value +
			"&fname=" + oForm.fname.value +
			"&sname=" + oForm.sname.value +
			"&Address=" + oForm.Address.value +
			"&postcode=" + oForm.postcode.value +
			"&tel=" + oForm.tel.value +
			"&email=" + oForm.email.value +
			"&password=" + oForm.password.value
		
		$("#loadingAni").show().next("form").css("opacity","0.35");
		// return false;

		oForm2.submit();
	}
}


function validateEmail(email_address) {
	if (/\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email_address)){
		return true;
	}
	return false;
}