﻿<!--

	var isIE = navigator.appName.indexOf("Microsoft") != -1;

// Set dropdown menus to inactive - onload makes them active

	var menuSystemActive = false;
	
// detection of platforms

	// iphone + ipod safari
	var iosMode = false;
	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) iosMode = true;
	
	var isTouchDevice = false;
	
	function checkTouchDevice() {  
	  	try {  
			document.createEvent("TouchEvent");  
			return true;  
	 	 } catch (e) {  
			return false;  
	  	}  
	}
		

// image preload settings

	var preloadArray = new Array();
	var preloadCount = 0;
	function addPreloadImage(imgSrc) {
		preloadArray[preloadCount] = imgSrc;
		preloadCount +=1;
	}
	
	addPreloadImage("/global/images/menu/mega-menu-top-sprite.png");
	addPreloadImage("/global/images/menu/mega-menu-divider-tile.gif");
	addPreloadImage("/global/images/menu/mega-menu-tile-sprite.png");
	addPreloadImage("/global/images/menu/mega-menu-bottom-sprite.png");
	addPreloadImage("/global/images/menu/menu-indicator.png");

// onload triggers

	function pageTrigger() {
		menuSystemActive = true;
		// touch device?
		if(checkTouchDevice()) {
			isTouchDevice = true;
			touchMenuListener();
		}
		// fix for submit forms by hitting 'return'
		inputSubmitByReturn();
		// homepage intro text
		setupHomeIntro();
		// tabbed content
		buildTabs();
		// clickable panels
		initClickablePanels();
		// video button
		initVideoButton();
		// scrollers
		initScrollers();
		// preload images
		var cache = [];
		for (i=0;i<preloadArray.length;i++) {
			var cacheImage = document.createElement('img');
			cacheImage.src = preloadArray[i];
			cache.push(cacheImage);
		}
		localPageTrigger();
		//inpage visual map?
		initInpageVisualMap();
		// jquery setup
		if($) {
			// visual map
			$(function() {
				$(".visualMapLauncher").click(function() {
					$.fancybox({
						'overlayOpacity'	: 0.8,
						'overlayColor'		: '#28164d',
						'width'				: 960,
						'height'			: 622,
						'autoScale'			: false,
						'hideOnOverlayClick': false,
						'content'			: visualMapCode(),
						'scrolling'			: 'no',
						'onComplete'		: function() {
							vmModalVersion = true;
							return visualMapLabels();
						},
						'onCleanup'			: function() {
							vmModalVersion = false;
						}
					});
					return false;
				});
			});
			// clickable DIVs (for listings)
			$("div[class*='contentBox clickable']").each(function() {
				$(this).removeClass("clickable").addClass("contentBoxClickable");
				$(this).click(function() { window.location = $(this).find("a:last").attr("href"); return false; });
			});
		}
	}
	
// extra html5 support in elements?

	function elementSupportsAttribute(srcElement,srcAttribute) {
		var test = document.createElement(srcElement);
		if(srcAttribute in test) {
			return true;
		} else {
			return false;
		}
	}
	
	function inputSupportsType(srcType) {
		var input = document.createElement("input");
		input.setAttribute("type",srcType);
		if(input.type == "text") {
			return false;
		} else {
			return true;
		}
	}
	
	
// fix for submit forms by hitting 'return'

	function addInputSubmitEvent(form, input) {
		input.onkeydown = function(e) {
			e = e || window.event;
			if (e.keyCode == 13) {
				form.submit();
				return false;
			}
		};
	}

	function inputSubmitByReturn() {
		var forms = document.getElementsByTagName('form');
		for (var i=0;i < forms.length;i++) {
			var inputs = forms[i].getElementsByTagName('input');
			for (var j=0;j < inputs.length;j++) {
				addInputSubmitEvent(forms[i], inputs[j]);
			}
		}
	}
	
// form field validation function

	function validateField(getField,getMode,getFormAreaID) {
		isValid = true;
		switch(getMode) {
			case "req":
				if(isEmptyField(getField)) isValid = false;
				break;
				
			case "email":
				if(!isValidEmail(getField.value)) isValid = false;
				break;
				
			case "reqEmail":
				if(!isValidEmail(getField.value)) isValid = false;
				if(isEmptyField(getField)) isValid = false;
				break;
				
			case "date":
				if(!/^\d{2}\/\d{2}\/\d{4}$/.test(getField.value)) isValid = false;
				break;
				
			case "postcode":
				if(!/^[A-Za-z]{1,2}[0-9]{1,2}[A-Za-z]?\s*[0-9][A-Za-z]{2}$/.test(getField.value)) isValid = false;
				break;
				
			case "dropdown":
				if(getField.selectedIndex == 0) isValid = false;
				break;
		}
		if(isValid) {
			document.getElementById(getFormAreaID).className = "formArea okay";
		} else {
			document.getElementById(getFormAreaID).className = "formArea error";
		}
	}
	
// enter input field function

	var initSearchText;
	
	function checkInputField(getField,initSearchText,getFocus) {
		if(getFocus) {
			// focus
			if(getField.value == initSearchText) getField.value = "";
		} else {
			// blur
			if(isEmptyField(getField)) {
				getField.value = initSearchText;
			}
		}
	}
	
// panel link clicker

	var allClickPanels = new Array();

	function initClickablePanels() {
		if(document.getElementsByClassName) {
			findClickPanels = document.getElementsByClassName("clickablePanel");
		} else {
			findClickPanels = getElementsByClass("clickablePanel",document,"div");
		}
		if(findClickPanels.length > 0) {
			for(i=0;i<findClickPanels.length;i++) {
				allClickPanels[i] = new clickPanel(findClickPanels[i],i);
			}
		}
	}
	
	function clickPanel(getPanel, getIndex) {
		this.panel = getPanel;
		this.index = getIndex;
		if(this.panel.getElementsByTagName('A')[0]) {
			// get link details
			this.panel.newLocation = this.panel.getElementsByTagName('A')[0].href;
			this.panel.newTarget = this.panel.getElementsByTagName('A')[0].target;
			// set behaviour
			this.panel.onclick = function() {
				if(this.newTarget == "_blank") {
					window.open(this.newLocation);
				} else {
					window.location = this.newLocation;
				}
			}
			// cancel link action
			this.panel.getElementsByTagName('A')[0].onclick = function() {return false};
			// set cursor style
			this.panel.style.cursor = "pointer";
		}
	}

// Function to retun the length of an object (number of keys/value pairs)

	function oCount(myObject) { var counter = 0; for(keys in myObject) counter++; return counter; }


// Function to check if a field string is empty
	
	function isEmptyField(srcField) {
		srcText = srcField.value;
		srcText = srcText.replace(/^\s+/g, '').replace(/\s+$/g, '');
		if(srcText == "") {
			srcField.value = "";
			return true;
		} else return false;
	}
	
	
// Email address validation
	
	function isValidEmail(src) {
		var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
		var regex = new RegExp(emailReg);
		return regex.test(src);
	}

// Image Loader functions

	// Cross-browser implementation of element.addEventListener()
	function addListener(element, type, expression, bubbling)
	{
	  bubbling = bubbling || false;
	  if(window.addEventListener)	{ // Standard
		element.addEventListener(type, expression, bubbling);
		return true;
	  } else if(window.attachEvent) { // IE
		element.attachEvent('on' + type, expression);
		return true;
	  } else return false;
	}
	
	var ImageLoader = function(url){
	  this.url = url;
	  this.image = null;
	  this.loadEvent = null;
	};
	
	ImageLoader.prototype = {
	  load:function(){
		this.image = document.createElement('img');
		var url = this.url;
		var image = this.image;
		var loadEvent = this.loadEvent;
		addListener(this.image, 'load', function(e){
		  if(loadEvent != null){
			loadEvent(url, image);
		  }
		}, false);
		this.image.src = this.url;
	  },
	  getImage:function(){
		return this.image;
	  }
	};
	
	
// Image size checking + resizing

	function checkImageSize(srcImage,maxWidth,maxHeight) {
		if(document.images) {
			getWidth = srcImage.width;
			getHeight = srcImage.height;
			if(getWidth>maxWidth || getHeight>maxHeight) {
				widthVariance = maxWidth/getWidth;
				heightVariance = maxHeight/getHeight;
				if(widthVariance<=heightVariance) scalePercentage = getWidth/maxWidth;
				else scalePercentage = getHeight/maxHeight;
				srcImage.width = getWidth/scalePercentage;
				srcImage.height = getHeight/scalePercentage;
			}
		}
	}

// Menu Stuff
	var dynamicMenuHolder;
	var dynamicMenu;
	var menuArea;
	var dynamicMenuContent;
	var dynamicMenuIndicator;
	var onIndicator;
	var menuFocus = "button";
	var storeMenuIndex = null;
	var storeButtonState = null;
	var storeThisElement = null;
	var menuActive = false;
	var menuTimeout = null;
	var submenuTimeout = null;
	
	function touchMenuListener() {
		if (document.addEventListener) {
			document.addEventListener('touchstart', function (e) {
				if(menuActive) {
					if(e.target || e.srcElement) {
						trigger = e.target || e.srcElement;
						menuFound = false;
						while(!menuFound && trigger != document.body) {
							if(trigger) {
								if(trigger.nodeType == 1) {
									if(trigger.tagName.toLowerCase() == "div") {
										if(trigger == dynamicMenu || trigger == menuArea) menuFound = true;
									}
								}
								trigger = trigger.parentNode;
							} else {
								trigger = document.body;
							}
						}
						if(!menuFound) {
							doHideMenu();
						}
					}
				}
			});
		}
	}
	
	function getMenuClass(src,hoverState) {
		if(hoverState) return "menuOver"
		else {
			if(storeButtonState) return "menuOn"
			else return "menuOff";
		}
	}
	
	function setPos(getObject,getX,getY) {
		getX = Math.floor(getX);
		getY = Math.floor(getY);
		if(getObject.style.posTop) {
			getObject.style.posLeft = getX;
			getObject.style.posTop = getY;
		} else {
			getObject.style.left = getX + "px";
			getObject.style.top = getY + "px";
		}
	}
	
	function showMenu(menuIndex,buttonState,buttonLeft,buttonWidth,thisElement) {
		if(menuSystemActive) {
			clearTimeout(submenuTimeout);
			cancelHideMenu();
			if(menuActive && menuIndex != storeMenuIndex) {
				if(document.getElementById("submenu" + menuIndex)) {
					// switch submenu content off
					if(document.getElementById("submenu" + storeMenuIndex)) document.getElementById("submenu" + storeMenuIndex).style.display = "none";
					// turn off old button
					storeThisElement.className = getMenuClass(storeThisElement,false);
				} else {
					doHideMenu();
				}
			}
			if(!menuActive) {
				// get elements
				menuArea = document.getElementById("menuArea");
				menuAreaWidth = parseFloat(menuArea.offsetWidth) -4;
				menuBaseX = parseFloat(document.getElementById("menuArea").offsetLeft) + 2;
				dynamicMenuHolder = document.getElementById("dynamicMenuHolder");
				dynamicMenu = document.getElementById("dynamicMenu");
				dynamicMenuIndicator = document.getElementById("dynamicMenuIndicator");
				dynamicMenuContent = document.getElementById("dynamicMenuContent");
				onIndicator = document.getElementById("menuOnIndicator");
				// set menu active
				menuActive = true;
			}
			//activation
			if(onIndicator) onIndicator.style.display = "none";
			storeMenuIndex = menuIndex;
			storeButtonState = buttonState;
			storeThisElement = thisElement;
			thisElement.className = getMenuClass(thisElement,true);
			if(document.getElementById("submenu" + menuIndex)) {
				// Set menu class based on number of columns
				dynamicMenu.className = "menu" + menuCols[menuIndex] + "col";
				// Set zIndex + make visible
				dynamicMenu.style.zIndex = 1000;
				dynamicMenu.style.display = "block";
				// Set horizontal position
				menuWidth = parseFloat(dynamicMenuContent.offsetWidth);
				// Set horizontal position
				xOffset = menuBaseX + buttonLeft - 1;
				if((xOffset + menuWidth) > parseFloat(dynamicMenuHolder.offsetWidth)) {
					xOffset = menuAreaWidth - menuWidth; //buttonLeft - (parseFloat(dynamicMenu.offsetWidth) - buttonWidth);
				}
				setPos(dynamicMenu,xOffset,153);
				// gap position
				setPos(dynamicMenuIndicator,(buttonLeft - xOffset) + Math.floor((buttonWidth)/2) - 11,0);
				// switch submenu content on
				document.getElementById("submenu" + menuIndex).style.display = "block";
				document.getElementById("submenu" + menuIndex).style.position = "relative";
				switch(menuCols[menuIndex]) {
					case 1:
					document.getElementById("submenu" + menuIndex).style.width = 250 + "px";
					break;
					case 2:
					document.getElementById("submenu" + menuIndex).style.width = 480 + "px";
					break;
					case 3:
					document.getElementById("submenu" + menuIndex).style.width = 710 + "px";
					break;
				}
				// rollover behaviour
				dynamicMenu.onmouseover = function() {
					menuFocus = "menu";
					showMenu(menuIndex,buttonState,buttonLeft,buttonWidth,thisElement);
				}
				dynamicMenu.onmouseout = function() {
					if(menuFocus == "menu") {
						menuFocus = 'button';
						submenuTimeout = setTimeout("hideMenu('button');",50);
					}
				}
			} else {
				dynamicMenu.style.display = "none";
			}
	}
}
	
	function hideMenu(getTrigger) {
		if(menuSystemActive) {
			if(getTrigger=="button" && menuFocus=="button") menuTimeout = setTimeout("doHideMenu();",100);
		}
	}
	
	function doHideMenu() {
		if(menuSystemActive && storeThisElement != null) {
			// hide menu
			storeThisElement.className = getMenuClass(storeThisElement,false);
			// switch submenu content off
			if(document.getElementById("submenu" + storeMenuIndex)) document.getElementById("submenu" + storeMenuIndex).style.display = "none";
			dynamicMenu.style.display = "none";
			storeMenuIndex = null;
			storeButtonState = null;
			storeThisElement = null;
			menuActive = false;
			// cancel behaviours
			dynamicMenu.onmouseover = null;
			dynamicMenu.onmouseout = null;
			//show on indicator again
			if(onIndicator) onIndicator.style.display = "block";
		}
	}
	
	function cancelHideMenu() {
		if(menuSystemActive) {
			clearTimeout(menuTimeout);
			clearTimeout(submenuTimeout);
			menuTimeout = null;
		}
	}
	
	function menuAreaClick(menuIndex,buttonState,buttonLeft,buttonWidth,thisElement) {
		if(menuSystemActive) {
			if(iosMode && menuActive && storeMenuIndex == menuIndex) {
				// hide menu
				doHideMenu();
				return false;
			} else if(menuActive && storeMenuIndex == menuIndex) {
				// close menu
				doHideMenu();
				return true;
			} else {
				// show menu
				showMenu(menuIndex,buttonState,buttonLeft,buttonWidth,thisElement);
				return false;
			}
		} else {
			return true;
		}
	}
	
	
// Function to track links with Google Analytics
	
	function trackLink(linkSrc) {
		try { pageTracker._trackPageview(linkSrc); } // New Google tracking code
		catch(e) {
			try { urchinTracker(linkSrc); } // Legacy Google tracking code
			catch(e) { }
		}
	}
	
// add a getElementByClass function for browsers that don't support getElementsByClassName
		
	// getElementsByClass(class string, optional DOM node, optional html tag)
	function getElementsByClass(searchClass,node,tag) {
		var classElements = new Array();
		if ( node == null )
			node = document;
		if ( tag == null )
			tag = '*';
		var els = node.getElementsByTagName(tag);
		var elsLen = els.length;
		var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
		for (ii = 0, j = 0; ii < elsLen; ii++) {
			if ( pattern.test(els[ii].className) ) {
				classElements[j] = els[ii];
				j++;
			}
		}
		return classElements;
	}
	
// video button function

	function initVideoButton() {
		// create a hidden video object in the browser (to avoid loading delay)
		var tempVid = document.createElement("VIDEO");
		tempVid.setAttribute("id", "initVideoObject");
		document.body.appendChild(tempVid);
		// check for video
		if(videoID > 0 && document.getElementById("mainImage")) {
			// change class of h1
			if(document.getElementsByTagName("h1")) {
				document.getElementsByTagName("h1")[0].className = "withVideoButton";
			}
			// add button elements
			var mainImage = document.getElementById("mainImage")
			newDiv = document.createElement("div");
			newDiv.setAttribute("id", "videoButtonContainer");
			newDiv.innerHTML = "<a id='videoButton' href='javascript:showVideo();'><span>" + videoButtonText + "<\/span><\/a><span id='videoButtonTopShadow'><\/span>";
			mainImage.appendChild(newDiv);
			newDiv = null;
			// slide down with jQuery
			if($) {
				$("#videoButton").animate({top: -48}, 0);
				setTimeout("$('#videoButton').animate({top: 0}, 500);" , 1000);
			}
		}
	}
	
	function showVideo() {
		if($) {
			$.fancybox({
				'overlayOpacity'	: 0.8,
				'overlayColor'		: '#28164d',
				'width'				: 640,
				'height'			: 360,
				'autoScale'			: false,
				'hideOnOverlayClick': false,
				'content'			: videoModalContent(),
				'scrolling'			: 'no',
				'onComplete'		: function() { 
					getModalVideo = document.getElementById("modalVideo");
					if(typeof(getModalVideo.canPlayType) != 'undefined') getModalVideo.play();
				},
				'onCleanup'			: function() {
					if(typeof(getModalVideo.canPlayType) != 'undefined') getModalVideo.pause();
				}
			});
		}
	}
	
	function showHomeVideo() {
		if($) {
			$.fancybox({
				'overlayOpacity'	: 0.8,
				'overlayColor'		: '#28164d',
				'width'				: 640,
				'height'			: 360,
				'autoScale'			: false,
				'hideOnOverlayClick': false,
				'content'			: videoModalContent(),
				'scrolling'			: 'no',
				'onComplete'		: function() { 
					scrollersActive = false;
					mouseTrackingActive = false;
					getModalVideo = document.getElementById("modalVideo");
					if(typeof(getModalVideo.canPlayType) != 'undefined') getModalVideo.play();
				},
				'onCleanup'			: function() { 
					scrollersActive = true;
					mouseTrackingActive = true;
					if(typeof(getModalVideo.canPlayType) != 'undefined') getModalVideo.pause();
				}
			});
			return false;
		}
	}
	
	var getModalVideo;
	
	function videoModalContent() {
		getModalVideo = null;
		vidCode = "<div id='videoContainer'><video id='modalVideo' controls width='640' height='360'>";
		// MP4 must be first for iPad!
		vidCode += "<source src='" + videoPath + "mp4' type='video\/mp4' \/>";
		vidCode += "<source src='" + videoPath + "webm' type='video\/webm' \/>";
		vidCode += "<source src='" + videoPath + "ogv' type='video\/ogg' \/>";
		// fallback to Flash
		vidCode += "<object width='640' height='360' type='application\/x-shockwave-flash' data='\/global\/flash\/ldc-video-player.swf'>";
		// Firefox uses the 'data' attribute above, IE/Safari uses the param below
		vidCode += "<param name='movie' value='\/global\/flash\/ldc-video-player.swf' \/>";
		vidCode += "<param name='wmode' value='transparent' \/>";
		vidCode += "<param name='flashvars' value='video=" + videoPath + "mp4' \/>";
		vidCode += "<\/object>";
		vidCode += "<\/video><\/div>";
		return vidCode;
	}
	
// tabbed content functions

	var tabOn = 0;
	var tabTextOn = "";
	var allTabDivs = new Array;
	var allTabTitles = new Array;
	var allTabContent = new Array;
	var allVRcontent = new Array();
	var urlAnchor = unescape(document.location.hash.substring(1));
	var isAnchorInPage = false;
	
	function buildTabs() {
		if(document.getElementById("tabArea")) {
			// find tabbedContent
			if(document.getElementsByClassName) {
				allTabDivs = document.getElementsByClassName("tabbedContent");
			} else {
				allTabDivs = getElementsByClass("tabbedContent",document,"div");
			}
			// look for anchor in url
			if(urlAnchor != "") {
				// find which tabbedContent container has this anchor inside it
				for(i=0; i<allTabDivs.length; i++) {
					allAnchors = allTabDivs[i].getElementsByTagName("A");
					for(x=0; x<allAnchors.length; x++) {
						if(allAnchors[x].id == urlAnchor) {
							tabOn = i;
							isAnchorInPage = true;
						}
					}
				}
			} else {
				// Get location query (to check for turning tabs on and off)
				var queryArray = new Array;
				queryArray = document.location.search.substring(1).split("&");
				if (queryArray.length > 0) {
					for (var i in queryArray) {
						// Look for tab numbers
						if (queryArray[i].toLowerCase().indexOf("tabnum") >= 0) {
							var querySplit = new Array;
							querySplit = queryArray[i].split("=");
							if (querySplit.length > 0) { tabOn = parseInt(querySplit[1]) - 1; break; }
						}
						// Look for tab names
						if (queryArray[i].toLowerCase().indexOf("tabname") >= 0) {
							var querySplit = new Array;
							querySplit = queryArray[i].split("=");
							if (querySplit.length > 0) { tabTextOn = unescape(querySplit[1].toLowerCase()); break; }
						}
					}
				}
			}
			if(allTabDivs.length > 0) {
				// See if a tab name is specified and find the tab number associated with it
				if(tabTextOn != "") {
					for(i=0;i<allTabDivs.length;i++) {
						if(document.all) allTabTitles[i] = allTabDivs[i].getElementsByTagName("H2")[0].innerText.toString();
						else allTabTitles[i] = allTabDivs[i].getElementsByTagName("H2")[0].textContent.toString();
						if(tabTextOn == allTabTitles[i].toLowerCase()) { tabOn = i; break; }
					}
				}
				// loop through, get data, and hide all but chosen tab (first tab is default)
				for(i=0;i<allTabDivs.length;i++) {
					// tab title
					if(document.all) {
						allTabTitles[i] = allTabDivs[i].getElementsByTagName("H2")[0].innerText.toString();
					} else {
						allTabTitles[i] = allTabDivs[i].getElementsByTagName("H2")[0].textContent.toString();
					}
					// hide content?
					if(i == tabOn) {
						allTabDivs[i].className = "tabbedContent contentVisible";
					} else {
						allTabDivs[i].className = "tabbedContent contentHidden";
					}
				}
			}
			// Build tabs
			var myTabs = "<dl id='tabButtons'>";
			for (i=0; i<allTabDivs.length; i++) {
				if (i == tabOn) {
					myTabs += "<dd id='tab" + i + "' class='tab tabOn'>";
				} else {
					myTabs += "<dd id='tab" + i + "' class='tab tabOff'>";
				}
				myTabs += "<a href='javascript:doTab(" + i + ");'><span class='tabContent'>" + allTabTitles[i] + "<\/span><\/a><\/dd>";
			}
			myTabs += "</dl>";
			document.getElementById("tabArea").innerHTML += myTabs;
		}
	}
	
	function doTab(getTab) {
		// check tab is different from current active tab
		if(getTab != tabOn) {
			// get elements again for IE
			if(document.getElementsByClassName) {
				allTabDivs = document.getElementsByClassName("tabbedContent");
			} else {
				allTabDivs = getElementsByClass("tabbedContent",document,"div");
			}
			// hide old content and change old tab class
			allTabDivs[tabOn].className = "tabbedContent contentHidden";
			document.getElementById("tab"+tabOn).className = "tab tabOff";
			// show new content and change new tab class
			allTabDivs[getTab].className = "tabbedContent contentVisible";
			document.getElementById("tab"+getTab).className = "tab tabOn";
			// store new tab
			tabOn = getTab;
		}
	}
	
// homepage expander functions

	function setupHomeIntro() {
		if(document.getElementById("fullHomeIntroCopy")) {
			if($) {
				$("#fullHomeIntroCopy").stop(false,false);
				$("#fullHomeIntroCopy").slideUp(0);
			} else {
				document.getElementById("fullHomeIntroCopy").style.display = "none";
			}
		}
	}
	
	function homeReadMore() {
		document.write("<a id='homeReadMore' href='javascript:toggleHomeIntro(true);'>Read more&hellip;</a>");
	}
	
	function homeReadLess() {
		document.write("<p><a style='display: none;' id='homeReadLess' href='javascript:toggleHomeIntro(false);'>Read less&hellip;<\/a><\/p>");
	}
	
	function toggleHomeIntro(getMode) {
		if(getMode) {
			document.getElementById("homeReadMore").style.display = "none";
			document.getElementById("homeReadLess").style.display = "inline";
			if($) {
				$("#fullHomeIntroCopy").stop(false,false);
				$("#fullHomeIntroCopy").slideDown(1000);
			} else {
				document.getElementById("fullHomeIntroCopy").style.display = "block";
			}
			
		} else {
			document.getElementById("homeReadLess").style.display = "none";
			document.getElementById("homeReadMore").style.display = "inline";
			if($) {
				$("#fullHomeIntroCopy").stop(false,false);
				$("#fullHomeIntroCopy").slideUp(0);
			} else {
				document.getElementById("fullHomeIntroCopy").style.display = "none";
			}
		}
	}
	
	
// general expander functions

	var expanders = new Array();
	var expanderOpenLabels = new Array();
	var expanderCloseLabels = new Array();

	function toggleExpander(expanderIndex) {
		if(!expanders[expanderIndex]) {
			expanders[expanderIndex] = true;
			document.getElementById("xControl" + expanderIndex).getElementsByTagName("A")[0].className = "expanderClose";
			document.getElementById("xControl" + expanderIndex).getElementsByTagName("A")[0].getElementsByTagName("STRONG")[0].innerHTML = expanderCloseLabels[expanderIndex];
			if($) {
				$(("#xContent" + expanderIndex)).stop(false,false);
				$(("#xContent" + expanderIndex)).slideUp(0);
				$(("#xContent" + expanderIndex)).slideDown(1000);
			} else {
				document.getElementById("xContent" + expanderIndex).style.display = "block";
			}
		} else {
			expanders[expanderIndex] = false;
			document.getElementById("xControl" + expanderIndex).getElementsByTagName("A")[0].className = "expanderOpen";
			document.getElementById("xControl" + expanderIndex).getElementsByTagName("A")[0].getElementsByTagName("STRONG")[0].innerHTML = expanderOpenLabels[expanderIndex];
			if($) {
				$(("#xContent" + expanderIndex)).stop(false,false);
				$(("#xOpen" + expanderIndex)).slideDown(0);
				$(("#xContent" + expanderIndex)).slideUp(0);
			} else {
				document.getElementById("xContent" + expanderIndex).style.display = "none";
			}
		}
	}
	
// visual map code

	var vmModalVersion = false;
	var vmWidth;
	var vmLabel;
	var vmLabelHalfWidth = 127; // includes 2px border
	var vmContainer;
	var vmLabelActive = false;
	var vmLabelTimeout = null;
	var vmLabelURL = null;
	var prevArea = null;
	
	function initInpageVisualMap() {
		if(document.getElementById("inpageVisualMapContainer")) {
			visualMapLabels();
		}
	}

	function visualMapCode() {
		return vmCode;
	}
	
	function visualMapLabels() {
		vmLabel = $("#vmImageLabel");
		vmContainer = $("#visualMapContainer");
		vmWidth = $("#visualMapContainer").width();
		// hide label container
		$(vmLabel).fadeTo(0,0);
		// add mouseover functionality
		$("#vmImageMap area").each(function(index) {
			// touch behaviours
			if(isTouchDevice) {
				$(this).click(function(e) {
					e.preventDefault();
					clearTimeout(vmLabelTimeout);
					if(vmLabelActive && prevArea == $(this)) {
						window.location = vmLabelURL;
						hideVmLabel();
						prevArea = null;
					} else {
						var offset = $(vmContainer).offset();
						var mX = e.pageX - offset.left;
						var mY = e.pageY - offset.top;
						vmLabelURL = $(this).attr("href").toString();
						setVmLabelContent($(this).attr("alt"));
						setVmLabelPosition(mX, mY);
						if(!vmLabelActive) {
							// show label
							vmLabelActive = true;
							$(vmLabel).stop(false,false);
							$(vmLabel).fadeTo(500,1);
						}
						prevArea = $(this);
					}
					return false;
				});
				$(vmLabel).click(function(e) {
					window.location = vmLabelURL;
				});
			} else {
				$(this).mouseover(function() {
					clearTimeout(vmLabelTimeout);
					vmLabelTimeout = null;
					setVmLabelContent($(this).attr("alt"));
					if(!vmLabelActive) {
						// show label
						vmLabelActive = true;
						$(vmLabel).stop(false,false);
						$(vmLabel).fadeTo(500,1);
					}
				}).mouseout(function() {
					if(vmLabelActive) vmLabelTimeout = setTimeout("hideVmLabel();", 200);
				}).mousedown(function() {
					return false;
				});
			}
		});
		// track mouse position
		if(!isTouchDevice) {
			$(vmContainer).mousemove(function(e) {
				var offset = $(vmContainer).offset();
				var mX = e.pageX - offset.left;
				var mY = e.pageY - offset.top;
				setVmLabelPosition(mX, mY);
			});
		}
		// return true for fancybox
		if(vmModalVersion) return true;
	}
	
	function setVmLabelContent(getAlt) {
		thisAlt = getAlt.replace("®","<sup>®<\/sup>");
		thisTitle = thisAlt.split(" | ")[0];
		thisDescription = thisAlt.split(" | ")[1];
		$(vmLabel).html("<div><span><strong>" + thisTitle + "</strong>" + thisDescription + "<\/span><\/div>");
	}
	
	function setVmLabelPosition(mX, mY) {
		if((mX + vmLabelHalfWidth) > (vmWidth-10)) {
			labelX = (vmWidth-10) - (vmLabelHalfWidth * 2);
		} else if((mX - vmLabelHalfWidth) < 10) {
			labelX = 10;
		} else {
			labelX = mX - vmLabelHalfWidth;
		}
		labelY = mY-1;
		$(vmLabel).css({left: labelX, top: labelY});
	}
	
	function hideVmLabel() {
		if(vmLabelActive) {
			vmLabelURL = null;
			vmLabelActive = false;
			$(vmLabel).stop(false,false);
			$(vmLabel).fadeTo(500,0);
		}
	}
	
// -->
