<!--
//WARNING - EVIL browser-sniffing ahead
//var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
var IE6 = /msie|MSIE 6/.test(navigator.userAgent);
var Safari = (document.childNodes) && (!document.all) && (!navigator.taintEnabled) && (!navigator.accentColorName);
var Opera = (self.opera != null); 

// -----------------------
// FUNCTION: fAllowTabbing
// DESCRIPTION: Prevents onkey evetns firing when the tab key is pressed, thus allowing users to tab past them
// ARGUMENTS: 1: the event - always described as: event, 2: a function name to call without parenthesis "()", 3 variable names to pass to a function. Multiple variable names must be seperated by a "~", i.e. 'variable one~variable two~variable three~etc...'
// RETURNS: n/a
// N.B: onKey.... events should be followed with "return:true;" NOT "return:false" as for onClick events.
// -----------------------
function fAllowTabbing(e, sFunctionName, sVariable) {
	var e = e || window.event;
	var sKeyPressed = e.keyCode || e.charCode;

	if (sKeyPressed != 9) {
		if (sVariable) {
			if (sVariable.match("~")) {
				var aVariables = sVariable.split('~');
				window[sFunctionName].apply(this, aVariables);
			} else {
				window[sFunctionName](sVariable);
			}
		} else {
		window[sFunctionName]();
		}
	}
}

// Switches a selected class on a specified element.
// Pass the element ID and class name that needs to be added or removed.
function fSwitchClass(sElementId, sClassToSwitch) {

	var eElement = document.getElementById(sElementId);
	var sClassName = eElement.className;
	if (sClassName.match(sClassToSwitch) || sClassName.match(' ' + sClassToSwitch)) {
		// Removes Class
		eElement.className = eElement.className.replace(sClassToSwitch, '');
	} else {
		// Adds Class
		eElement.className = sClassName + ' ' + sClassToSwitch;
	}
}
// -----------------------
// FUNCTION: addEvent
// DESCRIPTION: Attaches an event to the requested object
// ARGUMENTS: 1: The object type, 2: The event type 3: The function to be called
// -----------------------
function fAddEvent(sObject, sEventType, sFunction){ 
 if (sObject.addEventListener){ 
	 if (Safari && (sEventType == 'DOMContentLoaded'))	{	//safari
		sEventType = 'load';
	 } 
	 sObject.addEventListener(sEventType, sFunction, false); 
	 return true; 
 } else if (sObject.attachEvent){
	if (sEventType == 'DOMContentLoaded') {
		sEventType = 'load';
	}
	var sReturn = sObject.attachEvent("on" + sEventType, sFunction); 
	return sReturn; 
 } else { 
   return false; 
 } 
}
//-----------------
// Function: fRemoveEvent
// DESCRIPTION: Removes an event from the object
// ARGUMENTS: 1: The object 2: The event type 3: Associated function
// ----------------
function fRemoveEvent(sObject, sEventType, sFunction){
  if (sObject && sObject.removeEventListener){
    sObject.removeEventListener(sEventType, sFunction, false);
    return true;
  } else if (sObject.detachEvent){
    var oRemove = sObject.detachEvent("on" + sEventType, sFunction);
    return oRemove;
  } else {
    return false;
  }
}

// -----------------------
// FUNCTION: fGetTarget
// DESCRIPTION: Returns the object of an event
// ARGUMENTS: The Event
// RETURNS: The object
// -----------------------
function fGetTarget(e) {
	e = e || window.event;
	if (e.target) {
		var sTarget = e.target;
	}
	if (e.srcElement) {
		var sTarget = e.srcElement;
	}
	return sTarget;
}

// Removes the default value of an input
function fRemoveValue(e) {
	var oTarget = fGetTarget(e);
	if (oTarget.value == oTarget.defaultValue) {
		oTarget.value = '';
	}
}

// Adds the default value to an input if no entry present
function fAddValue(e) {
	var oTarget = fGetTarget(e);
	if (oTarget.value == '') {
		oTarget.value = oTarget.defaultValue;
	}
}
// -----------------------
// FUNCTION: fInputClear
// DESCRIPTION: clears and repopulates inputs unless listed in aPresetFormElements array
// -----------------------
function fInputClear() {
	// Add clearing to Inputs
	aInputs = document.getElementsByTagName('input');
	nInputLength = aInputs.length;
	for (nInputCount = 0; nInputCount < nInputLength; nInputCount++) {		
		 if (aInputs[nInputCount].type == 'text') {
		    if (aInputs[nInputCount].readOnly) {
		        var sReadOnlyId = aInputs[nInputCount].id;
		        fAddEvent(aInputs[nInputCount], 'focus', function() {document.getElementById(sReadOnlyId).select();});   
		    } else {
			    fAddEvent(aInputs[nInputCount], 'focus', fRemoveValue);
			    fAddEvent(aInputs[nInputCount], 'blur', fAddValue);
			}
		 }
	}
	// Add clearing to Text areas
	aTextAreas = document.getElementsByTagName('textarea');
	nTextAreaLength = aTextAreas.length;
	for (nTextAreaCount = 0; nTextAreaCount < nTextAreaLength; nTextAreaCount++) {
		fAddEvent(aTextAreas[nTextAreaCount], 'focus', fRemoveValue);
		fAddEvent(aTextAreas[nTextAreaCount], 'blur', fAddValue);
	}
	// Check for excluded form elements.
	// NB: This will clear any elements with their ID listed in the array 'aPresetFormElements' - this array should be declared on the page from the back end.
	if (typeof aPresetFormElements != 'undefined') {
		var nPresetLength = aPresetFormElements.length;
		for (nPresetCount = 0; nPresetCount < nPresetLength; nPresetCount++) {
			fRemoveEvent(document.getElementById(aPresetFormElements[nPresetCount]), 'focus', fRemoveValue);
			fRemoveEvent(document.getElementById(aPresetFormElements[nPresetCount]), 'blur', fAddValue);
		}
	}
}

// Remove all nodes from within an element
function fRemoveNodes(sParentId) {
	var oChildNodes = document.getElementById(sParentId).childNodes;
	while (oChildNodes[0]) {
		document.getElementById(sParentId).removeChild(oChildNodes[0]);
	}
}

// Create and return a DOM element.
function fCreateElement(hElement) {
	if (hElement.type) {
		var oElement = document.createElement(hElement.type);
		if (hElement.className) {
			oElement.className = hElement.className;
		}		
		if (hElement.id) {
			oElement.id = hElement.id;
		}
		if (hElement.forTag) {
			oElement.htmlFor = hElement.forAttribute;
		}
		if (hElement.inputType) {
		    oElement.type = hElement.inputType;
		}
		if (hElement.inputValue) {
		    oElement.defaultValue = hElement.inputValue;
		    oElement.value = hElement.inputValue;
		}
		if (hElement.elementName) {
			oElement.name = hElement.elementName;
		}
		if (hElement.href) {
			oElement.href = hElement.href;
		}
		if (hElement.title) {
			oElement.title = hElement.title;
		}
		if (hElement.tabindex) {
			oElement.tabIndex = hElement.tabindex;
		}			
		return oElement;
	}	
}

//-----------------------
// FUNCTION: fCreateCookie
// DESCRIPTION: A function that creates a cookie
// ARGUMENTS: 1: Cookie Name, 2: Cookie Value 3: Expiry date
//-----------------------
function fCreateCookie(sName, sValue, sDays) {
	if (sDays) {
		var oDate = new Date();
		oDate.setTime(oDate.getTime() + (sDays * 24 * 60 * 60 * 1000));
		var sExpires = "; expires=" + oDate.toGMTString();
	}
	else var sExpires = "";
	document.cookie = sName + "=" + sValue + sExpires + "; path=/";
}
//-----------------------
// FUNCTION: fReadCookie
// DESCRIPTION: A function that reads a cookie
// ARGUMENTS: 1: Cookie Name
// RETURN: cookie string or null if no cookie present
//-----------------------
function fReadCookie(sName) {
	var sNameEQ = sName + "=";
	var aCookies = document.cookie.split(';');
	for(var nCount = 0; nCount < aCookies.length; nCount++) {
		var sCookie = aCookies[nCount];
		while (sCookie.charAt(0)==' ') sCookie = sCookie.substring(1, sCookie.length);
		if (sCookie.indexOf(sNameEQ) == 0) return sCookie.substring(sNameEQ.length, sCookie.length);
	}
	return null;
}
//-----------------------
// FUNCTION: fDeleteCookie
// DESCRIPTION: A function that deletes a cookie
// ARGUMENTS: 1: Cookie Name , path , domain
//-----------------------
function fDeleteCookie( name, path, domain ) 
{
    if ( GetCookie( name ) ) 
        document.cookie = name + "=" + ( ( path ) ? ";path=" + path : "") + ( ( domain ) ? ";domain=" + domain : "" ) + ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

// ----------------------
// FUNCTION: fGetHref
// DESCRIPTION: A function that returns the url of the "what's this' link in social bookmarks
// ARGUMENTS: None
// RETURN: sLinkRef (the url)
// ----------------------
function fGetHref() {
	var aLinks = document.getElementById('social-bookmarks').getElementsByTagName('a');
	var nLength = aLinks.length;

	for (nCount = 0; nCount < nLength ; nCount++) {
		if (aLinks[nCount].className.match('explanation')) {
			var sLinkRef = aLinks[nCount].href;
			return sLinkRef;
		}
	}
}

// Creates a hidden input '___JSSniffer' and inserts into each <form> element on the page
// Used for JS detection on search result with maps. (i.e. if no JS - no map tab will be rendered).
function fCreateSniffer() {
	var aTheForm = document.body.getElementsByTagName('form');
	var nFormCount = (aTheForm.length);
	for (nCount = 0; nCount < nFormCount; nCount++) {
	    var oInput = document.createElement('input');
	    oInput.setAttribute('type', 'hidden');
	    oInput.setAttribute('name', '___JSSniffer');
	    oInput.id = '___JSSniffer';
	    oInput.value = 'true';  
	    aTheForm[nCount].insertBefore(oInput, aTheForm[nCount].firstChild);
	}
}

// Hides all elements of a given type within a container element using the CSS class 'hidden'
// recieves the container ID and element type
function fHideElements(sContainerId, sElementType) {
	var sElementId;
	var sContainer = document.getElementById(sContainerId);
	var aElements = sContainer.getElementsByTagName(sElementType);
	var nArrayLength = aElements.length;
	for (nCount = 0; nCount < nArrayLength ; nCount++) {
		sElementId = aElements[nCount].id;
		fSwitchClass(sElementId, 'hidden');
	}
}

var oMSGlobals; // Global variable for Main Search.

// Object instance to hold global variables for main search switching.
function fMainSearchGlobals() {
	this.sSearchContainer = 'search-options';
	this.sActiveId = 'search-1';
	this.sActiveClassName = 'active';
}

// Checks for requirement of and adds common site wide events.
function fAddChoicesEvents() {
	fInputClear();
	fCreateSniffer();
}
fAddEvent(window, 'load', fAddChoicesEvents);

// ----------------------
// FUNCTION: fRemoveElementIfExists
// DESCRIPTION: A function that removes provided element
// ARGUMENTS: element id
// ----------------------
function fRemoveElementIfExists(sElementId) {
	if (document.getElementById(sElementId)) {
		var oElement = document.getElementById(sElementId);
		oElement.parentNode.removeChild(oElement);
	}
}

// ----------------------
// FUNCTION: fHideElementsServices
// DESCRIPTION: A function that hides elements in a provided container
// ARGUMENTS: sContainerId,sElementType
// ----------------------
function fHideElementsServices(sContainerId, sElementType) {
	var sElementId;
	var sContainer = document.getElementById(sContainerId);
	var aElements = sContainer.getElementsByTagName(sElementType);
	var nArrayLength = aElements.length;
	for (nCount = 0; nCount < nArrayLength ; nCount++) {
		sElementId = aElements[nCount].id;
		fSwitchClass(sElementId, 'hidden');
	}
}
// ----------------------
// FUNCTION: fShowLabels
// DESCRIPTION: A function that shows elements in a provided container
// ARGUMENTS: sContainerId,sElementType
// ----------------------
function fShowLabels(sContainerId, sElementType){
	var sElementId;
	var sContainer = document.getElementById(sContainerId);
	var aElements = sContainer.getElementsByTagName(sElementType);
	var nArrayLength = aElements.length;
	for (nCount = 0; nCount < nArrayLength ; nCount++) {
		sElementId = aElements[nCount].id;
		var eElement = document.getElementById(sElementId);
		eElement.className = sElementId;
	}
}

function fRemoveAttributes(sContainerId, sElementType,sAttribute){
	var sElementId;
	var sContainer = document.getElementById(sContainerId);
	var aElements = sContainer.getElementsByTagName(sElementType);
	var nArrayLength = aElements.length;
	for (nCount = 0; nCount < nArrayLength ; nCount++) {
		sElementId = aElements[nCount].id;
		var eElement = document.getElementById(sElementId);
		eElement.removeAttribute(sAttribute);
	}
}

function fHappyBobby() {
}
//-->
