// Scripts by kev (at) technotik (dot) com
// Copyright technotik.com
// unless stated otherwise in comments


function duplicateAddress(thisForm) {
// fill in delivery address details
	thisForm.delivery_address1.value = thisForm.address1.value;
	thisForm.delivery_address2.value = thisForm.address2.value;
	thisForm.delivery_address3.value = thisForm.address3.value;
	
	thisForm.delivery_post_town.value = thisForm.post_town.value;
	thisForm.delivery_county.value = thisForm.county.value;
	thisForm.delivery_post_code.value = thisForm.post_code.value;
} // end duplicateAddress()


function clearAddress(thisForm) {
// clear delivery address details
// NOT SURE ABOUT THIS
/*	
	thisForm.delivery_address1.value = "";
	thisForm.delivery_address2.value = "";
	thisForm.delivery_address3.value = "";
	
	thisForm.delivery_post_town.value = "";
	thisForm.delivery_county.value = "";
	thisForm.delivery_post_code.value = "";
*/
	thisForm.delivery_address1.focus();
} // end clearAddress()


function validateCheckout(thisForm) {
/*
	if(thisForm.delivery_add[1].checked)
		duplicateAddress(thisForm);
*/
	
	if(isBlank(thisForm.last_name.value)) {
		alert("Please enter your last name");
		thisForm.last_name.focus();
		return false;
	}
	else if(isBlank(thisForm.email.value)) {
		alert("Please enter your email address");
		thisForm.email.focus();
		return false;
	}
	else if(isBlank(thisForm.address1.value)) {
		alert("Please enter your address");
		thisForm.address1.focus();
		return false;
	}
	else if(isBlank(thisForm.post_town.value)) {
		alert("Please enter your post town");
		thisForm.post_town.focus();
		return false;
	}
	else if(isBlank(thisForm.county.value)) {
		alert("Please enter your county");
		thisForm.county.focus();
		return false;
	}
	else if(isBlank(thisForm.post_code.value) && (thisForm.zone.options[thisForm.zone.selectedIndex].value < 3)) {
		alert("Please enter your post code");
		thisForm.post_code.focus();
		return false;
	}
/*
	else if(isBlank(thisForm.delivery_address1.value)) {
		alert("Please enter your delivery address");
		thisForm.delivery_address1.focus();
		return false;
	}
	else if(isBlank(thisForm.delivery_post_town.value)) {
		alert("Please enter your delivery post town");
		thisForm.delivery_post_town.focus();
		return false;
	}
	else if(isBlank(thisForm.delivery_county.value)) {
		alert("Please enter your delivery county");
		thisForm.delivery_county.focus();
		return false;
	}
	else if(isBlank(thisForm.delivery_post_code.value) && (thisForm.zone.options[thisForm.zone.selectedIndex].value < 3)) {
		alert("Please enter your delivery post code");
		thisForm.delivery_post_code.focus();
		return false;
	}
*/
	else 
		return true;
} // end validateCheckout()


function validateRegister(thisForm) {
	
	if(thisForm.email.value.length < 9) {
		alert("Please enter your email address");
		thisForm.email.focus();
		return false;
	}
	else if(thisForm.pass1.value.length < 6) {
		alert("Please enter a value for password at least six characters long");
		thisForm.pass1.focus();
		return false;
	}
	else if(thisForm.pass2.value.length < 6) {
		alert("Please re-type password");
		thisForm.pass2.focus();
		return false;
	}
	else if(thisForm.pass1.value != thisForm.pass2.value) {
		alert("Please re-enter both passwords");
		thisForm.pass1.focus();
		return false;
	}
	else if(isBlank(thisForm.last_name.value)) {
		alert("Please enter your last name");
		thisForm.last_name.focus();
		return false;
	}
	else if(isBlank(thisForm.address1.value)) {
		alert("Please enter your address");
		thisForm.address1.focus();
		return false;
	}
	else if(isBlank(thisForm.post_town.value)) {
		alert("Please enter your post town");
		thisForm.post_town.focus();
		return false;
	}
	else if(isBlank(thisForm.post_code.value) && (thisForm.zone.options[thisForm.zone.selectedIndex].value < 3)) {
		alert("Please enter your post code");
		thisForm.post_code.focus();
		return false;
	}	

	return true;
} // end validateRegister()


function validateEditCustomer(thisForm) {
	
	if(thisForm.email.value.length < 9) {
		alert("Please enter your email address");
		thisForm.email.focus();
		return false;
	}
	else if(thisForm.pass1.value.length < 6) {
		alert("Please enter a value for password at least six characters long");
		thisForm.pass1.focus();
		return false;
	}
	else if(isBlank(thisForm.last_name.value)) {
		alert("Please enter your last name");
		thisForm.last_name.focus();
		return false;
	}
	else if(isBlank(thisForm.address1.value)) {
		alert("Please enter your address");
		thisForm.address1.focus();
		return false;
	}
	else if(isBlank(thisForm.post_town.value)) {
		alert("Please enter your post town");
		thisForm.post_town.focus();
		return false;
	}
	else if(isBlank(thisForm.post_code.value) && (thisForm.zone.options[thisForm.zone.selectedIndex].value < 3)) {
		alert("Please enter your post code");
		thisForm.post_code.focus();
		return false;
	}	

	return true;
} // end validateEditCustomer()
