/*@cc_on @*/
/*@if (@_win32)
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
/*@end @*/
IEhandling = {
	getIEMajorVersion : function(){
		if(navigator.appName === "Microsoft Internet Explorer"){
			var regExp = /MSIE\s(\d+)\./gi;
			var testUA = regExp.exec(navigator.userAgent);
			return testUA[1];
		}
		else{
			return false;
		}
	},
	islteIE6 : function(){
		var IEVersion = IEhandling.getIEMajorVersion();
		if(IEVersion && IEVersion < 7){
			return true;
		}
		return false;
	}
};
/********** DOM READY STATE CHECKING, WITH ONLOAD FALLBACK. **********/
// hide masthead panels on Home page - to eliminate initial display of all panels in IE6/IE7 
document.write('<style type="text/css">#startupHomeLeadv2 {position: absolute; left: -9999px;}#startupHomeLeadv3 {position: absolute; left: -9999px;}#startupHomeLeadv4 {position: absolute; left: -9999px;}</style>');
window.initialised=false;
if (document.addEventListener) {document.addEventListener("DOMContentLoaded", layerinit, false);}
/* ######################################################################################## */
/*                DO NOT DELETE THE FOLLOWING CODE - EXECUTABLE IN INTERNET EXPLORER - start        */
/* ######################################################################################## */
/*@cc_on @*/
/*@if (@_win32)
      document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
      var script = document.getElementById("__ie_onload");
      script.onreadystatechange = function() {
            if (this.readyState == "complete") {
                  layerinit(); // call the onload handler
            }
      };
/*@end @*/
/* ################################################################################### */
/*                DO NOT DELETE THE ABOVE CODE - EXECUTABLE IN INTERNET EXPLORER - end       */
/* ################################################################################### */
/* safari regular polling */
if (/WebKit/i.test(navigator.userAgent)) { // sniff webkit-based browser
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			layerinit(); // call the onload handler
		}
	}, 10);
}
/* fallback for all other browsers */
window.onload=onloadhandler;
/*########################################################################################################*/
// FUNCTIONS TO RUN WHEN DOM IS READY
function layerinit()	{
	if (window.initialised){return;}
	window.initialised=true;
	IEhandling.isIE6 = IEhandling.islteIE6();
	validator();
	setupExpandableAreas();
	setupExpandingAreas();
	toggleView();
	setupExpandingQuizAreas();
	tabLoader();
	hideDiv("accessibleBlogArchive");
	showDiv("blogArchiveDD");
	headerSwap('startupHomeLeadv');
	hideDiv("accessibleBlogCategory");
	//setupInputHover();
	setupAjaxEvents();
	slideShows.init();
	imageGallery();
	imgSwap();
	pngHandling();
}

function onloadhandler()	{
	layerinit(); // will only execute if layerinit hasn't already executed
	equalisePanelHeights();	// should always be last task
}
/********** END DOM READY **********/

//get the contents between ( and ) marks attached to a classname that starts with a given marker
function getPEClassInfo(el,marker){
	var fullClass = el.className;
	var info = fullClass.substring(fullClass.indexOf(marker+"(")+marker.length+1);
	info = info.substring(0,info.indexOf(")"));
	return info;
}

function fuzzyClassName(tag,fClass)	{
	var el = (tag == "*" && document.all) ? document.all : document.getElementsByTagName(tag);
	var o=new Array();
	for (var i=0;i<el.length;i++)	{
		if (el[i].className.indexOf(fClass)!=-1)	{
			o.push(el[i]);
		}
	}
	return o;
}
//as fuzzyClassName, but restriced to self and children of a specific DOM object
function fuzzyClassNameBlock(block,tag,fClass)	{
	var el = (tag == "*" && block.all) ? block.all : block.getElementsByTagName(tag);

	var o=new Array();
	for (var i=0;i<el.length;i++)	{
		if (el[i].className.indexOf(fClass)!=-1)	{
			o.push(el[i]);
		}
	}
	if(block.className.indexOf(fClass)!=-1){
		o.push(block);
	}
	return o;
}
//handle cross-browser adding events
function addEvent(obj,evt,fn){
	if(document.addEventListener){
		addEvent = function(obj,evt,fn){
			obj.addEventListener(evt,fn,false);
		}
	}
	else if(document.attachEvent){
		addEvent = function(obj,evt,fn){
			obj["e"+evt+fn] = fn;
			obj[evt+fn] = function() { obj["e"+evt+fn]( window.event ); }
			obj.attachEvent( "on"+evt, obj[evt+fn] );
		}
	}
	else{
		return false;
	}
	addEvent(obj,evt,fn);
}

/*IE5.0 ARRAY PROTOTYPE PUSH*/
if(typeof Array.prototype.push=="undefined"){
	Array.prototype.push=function(item){
		return this[this.length] = item;
	};
}

/************ AJAX EVENTS ********************/ 
function setupAjaxEvents() {
	var htmlBody = document.getElementsByTagName("body")[0];
	
	//Poll submission
	if ((htmlBody != null) && ((htmlBody.id == 'home') || (htmlBody.className == 'polls'))) {
		var ajaxPollSubmit = document.getElementById("vote");
		var ajaxPollMode = (htmlBody.className == 'polls') ? 'p' : 'h';
		
		if (ajaxPollSubmit != null) {
			ajaxPollSubmit.onclick = function() {
				ajaxPollSubmission(ajaxPollMode);
				return false;
			}
		}
	}
	
	//Blog rating submission
	if ((htmlBody != null) && (htmlBody.id == 'content')) {
		var blogContainerObj = document.getElementById("ratePost");

		if (blogContainerObj != null)
		{
			var blogRatings = blogContainerObj.getElementsByTagName("a");
			
			if ((blogRatings != null) && (blogRatings.length > 1)) {
				for (i=0; i<blogRatings.length; i++) {
					blogRatings[i].onclick = function() {
						ajaxBlogRatingSubmission(this);
						return false;
					}
				}	
			}
		}
	}
	
	//BT Tradespace name checker
	if ((htmlBody != null) && (htmlBody.id == 'startup')) {
		var ajaxTradespaceNameCheckerModule = getElementsByClassName(document, "div", "nameChecker")[0];
		if (ajaxTradespaceNameCheckerModule) {
			//run relevant function to perform tradespace methods, sending it the module to use
			ajaxTradespaceNameChecker(ajaxTradespaceNameCheckerModule);
		}
	}
}


/********* AJAX TRADESPACE NAME CHECKER **********/ 
//function finds a business name input by user, stops a form submission, makes ajax request to test is name is available
//the funtion will change the namechecker module to display success, failure or error messages
function ajaxTradespaceNameChecker(module) {
	var label = module.getElementsByTagName("label")[0];
	var inputBox = getElementsByClassName(document, "input", "inputBox")[0];    //input box for namechecker	
	var submitButton = getElementsByClassName(document, "input", "nameCheckerButton")[0];
	var form = getParentByTagName(module,"form");                        //finds the parent form of the module
	    labelContent = label.innerHTML;                                  //contents of label to insert into input box
	    
	//place label content into input box
	if (labelContent && inputBox) {
		inputBox.value = labelContent;
		label.innerHTML = "";
	}
	
	//when input box gets focus, remove intial label content, place it back in the label.
	addEvent(inputBox, 'focus', function(){
		var label = this.parentNode.getElementsByTagName("label")[0];
		if(this.value === labelContent){
			label.innerHTML = this.value;
			this.value = '';
		}
	});
	
	//when input box loses focus, if the input is empty, replace with label content
	addEvent(inputBox, 'blur', function(){	
		if(!this.value){
			this.value = labelContent;
			label.innerHTML = '';	
		}
	});
				

	//when submit button is pressed, make ajax call, make decision about what to modify on namechecker module
	if (submitButton && form && inputBox) {
			
		submitButton.onclick = function () {
		
			//error checking - if a name as spaces, or if input hasn't been made, then change module contents accordingly
			if ( illegalCharacters(inputBox.value) || inputBox.value === labelContent) {
				var firstHeadingImg = "/assets/images/promos/namecheck_head_lrg.gif";
				var firstHeadingImgAlt = "Get your business noticed with a free BT Tradespace site!";
				var firstHeadingImgSmall = "/assets/images/promos/namecheck_head_sml.gif";
				var firstInstructionText = "Names cannot contain spaces or special characters.";
				var instructionTextHolder = getElementsByClassName(document, 'p', 'nameCheckerInstructionText')[0];
				var headingImageHolder = getElementsByClassName(document, 'p', 'nameCheckerTitleText')[0];
				var newImg = document.createElement('img');
					newImg.src = (module.className.indexOf("nameCheckerSmall") == -1) ? firstHeadingImg : firstHeadingImgSmall;
					newImg.alt = firstHeadingImgAlt;
				if (instructionTextHolder && headingImageHolder) {
					instructionTextHolder.innerHTML = firstInstructionText;
					headingImageHolder.innerHTML = '';
					headingImageHolder.appendChild(newImg);				
				}
				module.className = module.className.replace("nameCheckError","");
				module.className += " nameCheckError";
				return false;
			} else {
				//do nothing
			}		
			
			function illegalCharacters(myString) {
			
				var myRegExp = new RegExp ("[^a-zA-Z0-9\-]")
				if (myRegExp.test(myString)) {
					return true;
				} else {
					return false;
				}
			}
			
			//response text
			var failureTextSmall = 'Try entering another business name below or visit <span class="nameCheckerTradespaceEmphasis">BT Tradespace.</span>'; 
			var failureText = 'Try entering another business name. Or find out more about promoting your business for free on <a href="http://www.bttradespace.com"><span class="nameCheckerTradespaceEmphasis">BT Tradespace.</span></a>';	
			var successText = 'Register for a free BT Tradespace site now!';
			
			//response image content	
			var failHeadingImg = '/assets/images/promos/namecheck_head_fail_lrg.gif';
			var failHeadingImgAlt = 'Unfortunately this business name is taken...';
			var failHeadingImgSmall = '/assets/images/promos/namecheck_head_fail_sml.gif';
			var failHeadingImgSmallAlt = 'Unfortunately this business name is taken...';
		    var successHeadingImg = '/assets/images/promos/namecheck_head_success_lrg.gif';
			var successHeadingImgAlt = 'Congratulations! Your business name is available.';
			var successNewsHeadingImg = '/assets/images/promos/namecheck_foot_success_lrg.gif';
			var successNewsHeadingImgAlt = 'Latest from BT Tradespace';
			var successHeadingImgSmall = '/assets/images/promos/namecheck_head_success_sml.gif';
		    var successHeadingImgSmallAlt = 'Congratulations! Your business name is available.';
			
			//response button information
			var btnRegId = 'nameCheckerBusinessRegister';
			var btnSubmitClass = 'nameCheckerButton';
			var btnSubmitValue = 'register now';
								
			
			//response business name
			var businessNameClass = 'nameCheckerBusinessName';
			var businessNameContent = inputBox.value;

			//ajax path to call to
			var ajaxPath = '/templates/PageTypes/TradespaceNameChecker.aspx?op=issiteurlavailableforsignup&indebugmode=1&siteurl=';
			var newAjaxPath = ajaxPath + businessNameContent;     //adds the user's input to the URL to be sent on AJAX call


			//insert zero-width characters to business name so that it will wrap on all browsers. Screen-reader safe.
			function webSafeString(myString) {
				var stringAsArray = myString.split("");
				var stringLength = stringAsArray.length;
				var newArray = [];
				var webSafeCharacter = "<span class=\"webSafeChar\"></span>"
				for (var i=0; i < stringLength; i++ ) {
					newArray.push(stringAsArray[i],webSafeCharacter);
				}
				var newString = newArray.join("");
				return newString;
			}
			var webSafeBusinessName = webSafeString(businessNameContent);
			
			//prevents form from being submitted			
			submitButton.disabled = true;
			
			/*Generic AJAX functions*/
			var NewAjax = {
				createXMLHttpRequest : function() {
					try { return new XMLHttpRequest(); } catch(e) {}
					try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
					try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
					alert("XMLHttpRequest not supported");
					return null;
				}
			}
			var xhr = NewAjax.createXMLHttpRequest();
			xhr.open("GET",newAjaxPath,true);
			xhr.onreadystatechange = function() {
				if (xhr.readyState != 4)  { return false; }
				if (xhr.status != 200)  { 
					showErrorFunction();
					return false;
				}
				
				var xhrResponse = xhr.responseXML.documentElement;	
				var data = xhrResponse.getElementsByTagName("retval")[0].childNodes[0].nodeValue; 
				if (data === 'true'||data === 'false') {
					executeResponse(data);
				} else {
					showErrorFunction();
				} 
			}
			xhr.send(null);

			
			//actions to perform once ajax is complete
			function executeResponse(nameAvailable) {
				
				//actions to perform if name is available
				if (nameAvailable === 'true') {		
					
					//form elements
					var labelElm = module.getElementsByTagName("label")[0];
					var inputElm = module.getElementsByTagName("input")[0];
					
					//holding elements
					var headingImageHolder = getElementsByClassName(document, 'p', 'nameCheckerTitleText')[0];
					var headingNewsImageHolder = getElementsByClassName(document, 'p', 'nameCheckerNewsHeading')[0];
					var instructionTextHolder = getElementsByClassName(document, 'p', 'nameCheckerInstructionText')[0];
					instructionTextHolder.innerHTML = successText;
					module.className = module.className.replace("nameCheckError","");
			
					var registerNowButton = document.createElement('a');
					registerNowButton.href = "http://www.bttradespace.com/freetojoin/?s_intcid=btb_intban_business_insight_tradespace_join_v01";
					registerNowButton.innerHTML = "register now";
					
					//remove error class
					module.className = module.className.replace("nameCheckError","");

					//actions to perform if name is available and this is the large version of the module
					if (module.className.indexOf("nameCheckerSmall") == -1) {
						
						//elements to change
						var newImg = document.createElement('img');
						var newImgFooter = document.createElement('img');
						var btBtn = getElementsByClassName(module, 'div', 'btButton')[0];
						var btn = getElementsByClassName(module, 'input', 'nameCheckerButton')[0];
						var newName = document.createElement('p');
						
						//perform substitutions
						newImg.src = successHeadingImg;
						newImg.alt = successHeadingImgAlt;
						headingImageHolder.innerHTML = '';
						headingImageHolder.appendChild(newImg);
						
						newImgFooter.src = successNewsHeadingImg;
						newImgFooter.alt = successNewsHeadingImgAlt;
						headingNewsImageHolder.innerHTML = '';
						headingNewsImageHolder.appendChild(newImgFooter);
						
						newName.className = businessNameClass;
						newName.innerHTML = "'" + webSafeBusinessName + "'";

						btn.parentNode.insertBefore(registerNowButton, btn)
						btn.parentNode.removeChild(btn);						
						
						labelElm.parentNode.removeChild(labelElm);
						inputElm.parentNode.removeChild(inputElm);
						
						module.className += " nameCheckerSuccess";
						btBtn.className = btBtn.className.replace("btButtonRight","");
						
						//alert("1: "+newName.innerHTML + " 2:" + instructionTextHolder.innerHTML);
						//instructionTextHolder.innerHTML = newName.innerHTML;
						
						instructionTextHolder.parentNode.insertBefore(newName, instructionTextHolder);
						
					} else {
						//actions to perform if name is available and this is the small version of the module	
						
						//elements to change
						var newImg = document.createElement('img');
						var newImgFooter = document.createElement('img');
						var btBtn = getElementsByClassName(module, 'div', 'btButton')[0];
						var btn = getElementsByClassName(module, 'input', 'nameCheckerButton')[0];
						var newName = document.createElement('p');
						
						//perform substitutions
						module.className += " nameCheckerSmallSuccess";
						module.insertBefore(newName, instructionTextHolder);
						labelElm.parentNode.removeChild(labelElm);
						inputElm.parentNode.removeChild(inputElm);
						
						newImg.src = successHeadingImgSmall;
						newImg.alt = successHeadingImgSmallAlt;
						headingImageHolder.innerHTML = '';
						headingImageHolder.appendChild(newImg);
						
						newName.className = businessNameClass;
						newName.innerHTML = "'" + webSafeBusinessName + "'";

						btBtn.className = btBtn.className.replace("btButtonRight","");						
						btn.parentNode.insertBefore(registerNowButton, btn)
						btn.parentNode.removeChild(btn);
					}	
								
				} else {
					//actions to perform if name is not available
					
					//elements to change
					var headingImageHolder = getElementsByClassName(document, 'p', 'nameCheckerTitleText')[0];
					var instructionTextHolder = getElementsByClassName(document, 'p', 'nameCheckerInstructionText')[0];
					
					//perform substitutions				
					inputBox.value = labelContent;
					module.className = module.className.replace("nameCheckError","");
															
					//actions to perform if name is not available and this is the large version of the module
					if (module.className.indexOf("nameCheckerSmall") == -1) {
						var newImg = document.createElement('img');
						newImg.src = failHeadingImg;
						newImg.alt = failHeadingImgAlt;
						headingImageHolder.innerHTML = '';
						headingImageHolder.appendChild(newImg); 
						instructionTextHolder.innerHTML = failureText;	
					} else {
						//actions to perform if name is not available and this is the small version of the module
						var newImg = document.createElement('img');
						newImg.src = failHeadingImgSmall;
						newImg.alt = failHeadingImgSmallAlt;
						headingImageHolder.innerHTML = '';
						headingImageHolder.appendChild(newImg); 	   
						instructionTextHolder.innerHTML = failureTextSmall;
					}
				}
			}
			//executeResponse function end
			
			
			//show error message when the AJAX call is not successful
			function showErrorFunction() {				
				var instructionTextHolder = getElementsByClassName(document, 'p', 'nameCheckerInstructionText')[0];
				var inputBox = getElementsByClassName(module, "input", "inputBox")[0];
				instructionTextHolder.innerHTML = 'The server is unavaiable right now, so please try again later...';
			}

            if (submitButton.disabled){
			     submitButton.disabled = false;
		    }
			
			return false;	
			
		}  
		
		
	}
}



/************ AJAX BLOG RATER ********************/ 
function ajaxBlogRatingSubmission(obj) {
	var rateAjaxPath = '/tools/ajax/blograting/';
	var rateContainer = 'ratePost';

	var href = obj.href;
	var rating = 0;
	var id = 0;
	
	if (href != null) {
		if (href.indexOf("blograting=") != -1) {
			var hrefQuery = href.substring((href.indexOf("blograting=")+11)).split('_');
		}
		id = hrefQuery[0];
		rating = hrefQuery[1];
	}
	
	if (rating > 0) {
		var rateRequest = new Ajax(rateAjaxPath, {
			data: {'pid': id, 'rating': rating},
			method: 'get',
			update: $(rateContainer),
			evalScripts: false
		}).request();
	}
}
/************ AJAX POLL ********************/ 
function ajaxPollSubmission(mode) {
	var pollAjaxPath = '/tools/ajax/poll/';
	if (mode == 'h') var pollContainer = 'poll';
	if (mode == 'p') var pollContainer = 'pollsCurrent';
	var pollContainerObj = document.getElementById(pollContainer);
	var pollValue = 0;
	
	if (pollContainerObj != null)
	{
		var pollFieldset = pollContainerObj.getElementsByTagName("fieldset")[0];
		var pollOptions = pollContainerObj.getElementsByTagName("input");
		
		if ((pollOptions != null) && (pollOptions.length > 1)) {
			for (i=0; i<pollOptions.length; i++) {
				if (pollOptions[i].type == 'radio') {
					if (pollOptions[i].checked) {
						pollValue = pollOptions[i].value;
						break;
					}
				}
			}
		}
		
		if (pollValue != 0) {
			var pollRequest = new Ajax(pollAjaxPath, {
				data: {'pv': pollValue, 'mode': mode},
				method: 'get',
				update: $(pollContainer),
				evalScripts: false
			}).request();
		}
		else {
			var pollInError = false;
			var pollParagraphs = pollContainerObj.getElementsByTagName("p");
			
			for (i=0; i<pollParagraphs.length; i++) {
				if (pollParagraphs[i].className == 'error') {
					pollInError = true;
					break;
				}
			}
			
			if (!pollInError) {
				var pollError = document.createElement("p");
				pollError.className = 'error';
				pollError.innerHTML = 'Please choose an answer:';
				pollFieldset.parentNode.insertBefore(pollError, pollFieldset);
				
				pollInError = true;
			}
		}
	}
}
/************ TAB SWAP FUNCTIONS ********************/ 
/*Function that finds all id:tabNav elements, adds onclicks to their <a> children
  and sets up the function that hides the secondary content */
function tabLoader(){
	var uls = document.getElementsByTagName("ul");
	var parents = [];
	for(i=0;i<uls.length;i++)	{
		if(uls[i].id.indexOf("tabNav")!=-1)	{
			parents.push(uls[i].id);
		}
	}
	for(a=0;a<parents.length;a++)	{
		var links = document.getElementById(parents[a]).getElementsByTagName("a");
		for(b=0;b<links.length;b++)	{
			links[b].parent = parents[a]
			links[b].num = b;
			links[b].onclick = function()	{
				swap(("content"+(this.num+1)), this.parent);
				return false;
			}
		}
		if (document.getElementById('content1Items'))	{
			hideDiv('content2Items');
		}
	}
}
//Function to show selected content/hide old + change style of tabs by addition/subtraction of class
function swap(type, parentElem)	{
	var listitems = document.getElementById(parentElem).getElementsByTagName('li');
	if(type=="content1" && listitems.length>1)	{
		if (listitems[1].className != null)	{
			hideDiv('content2Items');
			showDiv('content1Items');
			if(!listitems[1].removeAttribute("className"))	{
				listitems[1].removeAttribute("class")
			}
			listitems[0].className = "current";
		}
	}
	if(type=="content2" && listitems[0].className != null)	{
		hideDiv('content1Items');
		showDiv('content2Items');
		if(!listitems[0].removeAttribute("className"))	{
			listitems[0].removeAttribute("class")
		}
		listitems[1].className = "current";
	}
}
//Function to Show Div ** Parameters: id of div
function showDiv(strDivName){
if(document.getElementById(strDivName) != null) {
    document.getElementById(strDivName).style.visibility = "visible";
    document.getElementById(strDivName).style.display = "block";
    }
	}
//Function to Hide Div **  Parameters: id of div
function hideDiv(strDivName){
if(document.getElementById(strDivName) != null) {
    document.getElementById(strDivName).style.visibility = "hidden";
    document.getElementById(strDivName).style.display = "none";
    }
	}
	
//Function to Show Masthead ** Parameters: id of div
function showMasthead(strDivName){
if(document.getElementById(strDivName) != null) {
    document.getElementById(strDivName).style.visibility = "visible";
    document.getElementById(strDivName).style.display = "block";
    document.getElementById(strDivName).style.position = "static";
	document.getElementById(strDivName).style.left = "0";
    }
	}
//Function to Hide Masthead **  Parameters: id of div
function hideMasthead(strDivName){
if(document.getElementById(strDivName) != null) {
    document.getElementById(strDivName).style.position = "absolute";
	document.getElementById(strDivName).style.left = "-9999px";
    }
	}
//Function to swap header sections for startup
function headerSwap() {
	var startupHeaders = getElementsByClassName(document,'div','startupHome');
	startupHeaders = showHideHeaders('startupHomeLeadv', 1, true);
	var headersLength = startupHeaders.length;
	if(headersLength === 4) {		
		for(y=0; y < headersLength; y++) { //get header links and add onclicks			
			var headerLinks = startupHeaders[y].getElementsByTagName('UL')[0].getElementsByTagName('A');
			var headerLinksLength = headerLinks.length;
			for(x=0; x < headerLinksLength; x++) {				
				if(headerLinks[x].className.indexOf('selected') == -1) { //test for selected link (remove this if markup can be corrected)					
					// headerLinks[x].onclick = function() - for adding onclick behaviour
						headerLinks[x].onmouseover = function() {					
						var links = this.parentNode.parentNode.getElementsByTagName('A');
						var linksLength = links.length;
						for(w=0; w < linksLength; w++) {							
							if(links[w] === this) { var linkIdx = w; }							
						}
						if(linkIdx !== null) { showHideHeaders('startupHomeLeadv', (linkIdx + 1)) };
						// return false;					
					}					
				}				
			}			
		}		
	}
	
}
function showHideHeaders(strLeadingText, intShowHeader, bolAddTo) {
	
	var headers = [];
	for(z=1; z<5; z++) { //get all headers
		var header = document.getElementById(strLeadingText + z);
		if(header !== null) { 
			if(z === intShowHeader) {		
				showMasthead(strLeadingText + z);
			} else {		
				hideMasthead(strLeadingText + z);	
			}
			if(arguments.length === 3 && bolAddTo === true) { headers.push(header) };
		};
	}
	return headers;
}

/* function for making panels equal height */

equalisePanelHeights = function() {
	var equal_container_divs = getElementsByClassName(document,'div','equalPanelHeights');
	for (var i=0; i<equal_container_divs.length; i++) {
		equalise(equal_container_divs[i]);
	}
	// the equaliser;
	function equalise(container_div) {
		var max_height = 0;
		//Get all the homePromos
		var content_divs = getElementsByClassName(container_div,'div','equalMe');
		//If there are more than 1 homePromos
		if(content_divs.length > 1) {
			//find the max height of the homePromos
			for (var i=0; i<content_divs.length; i++) {
					max_height = (content_divs[i].offsetHeight > max_height) ? content_divs[i].offsetHeight : max_height;
			}
			//set all the homePromo conts to be equivalent to this max height minus top and base
			for (var i=0; i<content_divs.length; i++) {
				//get each cont
				var innerDivToEnlarge = getElementsByClassName(content_divs[i], 'div', 'cont');
				//if there are conts
				if(innerDivToEnlarge.length > 0){
					//calculate new height
					var newHeight = equalPanel(max_height, 20)+"px";
					if(IEhandling.isIE6){
						innerDivToEnlarge[0].style.height = newHeight;					
					}
					innerDivToEnlarge[0].style.minHeight = newHeight;
				}
			}
		}
	}
}

equalPanel = function(intHeight, intExcess) {
	
	return intHeight - intExcess;
	
}

/********** VALIDATION FUNCTIONS**********/
/*
REQUIREMENTS: 
	1) form with form_validator:yes inside the class attribute.
	2) container div or tr with validate(something) or validate_cs(something) as part of class attribute where 'something' is used as a to match the rules contained in the validation hash object validationData() (below).
	3) container div or tr also includes a div with class errorMessageText to write out error message
	4) labels for field elements being validated
	
	EXCEPTIONS:
		A) if no container div is possible, a container div with the validate class and just an errorMessageText div will work (e.g. TalkTime Choose Handset intro)
		B) if the text to be given the error class is not a label, add hasPseudoLabel to container tr's class attribute and give the text container element (p, div or span) with class pseudoLabel)  e.g. Talk Time Company Details "I have been at this address for less than three years"
		C) for activationdate validation, all labels are given error class.
		D) Validation is skipped on fields that are inside divs where display is none.
NEW:
	if exising methods and messages do not meet data to validate:
	I) add the text to be displayed to the list of validation error messages.
	II) add the parameter extracted from the class to valScan's switch(method) cases
	III) if necessary, write additional validation function that calls writeError if the data does not validate and clearError if it does.
*/
/* validation hash object. format is:
	
	this.<ruleName>={
		"errormsg" : <mandatory error message string>,
		"errorMsgAlt" : <optional secondary error message string>,
		"logic" : <mandatory string representing validation logic function, or "n/a" if there is no function>
	}
*/
function validationData() {   
   	this.globalError={
		"errormsg" : "Please ensure all required information is complete. See below for details.",
		"logic" : "n/a"
	}
	this.email={
		"errormsg" : "Please re-enter your email address.",
		"logic" : "valtype_cs_gen_email"
	}
	
	this.name={
		"errormsg" : "Please retype your name.",
		"logic" : "valtype_cs_gen_name"
	}
	
	this.lastname={
		"errormsg" : "Please retype your surname.",
		"logic" : "valtype_cs_gen_name"
	}
	
	this.jobtitle={
		"errormsg" : "Please enter your job title.",
		"logic" : "valtype_cs_gen_name"
	}
	this.position={
		"errormsg" : "Please enter your position.",
		"logic" : "valtype_cs_gen_name"
	}
	this.companyname={
		"errormsg" : "Please enter your company name.",
		"logic" : "valtype_cs_gen_name"
	}
	this.turnover={
		"errormsg" : "Please enter your turnover.",
		"logic" : "valtype_cs_gen_selectvalue"
	}
	this.tradingage={
		"errormsg" : "Please enter how many years you have been trading.",
		"logic" : "valtype_cs_gen_selectvalue"
	}
	this.telephone={
		"errormsg" : "Please enter your telephone number.",
		"logic" : "valtype_cs_gen_telephone"
	}
	this.postcode={
		"errormsg" : "Please enter a valid UK postcode.",
		"logic" : "valtype_cs_gen_postcode"
	}
	
	this.privacyterms={
		"errormsg" : "Please tick the BT privacy policy box to confirm that you've read, understood and agree to them.",
		"logic" : "valtype_cs_gen_checkbox"
	}
	
	this.BTcustomer={
		"errormsg" : "Please select an option.",
		"logic" : "valtype_cs_gen_radio"
	}
	this.terms={
		"errormsg" : "Please tick the BT terms &amp; conditions box to confirm that you've read, understood and agree to them.",
		"logic" : "valtype_cs_gen_checkbox"
	}
	this.promotional={
		"errormsg" : "Please indicate whether you would be available for promotional activity",
		"logic" : "valtype_cs_gen_radio"
	}
	this.businesstype={
		"errormsg" : "Please indicate which category you fall into",
		"logic" : "valtype_cs_gen_radio"
	}
	this.textarea={
		"errormsg" : "Please complete this field",
		"logic" : "valtype_cs_gen_name"
	}
	this.companysize={
		"errormsg" : "Please select a value.",
		"logic" : "valtype_cs_gen_selectvalue"
	}
	
	this.title={
		"errormsg" : "Please select a value.",
		"logic" : "valtype_cs_gen_selectvalue"
	}	
	
	this.industrytype={
		"errormsg" : "Please select a value.",
		"logic" : "valtype_cs_gen_selectvalue"
	}
	
	this.comments={
		"errormsg" : "Please enter your comment.",
		"logic" : "valtype_cs_gen_textarea"
	}
}
// create global object
window.validationData=new validationData(); 
//initial validation function, runs on load, sets up functions to run on form submission
function validator() {
	init();
	function init()	{
		el=document.getElementsByTagName("form")
		for (var aVal=0;aVal<el.length;aVal++)	{
			if ((el[aVal].className).indexOf("form_validator:yes")!=-1)	{
				el[aVal].onsubmit = function () {
					removeNodeById("globalError"); // removes any previous global error message
					var critError=getFirstInstanceByClassName(this,"div","criticalErrorMessage");
					if (critError)	{
						return false;
					}	else	{
						if (validate(this.id))	{
							return true;
						}	else	{
							if (document.getElementById("globalErrorPlaceholder"))	{
								oGPH=document.getElementById("globalErrorPlaceholder");
								if (oGPH)	{
									oGPH.innerHTML=oGPH.innerHTML+"<span class=\"globalErrorMessage\" id=\"globalError\"><strong>"+window.validationData.globalError.errormsg+"</strong></span>";
									window.scrollTo(0,getAbsoluteY(document.getElementById("globalError"))-20);
								}
							}
							return false;
						}
					}
				}
			}
		}
	}
}
/* gathers all divs and trs which are tested for validation trigger in the class name.
if there are errors, the page jumps to the first one. */
function validate(id)	{
	var errorFlag=false;
	var formel=document.getElementById(id);
	valScan(formel.getElementsByTagName("div"));
	valScan(formel.getElementsByTagName("tr"));
	return errorFlag?false:true;

	function valScan(el)	{
		for (var aScan=el.length-1;aScan>=0;aScan--)	{
			// validation rules
			if ((el[aScan].className).indexOf("validate(")!=-1 || (el[aScan].className).indexOf("validate_cs(")!=-1)	{
				var oWrapper=el[aScan];
				valData(oWrapper);
				if(method=="novalidation"){
					continue;
				}
				oWrapper.errormsg=eval('window.validationData.'+method+'.errormsg');
				var strLogicFunctionName=eval('window.validationData.'+method+'.logic');
				// execute rule (if rule exists)
				eval(strLogicFunctionName+'(oWrapper)');
			}
		}

		// removes error message div from given oWrapper object, returns boolean with removal status
		function removeError(oWrapper)	{
			return removeNodeByObj(getFirstInstanceByClassName(oWrapper,"div","error"));
		}
		//removes specific error message from given ID, returns boolean with removal status
		function removeSpecError(strId)	{
			return removeNodeById(strId);
		}
	}	
	//extract the type of data expected from the class name
	function valData(oWrapper)	{
		var sp=(oWrapper.className).indexOf("validate_cs(");
		var sstr=(oWrapper.className).substring(sp+12,oWrapper.className.length);
		sstr=sstr.substring(0,sstr.indexOf(")"));
		method=sstr;
	}

/*writeError is called by a valtype_<rule name> function if error condition is true. oWrapper is the wrapping div object.
Each wrapped form line to be validated must have a form element and a corresponding LABEL element, otherwise an error alert will appear. */
function writeError(oWrapper)	{
		errorFlag=true;		
		if ((oWrapper.className).indexOf("error")==-1)	{
			oWrapper.className=oWrapper.className+" error";//MAKES WRAPPER HAVE ERROR CLASS
			var oErrorMsg=getFirstInstanceByClassName(oWrapper,"div","errorMessageText");
			if (oErrorMsg)	{
				oErrorMsg.innerHTML="<div class=\"error\"><strong>"+oWrapper.errormsg+"</strong></div>";
			}	else	{
				alert("DEVELOPER ERROR: missing error message placeholder\n\n"+oWrapper.className);
			}
			var label=oWrapper.getElementsByTagName("label");
			var inpts=oWrapper.getElementsByTagName("input");
			var noInputs=false;
			if(inpts.length==0 && oWrapper.getElementsByTagName("select").length==0){
				noInputs=true;
			}
			if (label.length>0)	{
				var comp=1;
				for (var aLbl=0;aLbl<comp;aLbl++)	{
					label[aLbl].innerHTML="<span class=\"error\">"+label[aLbl].innerHTML+"</span>";
				}
			}	else	{
				alert("DEVELOPER ERROR: accessibility - all form items must have a label\n\n"+oWrapper.className);
			}

		}
	}

/*clearError is called by a valtype_<rule name> function if error condition is false, or occasionally if the error flag
needs clearing before a series of error checks are made. oWrapper is the wrapping div object.*/
	function clearError(oWrapper)	{
		oWrapper.className=oWrapper.className.replace(" error","");
		var errorMsg=getElementsByClassName(oWrapper,"div","errorMessageText");
		errorMsg[0].innerHTML="<!-- nothing in here -->";
		// refine to nodes based approach
		if (errorMsg[0].outerHTML)	{errorMsg[0].outerHTML='<div class="errorMessageText"></div>';}
		var label=oWrapper.getElementsByTagName("label");
		if (label.length>0)	{
			for (var aErr=0;aErr<label.length;aErr++)	{
				var spanErrs=getElementsByClassName(label[aErr],"span","error");
				if(spanErrs.length==0){continue;}
				label[aErr].innerHTML=((label[aErr].innerHTML).replace(/<span class=\"?error\"?>/i,"")).replace(/<\/span>/i,"");
			}

		}
		var tds=oWrapper.getElementsByTagName("td");
		if (tds.length==5)	{
			if (tds[4].innerHTML!="")
			tds[4].style.paddingTop="5px";
		}
	}
	
	/* VALIDATION LOGIC FUNCTIONS *
		for all functions:
	 	oWrapper is wrapping element of form line. errormsg is now a property of object oWrapper
		All write/clear error message inside oWrapper depending on error condition
		NB: See documentation for full explanation of validation rules for each validation logic function.*/
	function valtype_cs_gen_empty(oWrapper)	{
		(getInputVal(oWrapper)=="")?writeError(oWrapper):clearError(oWrapper);
	}
	function valtype_cs_gen_radio(oWrapper)	{
		getRadioSelected(oWrapper)?clearError(oWrapper):writeError(oWrapper);
	}
	function valtype_cs_gen_checkbox(oWrapper)	{
		getCheckboxVal(oWrapper)?clearError(oWrapper):writeError(oWrapper);
	}
	function valtype_cs_gen_textarea(oWrapper)	{
		(getTextareaVal(oWrapper)=="")?writeError(oWrapper):clearError(oWrapper);
	}
	function valtype_cs_gen_name(oWrapper)	{
		var rexp=/^([a-z\-\x80-\xFF]+(. )?[ ']?)+$/i;
		(getInputVal(oWrapper).search(rexp))?writeError(oWrapper):clearError(oWrapper);
	}
	function valtype_cs_gen_email(oWrapper)	{
		var rexp=/^[a-z[\w\.-]*[a-z0-9]@[a-z0-9][\w\.-]*[a-z0-9]\.[a-z][a-z\.]*[a-z]$/i;
		(getInputVal(oWrapper).search(rexp))?writeError(oWrapper):clearError(oWrapper);
	}
	function valtype_cs_gen_selectvalue(oWrapper)	{
		var vals=getSelectVals(oWrapper);
		var orTrig=false;
		for (i=0;i<vals.length;i++)	{
			if (vals[i]=="")	{orTrig=true;}
		}
		(orTrig)?writeError(oWrapper):clearError(oWrapper);
	}
	function valtype_cs_gen_postcode(oWrapper)	{
		var rexp=/(^gir\s0aa$)|(^[a-pr-uwyz]((\d{1,2})|([a-hk-y]\d{1,2})|(\d[a-hjks-uw])|([a-hk-y]\d[abehmnprv-y]))\s?\d[abd-hjlnp-uw-z]{2}$)/i; // optional space in postcode validation
		(getInputVal(oWrapper).search(rexp))?writeError(oWrapper):clearError(oWrapper);
	}
	function valtype_cs_gen_phone(oWrapper)	{
		var rexp=/^((\(?0\d{5}\)?\s?\d{5})|(\(?0\d{4}\)?\s?\d{3}\s?\d{3})|(\(?0\d{3}\)?\s?\d{3}\s?\d{4})|(\(?0\d{2}\)?\s?\d{4}\s?\d{4}))+$/;
		(getInputVal(oWrapper).search(rexp))?writeError(oWrapper):clearError(oWrapper);
	}
	/*END VALIDATION LOGIC FUNCTIONS*/
}

/*hiddenParent checks the given object oWrapper for its display state. if it is hidden by either of the two
recognized methods used on this journey then validation will not take place, unless validateHidden is specified (e.g. vas teop add employees)  */
function hiddenParent(oWrapper)	{
	var tagName="div";
	var elM=oWrapper;var burst=11;var found=false;
	while (!found && burst>0)	{
		burst--;
		if (elM.parentNode==undefined || !elM.parentNode.tagName)	{ 
			return false;
		}
		elM=elM.parentNode;
	
		if ((elM.tagName).toLowerCase()==tagName && elM.style.display=="none" || elM.className.indexOf("expandableContentCollapsed")!=-1)	{
			if(elM.className.indexOf("validateHidden")!=-1 || elM.className.indexOf("validateAlways")!=-1){return false;}
			return true;
		}
	}
	return false;
}

function validateParentContent(oWrapper)	{
	var tagName="div";
	var elM=oWrapper;var burst=11;var found=false;
	while (!found && burst>0)	{
		burst--;
		if (elM.parentNode==undefined || !elM.parentNode.tagName)	{ 
			return false;
		}
		elM=elM.parentNode;
	
		if ((elM.tagName).toLowerCase()==tagName && elM.style.display=="none" || elM.className.indexOf("expandableContentCollapsed")!=-1)	{
			if(elM.className.indexOf("validateHidden")!=-1 || elM.className.indexOf("validateAlways")!=-1){return elM;}
			return false;
		}
	}
	return false;
}

/********** END VALIDATION FUNCTIONS**********/
/*########################################################################################################*/
/* SUPPORTING FUNCTIONS */
// returns an array of elements withing the wrapping element oElm, of the tag type strTagName (or wildcard), with the classname strClassName
//UPDATED 2007-08-21, DB. Added in 2 replace commands to escape ( and )
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var aC=0;
	strClassName = strClassName.replace(/\-/g, "\\-");
	strClassName = strClassName.replace(/\(/g, "\\(");
	strClassName = strClassName.replace(/\)/g, "\\)");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];		
		if(oRegExp.test(oElement.className)){
			arrReturnElements[aC]=oElement;
			aC++;
		}	
	}
	return (arrReturnElements)
}

// simplifies fetching of first element by classname. returns element obj or false
function getFirstInstanceByClassName(oElm,strTagName,strClassName)	{
	var els=getElementsByClassName(oElm,strTagName,strClassName);
	if (els.length>0)	{
		return els[0];
	}
	return false;
}

// returns array of element objects for any fragment of classname which matches strFuzzyClass
function fuzzyClassName(strTagName,strFuzzyClass)	{
	var el=document.getElementsByTagName(strTagName);var o=new Array();var oC=0;
	for (var i=0;i<el.length;i++)	{
		if (el[i].className.indexOf(strFuzzyClass)!=-1)	{
			o[oC]=el[i];
			oC++;
		}
	}
	return o;
}

// returns the object of the next parent/grand-parent etc. of the element object oEl of the tag type strTagName. Returns false if fails
function getParentByTagName(oEl,strTagName)	{
	var burst=10;var found=false;
	while (!found && burst>0)	{
		burst--;
		if (!oEl.parentNode.tagName)	{
			return false;
		}
		oEl=oEl.parentNode;
		if ((oEl.tagName).toLowerCase()==strTagName)	{
			return oEl;
		}
	}
	return false;
}
//finds the elements in oElm's block that has a specified attribute with a specified value
//CAVEAT: IE6 and below has patchy support for class attribute, don't use for that
function getByAttribute(oElm,strTagName,attribName,attribValue){
	var sEls=oElm.getElementsByTagName(strTagName);
	var aElms=new Array();
	for(var s=0;s<sEls.length;s++){
		if(sEls[s].getAttribute(attribName)==attribValue){
			aElms.push(sEls[s]);
		}
	}
	return aElms;
}
// returns an absolute y position of the given element object 'o'.
function getAbsoluteY(o) {
	oTop=o.offsetTop;            
	while(o.offsetParent!=null) { 
		oParent=o.offsetParent;
		oTop+=oParent.offsetTop;
		o=oParent;
	}
	return oTop
}

// removes given node string (nodeId). returns true/false status on node removal
function removeNodeById(strNodeId)	{
	if (document.getElementById(strNodeId))	{
		var oNode=document.getElementById(strNodeId);
		return removeNodeByObj(oNode);
	}	else	{
		return false;
	}
}

// removes given node obj (oNode). returns true/false status on node removal
function removeNodeByObj(oNode)	{
	if (oNode)	{
		oNode.parentNode.removeChild(oNode);
		return true;
	}	else	{
		return false;
	}
}

// returns value of first input element inside object oWrapper
function getInputVal(oWrapper)	{
	return oWrapper.getElementsByTagName("input")[0].value;
}
// returns value of first textarea element inside object oWrapper
function getTextareaVal(oWrapper)	{
	return oWrapper.getElementsByTagName("textarea")[0].value;
}
// returns check Boolean of first checkbox element inside object oWrapper
function getCheckboxVal(oWrapper)	{
	return oWrapper.getElementsByTagName("input")[0].checked;
}
// returns true if radio buttons inside object oWrapper is checked, else false
function getRadioSelected(oWrapper)	{
	var els=oWrapper.getElementsByTagName("input");
	for (var aSel=0;aSel<els.length;aSel++)	{
		if(els[aSel].checked)	{
			return true;
		}
	}
	return false;
}
// returns values of all select options
function getSelectVals(oWrapper)	{
		var els=oWrapper.getElementsByTagName("select");var o=new Array();
		for (var aSelV=0;aSelV<els.length;aSelV++)	{o[aSelV]=els[aSelV].value;}
		return o;
	}
/* END SUPPORTING FUNCTIONS */
/********** GENERAL DOM FUNCTIONS END **********/
/*IE5.0 ARRAY PROTOTYPE PUSH*/
if(typeof Array.prototype.push=="undefined"){
	Array.prototype.push=function(){
		for(var i=0;i<arguments.length;i++){
			this[this.length+i]=arguments[i];
			return this.length;
		}
	};
}
/********** EXPANDABLE CONTENT FUNCTIONS**********/
function setupExpandableAreas () {
	//find all expandable areas on page
	expandableAreas=fuzzyClassName("div","expandableContent");
	for (var i=0;i<expandableAreas.length;i++)	{
		expandableAreas[i].id = "expandableArea_"+i;
		var oEl=document.getElementById(expandableAreas[i].id);
		//collapse all expandable areas - unless wrapper has class defaultToOpen
		if (oEl.className.indexOf("defaultToOpen")==-1)	{
			if (oEl.className.indexOf("expandableContentCollapsed")==-1)	{
				oEl.className+= " expandableContentCollapsed";
			}
		}
		
		//remove link from anchor, assisgn id
	    if (expandableAreaAnchor = getElementsByClassName(expandableAreas[i], 'h3', 'commentOpener')[0].getElementsByTagName("a")[0]) {
		    expandableAreaAnchor.id = "expandableAreaAnchor_"+i;
		    expandableAreaAnchor.href="#";
	    }
		
		//remove 'for' attribute from label
		if(expandableAreaLabel = getElementsByClassName(expandableAreas[i], 'h3', 'commentOpener')[0].getElementsByTagName("label")[0]) {
			expandableAreaLabel.removeAttribute("for");
		}

		//assign onclick function to open / close expandable areas
		expandableAreaAnchor.onclick = function () {
			elementId = this.id.split("_").reverse()[0]; //puts the element id number at the front of array
			openOrCloseExpandableContent("expandableArea_" + elementId );
			return false;
		}
	}
}

function openOrCloseExpandableContent (id) {
	var oEl=document.getElementById(id);
	if (oEl.className.indexOf("expandableContent")!=-1)	{
		oEl.className=oEl.className.replace(" defaultToOpen","");
		if (oEl.className.indexOf("expandableContentCollapsed")==-1) 	{
			oEl.className += " expandableContentCollapsed";
		} else {
			oEl.className=oEl.className.replace(" expandableContentCollapsed","");
		}
	}
}
/********** END EXPANDABLE CONTENT FUNCTIONS **********/
/*########################################################################################################*/



/*
toggleView allows specified content to be displayed and hidden depending on one of a group of links being clicked or an input being checked.
the content is hidden using nodisplay, which means it is not available to screenreaders when hidden
the visible content area's link has its link removed so it is just a span, when it is no longer the visible area a link is written around it dynamically
REQUIRED:
	toggling content grouped inside a div with class PE_toggleView
	FOR LINKS
		toggling text in span element with class PE_toggler(uid)
	FOR INPUTS
		input given class PE_toggler(uid)
	FOR HIDING ALL TOGGLE AREAS
		input or span with class PE_toggler()
	block element wrapping the content to be toggled with class PE_toggle(uid)
	the toggler for the starting toggle view has no link around it, all the other togglers do
*/
function toggleView(){
	var toggleViewDiv = getElementsByClassName(document,"div","PE_toggleView");

	for(var i=0,j=toggleViewDiv.length;i<j;i++){
		toggleViewDiv[i].style.display = "block";
		toggleViewDiv[i].style.visibility = "visible";
		var toggles = fuzzyClassNameBlock(toggleViewDiv[i],"span","PE_toggler");
		var toggleInputs = fuzzyClassNameBlock(toggleViewDiv[i],"input","PE_toggler");
		for(var t=0,u=toggleInputs.length;t<u;t++){
			toggles.push(toggleInputs[t]);
		}
		for(var k=0,m=toggles.length;k<m;k++){
			toggles[k].allToggles = toggles;
			var toggleViewMarker = getPEClassInfo(toggles[k],"PE_toggler");
			var toggleViews = fuzzyClassName("*","PE_toggle("+toggleViewMarker+")");
			if(toggleViewMarker == ""){
				toggleViews = null;
			}
			else if(toggleViews.length == 0){
				continue;
			}
			else{
				toggles[k].toggleView = toggleViews[0];
			}

			toggles[k].parentNode.toggle = toggles[k];
			//for spans
			if(toggles[k].parentNode.tagName.toLowerCase() == "a"){
				hideToggleView(toggles[k].toggleView);
				toggles[k].parentNode.onclick = toggle;
			}
			//for inputs
			else if(toggles[k].tagName.toLowerCase() == "input"){
				toggles[k].toggle = toggles[k];
				if(toggles[k].checked == false){
					hideToggleView(toggles[k].toggleView);
				}
				addEvent(toggles[k],"click",toggle);
			}
		}
	}
	function toggle(){
		if(this.toggle.toggleView){showToggleView(this.toggle.toggleView);}
		for(var n=0,p=this.toggle.allToggles.length;n<p;n++){
			if(this.toggle.allToggles[n] == this.toggle){
				if(this.tagName.toLowerCase() == "a"){
					this.parentNode.insertBefore(this.toggle,this);
					this.parentNode.removeChild(this);
				}
				continue;
			}
			else{
				hideToggleView(this.toggle.allToggles[n].toggleView);
				if(this.toggle.allToggles[n].parentNode.tagName.toLowerCase() != "a" && this.tagName.toLowerCase() != "input" ){
					var toggleLink = document.createElement("a");
					toggleLink.href="#";
								this.toggle.allToggles[n].parentNode.insertBefore(toggleLink,this.toggle.allToggles[n]);
					toggleLink.appendChild(this.toggle.allToggles[n]);
					toggleLink.toggle = this.toggle.allToggles[n];
					toggleLink.onclick = toggle;
				}
			}
		}
		if(this.tagName.toLowerCase() == "a"){return false;}

	}
	function hideToggleView(el){
		if(!el){return false;}
		if(el.className.indexOf("nodisplay") == -1){
			el.className += " nodisplay";
		}
	}
	function showToggleView(el){
		if(!el){return false;}
		 el.className = el.className.replace("nodisplay","");
	}
}


/* LEGACY CODE */

/* Slideshows code */

/**
Slideshows

Slideshows consist of a list of li's who's ul has a class of PE_slideshow(name*) *where name is the id you want slideshow controls to have.

So PE_slideshow(show1) will have a list of controls created for it with id = "show1".

The code will read all <ul>'s with that class, create a list of links below them and assign control of their corresponding <li>'s to each link.
If you click on a link, it will display it's <li> and hide the rest. If no links are clicked, the default behaviour is for it to cycle through
the <li>'s one by one, fading each one in and out.

 */

slideShows = {
	
	shows : [],
	
	init : function() {
		
		this.getSlideShows();
		this.runSlideShows();
		
	},
	
	getSlideShows : function() {
		
		var showItems = fuzzyClassName("ul","PE_slideshow");
		if(showItems != null) {
			
			var showsLength = showItems.length;
			for(i=0;i<showsLength;i++) {
	
				var showItemArticles = showItems[i].getElementsByTagName("li");
				if(showItemArticles != null && showItemArticles.length > 1) {
					
					var showItemId = getPEClassInfo(showItems[i],"PE_slideshow");
					var controls = this.makeControls(showItems[i], showItemArticles, showItemId);
					showItems[i].parentNode.appendChild(controls);	
					if(IEhandling.getIEMajorVersion() != false){
						var colDivs = document.getElementById("column4").getElementsByTagName('div');
			   			if(colDivs !== null) { 
			   				var colDivLength = colDivs.length;
			   				for(b=0; b<colDivLength; b++) {
			   					if(colDivs[b].className.indexOf("topicsList") !== -1) {
			   						colDivs[b].style.paddingTop = "0px";
			   						controls.style.paddingTop = "0px";
			   					}
			   				}
			   			}
					}
							
					var runStatus = (showItemArticles.length > 1) ? true : false;
					var matchedShow = new slideShow(controls,showItems[i],runStatus);
					this.shows.push(matchedShow);
					this.shows[showsLength - 1].setLinks();
				
				}
				
			}	
			
		}
	
	},
	makeControls : function(showItem, showItemArticles, showItemId) {
					
		var controls = document.createElement('ul');
		controls.id = showItemId;
		controls.className = "topicsControls clear"
			
		var articleLength = showItemArticles.length;
		var forward = document.createElement('li');
		forward.innerHTML = "<a href='#' id='test1' class='back' title='article no. '><span class='hidden'>Forward</span></a>";			
		controls.appendChild(forward);
		for(a=0;a<articleLength;a++) {
			
			var control = document.createElement('li');
			if(a === 0) {
				
				control.innerHTML = "<a href='#' class='active' title='article no. '><span class='hidden'>"+(a + 1)+"</span></a>";
				
			} else {
				
				control.innerHTML = "<a href='#' title='article no. '><span class='hidden'>"+(a + 1)+"</span></a>";
				
			}
			controls.appendChild(control);
			
		}
		var back = document.createElement('li');
		back.innerHTML = "<a href='#' class='forward'' title='article no. '><span class='hidden'>Back</span></a>";			
		controls.appendChild(back);
		return controls;
		
	},
	
	articleSelect : function(thisLink, showIdx) {
		
		slideShows.shows[showIdx].slideShowRunning = false;
		var currentShow = slideShows.shows[showIdx];
		var linksNum = currentShow.linksList.length;
		var linkIdx;
		for(i=0;i<linksNum;i++) {
			
			if(currentShow.linksList[i] === thisLink) { linkIdx = i; }
			
		}
		var currentLinkIdx = currentShow.currentIdx + 1;
		var back = true, forward = true;
		if(currentLinkIdx === 1) { back = false; };
		if(currentLinkIdx === (linksNum - 2)) { forward = false; };
		
		if(linkIdx === 0) { // If link clicked is the Back button
			
			if(back === true) { 
			
				window.clearTimeout(slideShows.shows[showIdx].timer);
				currentLinkIdx --;
				this.setCurrent(currentShow, currentLinkIdx);
				currentShow.showCurrent(showIdx);
				
			} else {
			
				if(currentShow.opacity < 99) {
					
					slideShows.fadeIn(showIdx, currentShow.fadeIdx, currentShow.opacity);
					
				}
			
			}
			
		} else if(linkIdx === (linksNum - 1)) { // If link clicked is the Forward button
			
			if(forward === true) { 
			
				window.clearTimeout(slideShows.shows[showIdx].timer);
				currentLinkIdx ++;
				this.setCurrent(currentShow, currentLinkIdx);
				currentShow.showCurrent(showIdx);
				
			} else {
			
				if(currentShow.opacity < 99) {
					
					slideShows.fadeIn(showIdx, currentShow.fadeIdx, currentShow.opacity);
					
				}
			
			}
			
		} else { 
		
			window.clearTimeout(slideShows.shows[showIdx].timer);
			this.setCurrent(currentShow, linkIdx);
			currentShow.showCurrent(showIdx);
			
		}
		
	},
	
	setCurrent : function(currentShow, linkIdx) {
		
		currentShow.current.className = "";
		var currentLinkIdx = linkIdx;
		currentShow.current = currentShow.linksList[currentLinkIdx];
		currentShow.currentIdx = currentLinkIdx - 1;
		currentShow.current.className += " active";
		
	},
	
	runSlideShows : function () {
		
		var showsLength = this.shows.length;
		for(i=0;i<showsLength;i++) {
			
			if(this.shows[i].runStatusFlag === true) { this.shows[i].runSlideShow(i); }
			
		}
		
	},
	
	setOpacity : function(obj, opacity) {
		
  		//opacity = (opacity == 100)?99.999:opacity;
  
		// IE/Win
		obj.style.filter = "alpha(opacity:"+opacity+")";
		
		// Safari<1.2, Konqueror
		obj.style.KHTMLOpacity = opacity/100;
		
		// Older Mozilla and Firefox
		obj.style.MozOpacity = opacity/100;
		
		// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = opacity/100;
		
	},
	
	fadeIn : function(showIdx, articleIdx, opacity) {
			
			var currentShow = this.shows[showIdx];
			if(opacity > 100) { 
				
				currentShow.opacity = 100; 
				
			} else { currentShow.opacity = opacity; }
			
			var articleObj = currentShow.articlesList[articleIdx];
			if (opacity <= 100) {
				
			  	slideShows.setOpacity(articleObj, opacity);
			  	opacity += 10;
			  	if(opacity < 110) { 
					
					currentShow.timer = window.setTimeout("slideShows.fadeIn("+showIdx+","+articleIdx+","+opacity+")", 100);
					
				} else {
					
					/* adjust the timer here to change the pause time */
					currentShow.timer = window.setTimeout("slideShows.fadeIn("+showIdx+","+articleIdx+","+opacity+")", 5000);
					
				}
				
			} else {
				
				if(currentShow.slideShowRunning === true) {
			
					
					var nextArticleIdx;
					if(currentShow.currentIdx === currentShow.articlesList.length - 1) { 
						
						nextArticleIdx = 0; 
						
					} else {
						
						nextArticleIdx = currentShow.currentIdx + 1;						
					}
					
					this.fadeOut(showIdx, articleIdx, 100, nextArticleIdx);
			
				}
				
			}
 
	},

	fadeOut : function(showIdx, articleIdx, opacity, nextArticleIdx) {
		
		
		var currentShow = this.shows[showIdx];
		currentShow.opacity = opacity;	
		var articleObj = currentShow.articlesList[articleIdx];		
		var nextArticleObj = currentShow.articlesList[nextArticleIdx];
		if (opacity > 0) {
			
		  	slideShows.setOpacity(articleObj, opacity);
		  	opacity -= 10;
		  	currentShow.timer = window.setTimeout("slideShows.fadeOut("+showIdx+","+articleIdx+","+opacity+","+nextArticleIdx+")", 100);
			
		} else {
			
			articleObj.style.display = "none";
			this.setOpacity(nextArticleObj,0);
			nextArticleObj.style.display = "block";
			currentShow.fadeIdx = nextArticleIdx;
			slideShows.setCurrent(currentShow, nextArticleIdx + 1);
			this.fadeIn(showIdx, nextArticleIdx, 0);

		}
	}
	
}

function slideShow(linksList,articlesList,runStatus) {
	
	this.linksObj = linksList;
	this.articlesObj = articlesList;
	this.runStatusFlag = runStatus;
	this.linksList = this.linksObj.getElementsByTagName('a');
	this.articlesList = this.articlesObj.getElementsByTagName('li');
	this.slideShowRunning = null;	
	this.timer = null;
	this.opacity = null;
	this.setUpShow();
	
}

slideShow.prototype = {
	
	setUpShow : function() {
		
		this.getCurrent();		
		this.showCurrent();
		
	},
	
	getCurrent : function() {
		
		var links = this.linksList;
		var linksLength = links.length;
		for(i=1;i<(linksLength - 1);i++) {
			
			if(links[i].className.indexOf('active') > -1) { 
			
				this.current = links[i]; 
				this.currentIdx = i - 1; // applies to index of the current article and that of the current numbered link (not forward or back links)
			
			}
			
		}
		
	},
	
	setLinks : function() {
		
		var showIdx;
		var showNum = slideShows.shows.length;
		for(i=0;i<showNum;i++) {
			
			if(slideShows.shows[i] === this) { showIdx = i; }
			
		}
		var linksLength = this.linksList.length;
		for(i=0;i<linksLength;i++) {
			
			var selectArticle1 = function(that) { 
			
				return (function(e) {
					
					e.preventDefault();
					slideShows.articleSelect(that, showIdx); 
					
				});
				
			};
			
			var selectArticle2 = function(that) { 
			
				return (function(e) {
					
					slideShows.articleSelect(that, showIdx);
					return false; 
					
				});
				
			};
			
			if(this.linksList[i].addEventListener) {
				
				this.linksList[i].addEventListener("click",selectArticle1(this.linksList[i]),false)
				
			} else {
				
				this.linksList[i].attachEvent("onclick",selectArticle2(this.linksList[i]));
			
			}
				
		}

	},
	
	showCurrent : function(flag) {
		
		if(arguments.length < 1) {
			
			var current = this.current;
			var linksLength = this.linksList.length - 1;
			for(a=1;a<linksLength;a++) {
				
				if(this.linksList[a] === current) {
				
					this.articlesList[a - 1].style.display = "block";
					
				} else { 
				
					this.articlesList[a - 1].style.display = "none";
				
				} 
				
			}
		
		} else {
			
			var showIdx;
			var showNum = slideShows.shows.length;
			for(i=0;i<showNum;i++) {
				
				if(slideShows.shows[i] === this) { showIdx = i; }
				
			}
			slideShows.fadeOut(showIdx, this.fadeIdx, this.opacity , this.currentIdx);
			
		}
		
	},
	
	runSlideShow : function(showIdx) {
	
		this.slideShowRunning = true;
		this.fadeIdx = this.currentIdx;		
		this.timer = window.setTimeout("slideShows.fadeOut("+showIdx+","+this.fadeIdx+",100,"+(this.currentIdx + 1)+")",5000);
		
	}
		
}

/* Slideshows code */

/* EXPANDING AREAS CODE FOR ACCORDION ON JOURNEY HUB PAGES*/
function setupExpandingAreas () {
	//find all expandable areas on page
	expandingAreas=fuzzyClassName("li","expandingContent");

	for (var i=0;i<expandingAreas.length;i++)	{
		expandingAreas[i].id = "expandingArea_"+i;
		//update: DB 2008-01-10: added in handling of minimum number of areas to have before expandable handling is activated
		if(getPEClassInfo(expandingAreas[i],"expandingContent") != ""){
			var classInfo = getPEClassInfo(expandingAreas[i],"expandingContent")
			var relatedAreas = 	fuzzyClassName("li","expandingContent("+classInfo+")");
			if(classInfo.indexOf("min-") != -1){
				var minTrigger = classInfo.substring(classInfo.indexOf("-")+1);
				if(relatedAreas.length < minTrigger){
					continue;
				}
			}
		}
		//collapse all expandable areas unless set to open by default
		//update: DB 2008-01-09: added in handling for defaultToOpen
		//update: DB 2008-01-09: changed straight rewrite of classname to appending.
		if(expandingAreas[i].className.indexOf("defaultToOpen") !=-1){
			expandingAreas[i].className = expandingAreas[i].className.replace(" defaultToOpen","");
			expandingAreas[i].className += " expandingContentShow";
		} else { expandingAreas[i].className += " expandingContentCollapsed"; }
				
		//remove link from anchor, assign id
		expandingAreaAnchor = getElementsByClassName(expandingAreas[i], 'span', 'shortDesc')[0].getElementsByTagName("a")[0];
		if (typeof expandingAreaAnchor != "undefined") {
			expandingAreaAnchor.id = "expandingAreaAnchor_"+i;
		//	expandingAreaAnchor.removeAttribute("href");
		}

		//updated: DB 2008-01-09: if there is no content in the open/close link, add open/close buttons
		if(expandingAreaAnchor.innerHTML == "&nbsp;"){
			expandingAreaAnchor.isDynamicText = true;
			if(document.getElementById(expandingAreas[i].id)
			){
				expandingAreaAnchor.innerHTML = "<span>Close</span>";
			}
			else{
				expandingAreaAnchor.innerHTML = "<span>Open</span>";
			}
		}
		
		//remove 'for' attribute from label
		expandingAreaLabel = getElementsByClassName(expandingAreas[i], 'span', 'shortDesc')[0].getElementsByTagName("label")[0];

		if(typeof expandingAreaLabel != "undefined" && expandingAreaLabel != null) {
			expandingAreaLabel.removeAttribute("for");
		}

		//assign onclick function to open / close expandable areas
		expandingAreaAnchor.onclick = function () {
			elementId = this.id.split("_").reverse()[0]; //puts the element id number at the front of array
			if(this.isDynamicText){
				if(this.innerHTML == "<span>Close</span>"){
					this.innerHTML = "<span>Open</span>";
				}
				else if(this.innerHTML == "<span>Open</span>"){
					this.innerHTML = "<span>Close</span>";
				}
			}
			for(a = 0; a < expandingAreas.length; a++) {
				openOrCloseExpandingContent(expandingAreas[a].id); // does the element clicked
			}
			return false;
		}
	}
}

function openOrCloseExpandingContent (id) {
	var clickedId = "expandingArea_"+elementId;
	var oEl=document.getElementById(id);
	if (oEl.id != clickedId)	{
		if (oEl.className.indexOf("expandingContentCollapsed") == -1) 	{
			oEl.className += " expandingContentCollapsed";
		} 
		if (oEl.className.indexOf("expandingContentShow") != -1) {
			oEl.className = document.getElementById(id).className.replace(" expandingContentShow","");	
		}
	} else {
			oEl.className=oEl.className.replace(" expandingContentCollapsed","");
			if(oEl.className.indexOf("expandingContentShow") == -1) {
				oEl.className += " expandingContentShow";			
			}
	}

}

/* END EXPANDING AREAS CODE */


/* QUIZ ACCORDION */

function setupExpandingQuizAreas(){

	//find all expandable quiz questions on page
	var expandingQuizAreas = fuzzyClassName("li", "expandingQuizArea");
	
	//only operate if quiz areas are found on page
	if (expandingQuizAreas.length > 0) {
	
		//cycle through each quiz question
		for (var i = 0; i < expandingQuizAreas.length - 1; i++) {
			var questionElement = document.getElementById("quizQuestion" + (i + 1));
			var answers = getElementsByClassName(questionElement, "div", "longDesc");
			
			if (answers.length === 1) {
			
				//insert saved answer elements
				var answerInformation = document.createElement("div");
				answerInformation.className = "shortDesc";
				answerInformation.innerHTML = "<div class=\"quizAnswer-bl\"><div class=\"quizAnswer-br\"><div class=\"quizAnswer-tr\"><div class=\"quizAnswer-tl\"><div class=\"quizAnswerContent\"><a href=\"#\" id=\"changeQuestion" + (i + 1) + "\" class=\"quizAnswerChange\">Change</a><p class=\"quizAnswer\"></p></div></div></div></div></div>";
				answers[0].parentNode.insertBefore(answerInformation, answers[0]);
				
				var changeQuestion = document.getElementById("changeQuestion" + (i + 1));
				if (changeQuestion) {
					changeQuestion.onclick = function(){
						var currentQuestion = this.id.slice(this.id.search(/[0-9]/)) - 1;
						closeQuizAreas(expandingQuizAreas);
						openQuizAreas(expandingQuizAreas, currentQuestion);
						return false;
					}
				}
				
				//insert 'move to next question' link to all but the last quiz question
				var nextQuestionLink = document.createElement("p");
				nextQuestionLink.className = "quizNextQuestion";
				nextQuestionLink.innerHTML = "<a id=\"linkToQuestion" + (i + 2) + "\" href=\"#\">Move on to question " + (i + 2) + "</a>";
				answers[0].appendChild(nextQuestionLink);
				
				//when clicked, check that question is answered, open next question
				var linkToNextQuestion = document.getElementById("linkToQuestion" + (i + 2));
				linkToNextQuestion.onclick = function(){
					var parentContainer = this.parentNode.parentNode;
					var currentQuestion = this.id.slice(this.id.search(/[0-9]/)) - 2;
					var radioButtons = parentContainer.getElementsByTagName("input");
					
					//checks to see if an answer has been selected 				
					var questionAnswered = function(){
						for (var j = 0; j < radioButtons.length; j++) {
							if (radioButtons[j].checked) {
								if (savedAnswerText = getElementsByClassName(parentContainer.parentNode, "p", "quizAnswer")) {
									//find all labels for the question, and 'save' the selected one
									var labels = parentContainer.getElementsByTagName("label");
									for (var k = 0; k < labels.length; k++) {
										if (labels[k].htmlFor === radioButtons[j].id) {
											savedAnswerText[0].innerHTML = labels[k].innerHTML;
											break;
										}
									}
									return true; //function found a selected answer
								}
							}
						}
						return false; //function found that no answer was selected
					}
					
					if (questionAnswered()) {
						//remove any error text
						if (parentContainer.firstChild.className === "errorText") {
							parentContainer.firstChild.parentNode.removeChild(parentContainer.firstChild);
						}
						//add 'completed' class to the question
						var containingQuestion = parentContainer.parentNode;
						if ((containingQuestion.className.search("expandingQuizArea") != -1) && (containingQuestion.className.search(" completed") == -1)) {
							containingQuestion.className += " completed";
						}
						
						closeQuizAreas(expandingQuizAreas);
						openQuizAreas(expandingQuizAreas, (currentQuestion + 1));
					}
					else {
						if (parentContainer.className === "longDesc") {
						
							var errorMessage = document.createElement("p");
							errorMessage.className = "errorText";
							errorMessage.innerHTML = "Please select one of the available answers:";
							
							//only insert error message if it does not already exist								
							if (parentContainer.firstChild.className !== "errorText") {
								parentContainer.insertBefore(errorMessage, parentContainer.firstChild);
							}
						}
					}
					return false;
				}
			}
		}
		
		
		//Find submit button and add functionality
		var submitButtons = getElementsByClassName(document,'input','submitButton');
		var submitButton = submitButtons[0];
		
		if (submitButton) {
		
			//add on click functionality
			submitButton.onclick = function(){
				var parentContainer = this.parentNode;
				var currentQuestion = this.id.slice(this.id.search(/[0-9]/)) - 2;
				var radioButtons = parentContainer.getElementsByTagName("input");
				
				//checks to see if an answer has been selected 				
				var questionAnswered = function(){
					for (var j = 0; j < radioButtons.length; j++) {
						if (radioButtons[j].checked) {
							return true; //function found a selected answer
							break;
						}
					}
					return false; //function found that no answer was selected
				}
				
				if (questionAnswered()) {
					//remove any error text
					if (parentContainer.firstChild.className === "errorText") {
						parentContainer.firstChild.parentNode.removeChild(parentContainer.firstChild);
					}
					return true;
				}
				else {
					if (parentContainer.className === "longDesc") {
					
						var errorMessage = document.createElement("p");
						errorMessage.className = "errorText";
						errorMessage.innerHTML = "Please select one of the available answers:";
						
						//only insert error message if it does not already exist								
						if (parentContainer.firstChild.className !== "errorText") {
							parentContainer.insertBefore(errorMessage, parentContainer.firstChild);
						}
					}
					return false;
				}
			}
			
			//add on roll over functionality
			submitButton.onrollover = function(){
				alert("dffd");
			}
		}
		
		//Close the quiz areas
		closeQuizAreas(expandingQuizAreas);
		
		//Open the first quiz area
		openQuizAreas(expandingQuizAreas, 0);
	}
}

//takes an optional 'questionId' which is the question number to close, otherwise closes all questions
function closeQuizAreas(questions, questionId) {
	if (questions !== undefined) {
		//if a question ID is specified and exists in the list of questions, close it
		if ((questionId != undefined) && (questionId <= questions.length)) {
			//only close the question if it is not already closed
			if (questions[questionId].className.search(" questionClosed") == -1) {
				questions[questionId].className = questions[questionId].className.replace(" questionOpened", "");
				questions[questionId].className += " questionClosed";
			}
		}
		//close all the questions
		else {		
			for (var i = 0; i < questions.length; i++) {
				//only close the question if it is not already closed
				if (questions[i].className.search(" questionClosed") == -1) {
					questions[i].className = questions[i].className.replace(" questionOpened", "");
					questions[i].className += " questionClosed";
				}				
			}	
		}
	}
	else {
		return (false);
	}
}

//takes an optional 'questionId' which is the question number to open, otherwise opens all questions
function openQuizAreas(questions, questionId) {
	if (questions !== undefined) {
		//if a question ID is specified and exists in the list of questions, open it
		if ((questionId != undefined) && (questionId <= questions.length)) {
			//only open the question if it is not already open
			questions[questionId].className = questions[questionId].className.replace(" questionClosed", "");
			questions[questionId].className += " questionOpened";
		}
		//open all the questions
		else {		
			for (var i = 0; i < questions.length; i++) {
				//only open the question if it is not already closed
				questions[i].className = questions[i].className.replace(" questionClosed", "");
				questions[i].className += " questionOpened";
			}	
		}
	}
	else {
		return (false);
	}
}
/* END QUIZ ACCORDION */



/* IMAGE STILLS VIEWER ON VIDEO PAGE */
function showPic(whichpic) {
		var source = whichpic.getAttribute("href");
		var imagescreen = document.getElementById("imageViewScreen");
		var imgArr=imagescreen.getElementsByTagName("img");
		var myimg=imgArr[0];
		myimg.src=whichpic.href;

	}
	function imageGallery() {
		if (!document.getElementById("ssthumbs")) return false;
		var gallery = document.getElementById("ssthumbs");
		var links = gallery.getElementsByTagName("a");
		var thumbs = gallery.getElementsByTagName("span");
		for (var i = 0; i < links.length; i++) {			
				links[i].onclick = function() {
				// remember, this function has no access to the objects in the function imageGallery.
				var gallery = document.getElementById("ssthumbs");
				var thumbs = gallery.getElementsByTagName("span");
				for (var j = 0; j < thumbs.length; j++) {
					thumbs[j].className = "";	
				}
				var thisThumb=this.getElementsByTagName("span");
				thisThumb[0].className="selected";			
				showPic(this);
				return false;
			}
		}
	}

/* END OF IMAGE STILLS VIEWER ON VIDEO PAGE */


//Adds swap functionality for all elements with class 'PE_swap'
function imgSwap(){
var swapImgs=getElementsByClassName(document,"*","PE_swap");
	for(var i=0;i<swapImgs.length;i++){
		swapImgs[i].onmouseover=function(){
				var newImg=this.src.replace("_off.","_over.");
				this.src=newImg;
			};
			swapImgs[i].onmouseout=function(){
				var newImg=this.src.replace("_over.","_off.");
				this.src=newImg;
			};
			swapImgs[i].onfocus=swapImgs[i].onmouseover;
			swapImgs[i].onblur=swapImgs[i].onmouseout;
		}
}



/*PNG handling for inline images
based on supersleight.js
*/
function pngHandling(wrapper){
var supersleight=function(){var root=wrapper;
            var applyPositioning=true;
            var shim='http://www.stratauk.co.uk/testarea/bt/4139_exec_insight/assets/images/css/t.gif';
            var shim_pattern=/t\.gif$/i;
var fnLoadPngs=function(){if(root){root=document.getElementById(root);}else{root=document;}
if(!root){return;}
for(var i=root.all.length-1,obj=null;(obj=root.all[i]);i--){if(obj.currentStyle.backgroundImage.match(/\.png/i)!==null){bg_fnFixPng(obj);}
if(obj.tagName=='IMG'&&obj.src.match(/\.png$/i)!==null){el_fnFixPng(obj);}
if(applyPositioning&&(obj.tagName=='A'||obj.tagName=='INPUT')&&obj.style.position===''){obj.style.position='relative';}}};var bg_fnFixPng=function(obj){var mode='scale';var bg=obj.currentStyle.backgroundImage;var src=bg.substring(5,bg.length-2);if(obj.currentStyle.backgroundRepeat=='no-repeat'){mode='crop';}
obj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='"+mode+"')";obj.style.backgroundImage='url('+shim+')';};var el_fnFixPng=function(img){var src=img.src;img.style.width=img.width+"px";img.style.height=img.height+"px";img.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+src+"', sizingMethod='scale')";img.src=shim;};var addLoadEvent=function(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){if(oldonload){oldonload();}
func();};}};return{init:function(){addLoadEvent(fnLoadPngs);},limitTo:function(el){root=el;},run:function(){fnLoadPngs();}};}();
if(IEhandling.isIE6){
	supersleight.init();
	//stop positioning on startup home header links
	var startupHomeHeader = getElementsByClassName(document,"div","startupHomeHeader");
	for(var s=0;s<startupHomeHeader.length;s++){
		var links = startupHomeHeader[s].getElementsByTagName("a");
		for(var t=0;t<links.length;t++){
			links[t].style.position = "static";	
		
		}
	}
}

}


function getParentByTagName(el,tagName){
            var parent=el.parentNode;
            while(tagName.toLowerCase()!=parent.nodeName.toLowerCase()){
                        parent=parent.parentNode;
                        if(!parent || parent.nodeName=="#document"){return false;}
            }
            return parent;
}




if(typeof sIFR == "function"){
	//white
    sIFR.replaceElement("#startup .flexibleWorkingQuizResults h3.pageSubTitle, #startup .startupHomeHeader h2 span, .startupHomeHeader h3, #startup #columnHeading .span2Column h2", named({sFlashSrc: "../flash/newbt.swf", sColor: "#ffffff", sWmode: "transparent"}));
	//white bold
	sIFR.replaceElement("#startup .homeInDepthPromoBottom h3 span", named({sFlashSrc: "../flash/newbt_bold.swf", sColor: "#ffffff", sWmode: "transparent"}));
	//grey
	sIFR.replaceElement("#startup .flexibleWorkingQuizResults h3.PE_SIFR, #startup .homePromo h3.btText, #startup #bottomHubLinks h3, #startup #column2Hero h2", "#startup #column2 .article .articleContent h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#666666", sWmode: "transparent"}));
	//green
	sIFR.replaceElement("#startup .thinkingTips h3, #startup .thinking .journeyLatestFirst h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#69be28", sWmode: "transparent"}));
	//green bold
	sIFR.replaceElement("#startup .thinking .panelInnerGradient h3, #startup .journeyLatestFirst #startup .thinking h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#69be28", sWmode: "transparent"}));
	//blue
	sIFR.replaceElement("#startup .startingTips h3, #startup .starting .journeyLatestFirst h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#0083af", sWmode: "transparent"}));
	//blue bold
	sIFR.replaceElement("#startup .starting .panelInnerGradient h3, #startup .journeyLatestFirst #startup .starting h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#0083af", sWmode: "transparent"}));
	//purple
	sIFR.replaceElement("#startup .runningTips h3, #startup .running .journeyLatestFirst h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#de5db5", sWmode: "transparent"}));
	//purple bold
	sIFR.replaceElement("#startup .running .panelInnerGradient h3, #startup .journeyLatestFirst #startup .running h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#de5db5", sWmode: "transparent"}));
	//indigo
	sIFR.replaceElement("#startup .growingTips h3, #startup .growing .journeyLatestFirst h3, #accordion h3.overviewHeader", named({sFlashSrc: "/sp/media/direct/btbe/assets/flash/newbt.swf", sColor: "#825ab0", sWmode: "transparent"}));
	//indigo bold
	sIFR.replaceElement("#startup .growing .panelInnerGradient h3, #startup .journeyLatestFirst #startup .growing h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#825ab0", sWmode: "transparent"}));
	//orange
	//sIFR.replaceElement("#startup #columnHeading .subTopicPageHeader h2, #startup .subTopic h3, #startup #column3 .flexibleWorking h3, #startup #column3 .learningGuides h3", named({sFlashSrc: "/assets/flash/newbt.swf", sColor: "#FCA832", sWmode: "transparent"}));
	sIFR.replaceElement("#startup #columnHeading .subTopicPageHeader h2,  #startup #column3 .flexibleWorking h3.PE_SIFR, #startup #column3 .learningGuides h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#FCA832", sWmode: "transparent"}));
	sIFR.replaceElement("#startup .subTopic h3", named({sFlashSrc: "../flash/newbt.swf", sColor: "#FCA832", nPaddingLeft:"8",sWmode: "transparent"}));	
	sIFR.replaceElement("#startup .weeklyBlogBottom h3 span", named({sFlashSrc: "../flash/newbt.swf", sColor: "#0d3c8d", sWmode: "transparent"}));	
};