
// clear postcode ////////////////////////////////////////////////////////////////////////
function clearPostcode () { //document.write ("HERE");
var ui = document.fPostcode.user_input.value; 
if (ui == "Postcode") {
	document.fPostcode.user_input.value = ""; return false;
}
}



// check postcode (search) ////////////////////////////////////////////////////////////////////
function checkPostcode () { //document.write ("HERE");

var ui = document.fPostcode.user_input.value; 
var illegalChars= /[\(\)\<\>\,\.\;\:\\\/\"\[\]]/

if (ui.match(illegalChars)) {
	alert("Please enter a valid postcode"); document.fPostcode.user_input.focus(); return false;
	} else {
	return true;
}
return false;
}


// check contact form //////////////////////////////////////////////////////////////////////////
function checkContactForm() { //document.write ("HERE");

// check name has been entered
if (document.fContact.ui_name.value.length < 1) {
	alert("Please enter your name"); document.fContact.ui_name.focus(); return false;}

// check email has been entered	
if (document.fContact.ui_email.value.length < 1) {
	alert("Please enter your email address"); document.fContact.ui_email.focus(); return false;}

var emailFilter=/^.+@.+\..+$/
var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
var e = document.fContact.ui_email.value;

// test structure of email address
if (!(emailFilter.test(e))) { alert("Please enter a valid email address"); document.fContact.ui_email.focus(); return false;}

// check email contains no illegal characters
if (e.match(illegalChars)) {alert("Please enter a valid email address"); document.fContact.ui_email.focus(); return false;}

// check enquiry has been entered	
if (document.fContact.ui_enquiry.value.length < 1) {
	alert("Please enter your enquiry"); document.fContact.ui_enquiry.focus(); return false;}

// check captcha code has been entered
if (document.fContact.ui_captcha.value.length < 1) {
	alert("Please enter the security letters"); document.fContact.ui_captcha.focus(); return false;}
	
// check captcha code is correct
captcha = document.fContact.captcha.value;
uic = document.fContact.ui_captcha.value; uic = uic.toUpperCase();
if (captcha == "1" && uic != "COACH") {	alert("Incorrect Security Code! Please try again."); document.fContact.ui_captcha.focus(); return false;}
if (captcha == "2" && uic != "FERRY") {	alert("Incorrect Security Code! Please try again."); document.fContact.ui_captcha.focus(); return false;}
if (captcha == "3" && uic != "HOTEL") {	alert("Incorrect Security Code! Please try again."); document.fContact.ui_captcha.focus(); return false;}
if (captcha == "4" && uic != "PLANE") {	alert("Incorrect Security Code! Please try again."); document.fContact.ui_captcha.focus(); return false;}
if (captcha == "5" && uic != "TRAIN") {	alert("Incorrect Security Code! Please try again."); document.fContact.ui_captcha.focus(); return false;}
if (captcha == "6" && uic != "TRUCK") {	alert("Incorrect Security Code! Please try again."); document.fContact.ui_captcha.focus(); return false;}

}


// reset contact form //////////////////////////////////////////////////////////////////////////
function resetContactForm() { //document.write ("HERE");

document.fContact.ui_name.value =""; 
document.fContact.ui_email.value =""; 
document.fContact.ui_enquiry.value =""; 
document.fContact.ui_name.focus(); 
return false;

}




// check join form //////////////////////////////////////////////////////////////////////////
function checkJoinForm() { //document.write ("HERE");

// check requried fields have been entered
if (document.fJoin.ui_service.value == "none") {alert("Please choose a service"); document.fJoin.ui_service.focus(); return false;}
if (document.fJoin.ui_company.value.length < 1) {alert("Please enter your company name"); document.fJoin.ui_company.focus(); return false;}
if (document.fJoin.ui_address1.value.length < 1) {alert("Please enter your address"); document.fJoin.ui_address1.focus(); return false;}
if (document.fJoin.ui_town.value.length < 1) {alert("Please enter a town"); document.fJoin.ui_town.focus(); return false;}
if (document.fJoin.ui_county.value.length < 1) {alert("Please enter a county"); document.fJoin.ui_county.focus(); return false;}
if (document.fJoin.ui_postcode.value.length < 1) {alert("Please enter your postcode"); document.fJoin.ui_postcode.focus(); return false;}

// check valid postcode

//var ui = document.fPostcode.user_input.value; 
var illegalChars= /[\(\)\<\>\,\.\-\_\=\+\!\£\$\%\^\&\*\{\}\@\'\#\~\?\;\:\\\/\"\[\]]/
if (document.fJoin.ui_postcode.value.match(illegalChars)) {
	alert("Please enter a valid postcode"); 
	document.fJoin.ui_postcode.value = "";
	document.fJoin.ui_postcode.focus();
	return false;
}

// if email has been entered, check it is valid
var e = document.fJoin.ui_email.value;
if (e != "" && e != "NULL") {
	var emailFilter=/^.+@.+\..+$/
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
	// test structure of email address
	if (!(emailFilter.test(e))) { alert("Please enter a valid email address"); document.fJoin.ui_email.focus(); return false;}
	// check email contains no illegal characters
	if (e.match(illegalChars)) {alert("Please enter a valid email address"); document.fJoin.ui_email.focus(); return false;}
}

// check captcha code has been entered
if (document.fJoin.ui_captcha.value.length < 1) {
	alert("Please enter the security letters"); document.fJoin.ui_captcha.focus(); return false;}
	
// check captcha code is correct
captcha = document.fJoin.captcha.value;
uic = document.fJoin.ui_captcha.value; uic = uic.toUpperCase();
if (captcha == "1" && uic != "COACH") {	alert("Incorrect Security Code! Please try again."); document.fJoin.ui_captcha.focus(); return false;}
if (captcha == "2" && uic != "FERRY") {	alert("Incorrect Security Code! Please try again."); document.fJoin.ui_captcha.focus(); return false;}
if (captcha == "3" && uic != "HOTEL") {	alert("Incorrect Security Code! Please try again."); document.fJoin.ui_captcha.focus(); return false;}
if (captcha == "4" && uic != "PLANE") {	alert("Incorrect Security Code! Please try again."); document.fJoin.ui_captcha.focus(); return false;}
if (captcha == "5" && uic != "TRAIN") {	alert("Incorrect Security Code! Please try again."); document.fJoin.ui_captcha.focus(); return false;}
if (captcha == "6" && uic != "TRUCK") {	alert("Incorrect Security Code! Please try again."); document.fJoin.ui_captcha.focus(); return false;}

}


// reset join form //////////////////////////////////////////////////////////////////////////
function resetJoinForm() { //document.write ("HERE");

document.fJoin.ui_company.value =""; 
document.fJoin.ui_address1.value =""; 
document.fJoin.ui_address2.value =""; 
document.fJoin.ui_address3.value =""; 
document.fJoin.ui_town.value =""; 
document.fJoin.ui_county.value =""; 
document.fJoin.ui_postcode.value =""; 
document.fJoin.ui_telephone.value =""; 
document.fJoin.ui_email.value =""; 
document.fJoin.ui_company.focus(); 
return false;

}