$(document).ready(function()
{

	$('#navigation li').hover(
		
		function () {
			$(this).addClass('sfhover');
		}, 
		function () {
			$(this).removeClass('sfhover');
		}
    );


});

function checkPrint() {
	if(window.print) {
		window.print();
	} else {
		alert("Sorry, your browser doesn't support this method of printing.\n\nPlease use your browsers print button instead.");
	}
}



function searchFocus() {
	if (document.forms.search.searchPhrase.value == 'Search') {
		document.forms.search.searchPhrase.value = '';
	}
}

function branchSearchFocus() {
 	if (document.forms.search.searchPhrasehome.value == 'Search') {
		document.forms.search.searchPhrasehome.value = '';
	}
}

<!--
// formObject javascript edition v.1.0
//
// Public Properties:
//
// versionString
// versionNumber
// getLastError
//
// Public Methods:
//
// validateEmail (email)
// validateAll (email, list of arguments to validate)
//
// Call like this:
// checkForm.validateAll(document.formName.email.value, document.formName.varName1.value, document.formName.varName2.value, etc...)

function FormObject () {
	//-----------------
	// Property init --
	//-----------------
	this.formObjversion = "formObject javascript edition v.1.0";
	this.formObjversionNum = 1.0;
	this.getLastError = 0;
	
	
	//----------------
	// Methods init --
	//----------------
	this.validateForm = validateForm; // Checks fields
	this.validateEmail = validateEmail; // Checks email address
	this.validateAll = validateAll; // Checks all fields, including email address
	this.formPass = formPass; // Method to execute if the form passes all the checks
	this.formFail = formFail; // Method to execute if the form fails the checks
	
//---------------------------------
// Define Methods for the object --
//---------------------------------


//---------------------------------//---------------------------------//---------------------------------//---------------------------------
	// Function that validates all the fields sent to it, including email address
	// The email address must be the first argument in the list
	function validateAll () {
		for (var i = 0; i < arguments.length; i++) { // Loops through all the arguments sent to the method
			if (this.validateForm(arguments[i]) == false) {;
				this.getLastError = "Please complete all the required fields"
				this.formFail(this.getLastError);
				return false;
			}
		}
		return this.validateEmail (arguments[0]);
		//return true;
	}

//---------------------------------//---------------------------------//---------------------------------//---------------------------------

	// Function to validate any number of fields. Checks for a value in passed variables.
	// Returns TRUE if email is valid and FALSE if not	
	function validateForm () {
		for (var i = 0; i < arguments.length; i++) { // Loops through all the arguments sent to the method
			if (arguments[i] == null || arguments[i] == "") { // Checks if current field is blank
				this.getLastError = "Please complete all the required fields"
				//this.formFail(this.getLastError);
				return false;
				
			}
		}
		this.getLastError = 0; // Reset the error property to 0
		//this.formPass(this.getLastError);
		return true;
	}
	
//---------------------------------//---------------------------------//---------------------------------//---------------------------------
	
	// Function to validate email address.
	// Returns TRUE if email is valid and FALSE if not
	function validateEmail (emailAddress) {
		var illegalChar = ["!","£","$","%","^","&","*","(",")","+","=","'",","] // List of illegal characters
		var illegalCharLength = illegalChar.length; // Number of illegal characters
		var emailLength = (emailAddress.length - 1); // Number of characters in email address. (-1 because charAt() works with array indexing beginning at 0 not 1)
		var atNumber = 0; // Number of "@" characters found
		var dotNumber = 0; // Number of "." characters found
		var charToCheck = 0; // Current character of email address being checked
		var illegalCharToCheck = 0; // Current array index of illegal character to check against
		
		// This section loops through the email and checks every char with '@', '.' or the 'illegalChar' array
		for (var i=0; i<= emailLength; i++) {
			charToCheck = emailAddress.charAt(i);
	
			if (charToCheck == "@") {
				atNumber++;
				if (atNumber > 1) {
					this.getLastError = "Please enter a valid email address"
					this.formFail(this.getLastError);
					return false;
				} else if (i == 0 || i == emailLength) {
					this.getLastError = "Please enter a valid email address"
					this.formFail(this.getLastError);
					return false;
				}

			} else if (charToCheck == ".") {
				dotNumber++;
				if (i == 0 || i == emailLength) {
					this.getLastError = "Please enter a valid email address"
					this.formFail(this.getLastError);
					return false;
				}
			}

			for (var n = 0; n <= illegalCharLength; n++) {
			//for (n in illegalChar) {
				illegalCharToCheck = illegalChar[n];
				if (illegalCharToCheck == charToCheck) {
					this.getLastError = "Please enter a valid email address"
					this.formFail(this.getLastError);
					return false;
				}
			}
		}

		// Finally, if everything in the above loop passes, we do a final check
		// to see that we have the right number of @s and .s
		if (atNumber == 1 && dotNumber >=1 ) { // one '@' and at least one '.'
			this.getLastError = 0; // Reset the error property to 0
			this.formPass(this.getLastError);
			return true;
		} else {
			this.getLastError = "Please enter a valid email address" 
			this.formFail(this.getLastError);
			return false;
		}
	}
	
//---------------------------------//---------------------------------//---------------------------------//---------------------------------
	
	
	// Code to execute if the form passes all the checks
	function formPass (lastError) {
		//alert("Form OK!\n\n" + lastError);
		return true;
	}

//---------------------------------//---------------------------------//---------------------------------//---------------------------------

	// Code to execute if the form fails the checks
	function formFail (lastError) {
		alert(lastError);
	}
	
	
} // END OF CLASS CODE


// Instantiate Object
checkForm = new FormObject();
	
//-->
// functiuons for tmg select fields
function toggleview(element1, view) {

   element1 = document.getElementById(element1);

   if ((element1.style.display == 'block' && view== 'hide') || (element1.style.display == '' && view == 'hide')){
      element1.style.display = 'none';
   }else if(view == 'show'){
      element1.style.display = 'block';
   }
   
   return;
}


//--------------------------
// Shows or hides a div by setting the display style
//--------------------------
function showHide(id, action) {
	if (document.getElementById) {
		document.getElementById(id).style.display = action;
	} else if (document.all) {
		document.all[id].style.display = action;
	} else if (document.layers) {
		document.layers[id].style.display = action;
	}
}


//--------------------------
// Called when the 'Show' or 'Hide' links are clicked
//--------------------------
function showPrices(action) {
	if (action == "hide") {
	
		showHide("turnon", "block");

		showHide("turnoff", "none");

		showHide("textToHide", "none");
		
	} else if (action == "show") {

		showHide("turnon", "none");

		showHide("turnoff", "block");

		showHide("textToHide", "block");
		
	}
}
