<!-- Hide from old browsers

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function isValidEmail(strEmail){
	// This function returns true if the email is valid and false if not
	validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;

   // Search email text for regular expression matches
	if (strEmail.search(validRegExp) == -1) {return false;} 
	return true; 
}

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(forename,"Please provide your forename.")==false){
			forename.focus();return false}

		if (validate_required(surname,"Please provide your surname.")==false){
			surname.focus();return false}

		if (validate_required(email,"Please provide your e-mail address.")==false){
			email.focus();return false}

		if (!isValidEmail(email.value)){
			alert("Sorry but the e-mail address provided isn't valid.\n\nPlease check it and try again.");
			email.focus();return false;}

		if (email.value!=email2.value){
			alert("Sorry but the e-mail confirmation doesn't match the first one given.\n\nPlease check it and try again.");
			email2.focus();return false;}

		if (validate_required(username,"Please choose a username.")==false){
			username.focus();return false}

		if (username.value.length<6){
			alert("Sorry, but your username needs to be at least 6 characters long.");
			username.focus();
			return false;
		}

		if (validate_required(password,"Please choose a password.")==false){
			password.focus();return false}

		if (password.value.length<6){
			alert("Sorry, but your password needs to be at least 6 characters long.");
			password.focus();
			return false;
		}

		if ((hometel.value==''||hometel.value==null)&&(worktel.value==''||worktel.value==null)&&(mobiletel.value==''||mobiletel.value==null)){
			alert("Please provide at least one contact phone number, either a home, work or mobile number.");
			hometel.focus();
			return false;
		}

	}
}

function clearForm(){
  var r=confirm("Are you sure you want to remove all information from this form?\n\nClick 'OK' for yes or 'Cancel' for no.")
  if (r==true){
	document.forms[0].reset()
  }
  else{
    alert("You've chosen not to clear the form so please continue\nand click 'Submit enquiry' when ready.")
  }
}

// end script hide from old browsers -->