	
function CheckForm() {
	var errorMsg = "";

	// Check first name
	if (document.Form.firstname.value == "" || document.Form.firstname.value == "-"){
		errorMsg += "\n\tFirst Name \t- Enter your First Name";	
	}
	
	//Check last name
	if (document.Form.lastname.value == "" || document.Form.lastname.value == "-"){
		errorMsg += "\n\tLast Name \t- Enter your Last Name";
	}
	
	// Check address
	if (document.Form.house.value == "" || document.Form.house.value == "-"){
		errorMsg += "\n\tAddress \t- Enter your Address";	
	}
	
	// Check Town/City
	if (document.Form.town.value == "" || document.Form.town.value == "-"){
		errorMsg += "\n\tTown \t- Enter your Town";	
	}
	
	// Check first name
	if (document.Form.postcode.value == "" || document.Form.postcode.value == "-"){
		errorMsg += "\n\tPost Code \t- Enter your Post Code";	
	}
	 
	//Check for an e-mail address and that it is valid
	if ((document.Form.email.value == "") || (document.Form.email.value.length > 0 && (document.Form.email.value.indexOf("@",0) == - 1 || document.Form.email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tE-mail Address \t- Enter your valid e-mail address";
	}
	
	//Check Password is valid
	if (document.Form.password.value == "" || document.Form.password.value == "-" || document.Form.password.value.length < 6){
		errorMsg += "\n\tPassword \t- Enter a valid Password.(It must have a minimum of 6 characters.)";
	}
	
	//Check Confirm Password is valid
	if (document.Form.password.value != document.Form.confirmpassword.value ) {
		errorMsg += "\n\tPassword \t- Your password and confirm password are different!!";
	}
			
	
	//If there is aproblem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Your registration has not been sent because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "______________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: \n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	return true;
}

function CheckContactForm() {
	var errorMsg = "";

	// Check first name
	if (document.Form.name.value == "" || document.Form.name.value == "-"){
		errorMsg += "\n\tName \t- Enter your Name";	
	}
	
	//Check for an e-mail address and that it is valid
	if ((document.Form.email.value == "") || (document.Form.email.value.length > 0 && (document.Form.email.value.indexOf("@",0) == - 1 || document.Form.email.value.indexOf(".",0) == - 1))) { 
		errorMsg += "\n\tE-mail Address \t- Enter a valid e-mail address";
	}
	
	//If there is aproblem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Your enquiry has not been sent because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "______________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: \n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		
	}
	else {
		document.Form.submit()
	}
}



function CheckFormDelivery() {
	var errorMsg = "";

	// Check first name
	if (document.Form.firstname.value == "" || document.Form.firstname.value == "-"){
		errorMsg += "\n\tFirst Name \t- Enter your First Name";	
	}
	
	//Check last name
	if (document.Form.lastname.value == "" || document.Form.lastname.value == "-"){
		errorMsg += "\n\tLast Name \t- Enter your Last Name";
	}
	
	//Check address
	if (document.Form.house.value == "" || document.Form.house.value == "-"){
		errorMsg += "\n\tAddress \t- Enter your Address";
	}
	
	//Check city/town
	if (document.Form.town.value == "" || document.Form.town.value == "-"){
		errorMsg += "\n\tTown \t- Enter your City/Town";
	}
	
	//Check post code
	if (document.Form.postcode.value == "" || document.Form.postcode.value == "-"){
		errorMsg += "\n\tPostCode \t- Enter your Zip/PostCode";
	}
	 
	
	//If there is aproblem with the form then display an error
	if (errorMsg != ""){
		msg = "______________________________________________________________\n\n";
		msg += "Your delivery information has not been changed because there are problem(s) with the form.\n";
		msg += "Please correct the problem(s) and re-submit the form.\n";
		msg += "______________________________________________________________\n\n";
		msg += "The following field(s) need to be corrected: \n";
		
		errorMsg += alert(msg + errorMsg + "\n\n");
		return false;
	}
	
	return true;
}


function submitForm(){
	if (document.termsForm.boxchecked.checked) {
		document.cpiForm.submit();
	}
	else {
		errorMsg = "______________________________________________________________\n\n";
		errorMsg += "You must read, accept and agree to our conditions before proceeding. \n";
		errorMsg += "Please tick the box to confirm and proceed.\n";
		errorMsg += "______________________________________________________________\n\n";
		alert (errorMsg);
	}
}




