var log = 'true';function logger (msg){if (log == 'true'){var b = navigator.userAgent.toLowerCase();safari = /webkit/.test(b);if (window.console && !safari){console.log(msg);}else {if(!document.getElementById('logger')){var ul = document.createElement('ul');ul.id = 'logger';document.getElementsByTagName('body')[0].appendChild(ul);}var ul = document.getElementById('logger');var li = document.createElement('li');ul.insertBefore(li,ul.firstChild);li.innerHTML = msg;}}}

function addEvent(elm, evType, fn, useCapture){if(elm.addEventListener){elm.addEventListener(evType, fn, useCapture);return true;}else if (elm.attachEvent){var r = elm.attachEvent('on' + evType, fn);return r;}else{elm['on' + evType] = fn;}}
var defSrchTxt="";
var newWindow = null;
var jQueryUsed = false;
var hpInteractive = false;
var hpContext = "";
var unsupported_safari = (((navigator.userAgent.indexOf("Version/3")==-1)&&(navigator.userAgent.indexOf("Version/4")==-1))&&(navigator.userAgent.indexOf("Safari/4")!=-1));
var homePageClickableLink = false;

// START for new flash Replacement technique
// see doFlashReplace() in jQuery section
var flashCapable;
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
function ControlVersion() {var version;var axo;var e;try {axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");version = axo.GetVariable("$version");} catch (e) {}if (!version){try {axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version = "WIN 6,0,21,0";axo.AllowScriptAccess = "always";version = axo.GetVariable("$version");} catch (e) {}}if (!version){try {axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");version = axo.GetVariable("$version");} catch (e) {}}if (!version){try {axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");version = "WIN 3,0,18,0";} catch (e) {}}if (!version){try {axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");version = "WIN 2,0,0,11";} catch (e) {version = -1;}}return version;}
function GetSwfVer(){var flashVer = -1;if (navigator.plugins != null && navigator.plugins.length > 0) {if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;var descArray = flashDescription.split(" ");var tempArrayMajor = descArray[2].split(".");			var versionMajor = tempArrayMajor[0];var versionMinor = tempArrayMajor[1];var versionRevision = descArray[3];if (versionRevision == "") {versionRevision = descArray[4];}if (versionRevision[0] == "d") {versionRevision = versionRevision.substring(1);} else if (versionRevision[0] == "r") {versionRevision = versionRevision.substring(1);if (versionRevision.indexOf("d") > 0) {versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));}}var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;;}}else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;else if ( isIE && isWin && !isOpera ) {flashVer = ControlVersion();}	return flashVer;}
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {versionStr = GetSwfVer();if (versionStr == -1 ) {return false;} else if (versionStr != 0) {if(isIE && isWin && !isOpera) {tempArray         = versionStr.split(" ");tempString        = tempArray[1];versionArray      = tempString.split(",");} else {versionArray      = versionStr.split(".");}var versionMajor      = versionArray[0];var versionMinor      = versionArray[1];var versionRevision   = versionArray[2];if (versionMajor > parseFloat(reqMajorVer)) {return true;} else if (versionMajor == parseFloat(reqMajorVer)) {if (versionMinor > parseFloat(reqMinorVer))return true;else if (versionMinor == parseFloat(reqMinorVer)) {if (versionRevision >= parseFloat(reqRevision))return true;}}return false;}}
function AC_AddExtension(src, ext){if (src.indexOf('?') != -1){return src.replace(/\?/, ext+'?'); }else{return src + ext;}}
function AC_Generateobj(objAttrs, params, embedAttrs) { var str = '';if (isIE && isWin && !isOpera){str += '<object ';for (var i in objAttrs)str += i + '="' + objAttrs[i] + '" ';for (var i in params)str += '><param name="' + i + '" value="' + params[i] + '" /> ';str += '></object>';} else {str += '<embed ';for (var i in embedAttrs)str += i + '="' + embedAttrs[i] + '" ';str += '> </embed>';}document.write(str);}
function AC_FL_RunContent(){var ret = AC_GetArgs (arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000", "application/x-shockwave-flash");AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);}
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){var ret = new Object();ret.embedAttrs = new Object();ret.params = new Object();ret.objAttrs = new Object();for (var i=0; i < args.length; i=i+2){var currArg = args[i].toLowerCase();    switch (currArg){	case "classid":break;case "pluginspage":ret.embedAttrs[args[i]] = args[i+1];break;case "src":case "movie":	args[i+1] = AC_AddExtension(args[i+1], ext);ret.embedAttrs["src"] = args[i+1];ret.params[srcParamName] = args[i+1];break;case "onafterupdate":case "onbeforeupdate":case "onblur":case "oncellchange":case "onclick":case "ondblClick":case "ondrag":case "ondragend":case "ondragenter":case "ondragleave":case "ondragover":case "ondrop":case "onfinish":case "onfocus":case "onhelp":case "onmousedown":case "onmouseup":case "onmouseover":case "onmousemove":case "onmouseout":case "onkeypress":case "onkeydown":case "onkeyup":case "onload":case "onlosecapture":case "onpropertychange":case "onreadystatechange":case "onrowsdelete":case "onrowenter":case "onrowexit":case "onrowsinserted":case "onstart":case "onscroll":case "onbeforeeditfocus":case "onactivate":case "onbeforedeactivate":case "ondeactivate":case "type":case "codebase":ret.objAttrs[args[i]] = args[i+1];break;case "id":case "width":case "height":case "align":case "vspace": case "hspace":case "class":case "title":case "accesskey":case "name":case "tabindex":ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];break;default:ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];}}ret.objAttrs["classid"] = classid;if (mimeType) ret.embedAttrs["type"] = mimeType;return ret;}
if (!unsupported_safari){
	var doFlashReplaceStylesElem = document.createElement('LINK');
	doFlashReplaceStylesElem.setAttribute("rel","stylesheet");
	doFlashReplaceStylesElem.setAttribute("id","flashReplaceStylesheet");
	doFlashReplaceStylesElem.setAttribute("href","/_stylesheets/flashReplace.css");
	var docHead = document.getElementsByTagName("HEAD")[0];
	docHead.appendChild(doFlashReplaceStylesElem);
}
// END for new flash Replacement technique

function popUpWin(url, type, strWidth, strHeight){
    closeWin();
    if (type == "fullScreen"){
            strWidth = screen.availWidth - 10;
            strHeight = screen.availHeight - 160;
    }
    var tools="";
    if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=20,left=0, status=1, statusbar=1"; 
    if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=yes,width="+strWidth+",height="+ strHeight+",left=0,top=20, status=1, statusbar=1"; 
    if (type == "noscroll") tools = "toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+ strHeight+",left=0,top=20, status=1, statusbar=1"; 		
    newWindow = window.open(url, 'newWin', tools);
    newWindow.focus();
}
function bankConsole(this_form){
	var selectedURL = this_form.frmSelectUrl.options[this_form.frmSelectUrl.options.selectedIndex].value;
	if(selectedURL == "/internetbanking/help/help_Welcome.htm?s=home"){
		var HelpWin = window.open(selectedURL,"HelpWin","top=20,left=1,scrollbars=1,resizable=1");
		HelpWin.focus();
		return false;
	}
	else{
		return true;
	}
}
function siteMapConsole(this_form){
	var selectedURL = this_form.frmSelectUrl.options[this_form.frmSelectUrl.options.selectedIndex].value;
	if(selectedURL == "/_SiteContents/Energy-efficiency.htm?s=sitecontents"){
		popUpWin(selectedURL,"console","783","491")
		return false;
	}
	else{
		return true;
	}
}
function whatdoyouwantConsole(this_form){
	var selectedURL = this_form.frmSelectUrl.options[this_form.frmSelectUrl.options.selectedIndex].value;
	if(selectedURL == "https://olb2.nationet.com/applications/modolpreapplyui/start.aspx?page=inputScreen&mis=brick&s=iwant"){
		var HelpWin = window.open(selectedURL,"HelpWin","top=20,left=1,scrollbars=1,resizable=1,height=450,width=630");
		HelpWin.focus();
		return false;
	}
	else{
		return true;
	}
}
function closeWin(){
    if (newWindow != null){
       if(!newWindow.closed)newWindow.close();
    }
}
//  ************************ PAGE TAGGING ***********************************
//This function handles Atlas click event tags when a user click the apply now button on an atlas monitored apply page
function doAtlas(str_click, str_url){
	var click_img = new Image()
	if (str_click != '' && str_url != ''){
		//load image src to cause a hit on atlas servers 
		click_img.src = "http://switch.atdmt.com/action/" + str_click;
		//go to the supplied url
		window.location.href =  str_url;
	}
}
//This function handles DoubleClick click event tags when a user click the apply now button on a monitored apply page
function doDoubleClick(str_click, str_url,new_win){
	if (str_click != '' && str_url != ''){
		var imgSpotlight = new Image();
		imgSpotlight.src = "http://ad.uk.doubleclick.net/activity;" + str_click; 
	}
	if(new_win!=null){
		window.open(str_url);
	}
	else{
	window.location.href =  str_url;
	}
}	
//This function handles Both click event tags when a user click the apply now button on a monitored apply page
function doClickTags(str_atlas, str_click, str_url,new_win){
	var click_img = new Image()
	if (str_atlas != '' && str_url != ''){
		//load image src to cause a hit on atlas servers 
		click_img.src = "http://switch.atdmt.com/action/" + str_click;
	}
	if (str_click != '' && str_url != ''){
		var imgSpotlight = new Image();
		imgSpotlight.src = "http://ad.uk.doubleclick.net/activity;" + str_click; 
	}
	//go to the supplied url
	if(new_win!=null){
		window.open(str_url);
	}
	else{
	window.location.href =  str_url;
	}
}	
function clickTag(str_click, str_url){
	if (str_click != ''){
		var imgSpotlight = new Image();
		imgSpotlight.src = str_click;
		window.location.href =  str_url; 
	}
}
function clickTag_forms(str_click, frm_name){
	if (str_click != ''){
		var imgSpotlight = new Image();
		imgSpotlight.src = str_click;
		document.forms[frm_name].submit();
	}
}
//  ************************ END PAGE TAGGING ***********************************
//Upper case change script
function doCase(str)
{
str = str.substring(0,1).toUpperCase() + str.substring(1,(str.length));
return(str);
}
function fixheader(whatEl)
{
var arrEl = document.getElementsByTagName(whatEl);
if (whatEl!="li")
 {
 for (i=0;i<arrEl.length;i++)
  {
  var arrEltxt = arrEl[i].innerHTML;
  //arrEltxt = arrEltxt.substring(0,1).toUpperCase() + arrEltxt.substring(1,(arrEltxt.length));
  arrEltxt = doCase(arrEltxt);
  arrEl[i].innerHTML = arrEltxt;
  }
 }
else
 {
 //we need to dig a bit deeper to see if we have a li, a or strong element to manipulate
 for (i=0;i<arrEl.length;i++)
  {
  thisEl = arrEl[i];
  if ((thisEl.parentNode.parentNode.id=="leftnav")||(thisEl.parentNode.parentNode.parentNode.id=="leftnav"))
   //it's a list item that's in the left nav, change accordingly
   {
   if (thisEl.childNodes[0].tagName=="A")
    {
    thisEl = arrEl[i].childNodes[0].childNodes[0];
    }
   var arrEltxt = thisEl.innerHTML;
   arrEltxt = doCase(arrEltxt);
   thisEl.innerHTML = arrEltxt;
   }
  }
 }
}
//---------------------------------------------------------------------------
// Launch savings Navigator Swf based on user type / center window functions
//---------------------------------------------------------------------------
function launchNavigator( userType ){
	var url = '/product_finder/Main.html?userType='+userType;
	var name = 'main';
	var windowWidth = 948; //1024, 976
	var windowHeight = 690; //768, 722
	var x = centerWindowX( screen.width, windowWidth );
	var y = centerWindowX( screen.height, windowHeight );
	var features = 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0,width='+windowWidth+',height='+windowHeight+',left='+x+',top='+y;
	var myWindowObject = window.open(url, name, features);
}
function centerWindowX( screenWidth, windowWidth ){
	return (screenWidth - windowWidth) / 2;
}
function centerWindowY( screenHeight, windowHeight ){
	return ( screenHeight - windowHeight) / 2;
}
function fs_filter(){
	for (var x=0; x < document.frmnom_form.elements.length; x++){
		if(document.frmnom_form.elements[x].value){
			document.frmnom_form.elements[x].value = document.frmnom_form.elements[x].value.replace(/[<>"'%;\(\)&\+]/g, "");
		}
	}	
}

// Function to strip/replace FS characters before submitting to server
function stripChars(fieldName){
	fieldName.value = fieldName.value.replace(/%/gi, " percent");
	fieldName.value = fieldName.value.replace(/\+/gi, " plus ");
	fieldName.value = fieldName.value.replace(/</gi," less than ");
	fieldName.value = fieldName.value.replace(/>/gi," greater than ");
	fieldName.value = fieldName.value.replace(/;/gi,",");
	fieldName.value = fieldName.value.replace(/['"]/gi,"~");
	fieldName.value = fieldName.value.replace(/\(/gi,"[");
	fieldName.value = fieldName.value.replace(/\)/gi,"]");
	fieldName.value = fieldName.value.replace(/\&/gi," and ");	
	fieldName.value = fieldName.value.replace(/\\n/gi,"|n");
	fieldName.value = fieldName.value.replace(/\\r/gi,"|r");
}

//---------------------------------------------------------------------------
// START RCA guide - can be removed when how-to guide is removed
function setUpHover(){
var img = document.getElementById("rca-image");
var rca_root = "/_common_images/rca-guide/";
var a = document.getElementsByTagName("a");
var cardinserted = false;
for (i=0;i<a.length;i++)
	{
	if (a[i].className=="rca-hoverlink")
		{
		a[i].onmouseout = a[i].onblur = function(e) {
			if (cardinserted)
				{
				img.setAttribute('src', rca_root + 'rca-clean-card-in.jpg');
				}
				else
				{
				img.setAttribute('src', rca_root + 'rca-clean.jpg');
				}
			}
		a[i].onmouseover = a[i].onfocus = function(e) {
			var id=this.id;
			var path = rca_root + id + ".jpg";
			if (id=="card-inserted-anim")
				{
				path = rca_root + id + ".gif";
				cardinserted = true;
				}
			img.setAttribute('src', path);
			};
		}
	}
}
addEvent(window, 'load', setUpHover, false);
// END RCA guide
function replaceAll(txt, replaceStr, with_this) {
		return txt.replace(new RegExp(replaceStr, 'g'),with_this);
}
function ValidateTalismaSearch(){
	var srchStr = document._search.word.value;
	srchStr = replaceAll(srchStr, "#", "");
	if (srchStr=="" || srchStr==defSrchTxt || srchStr==defAskTxt){
		alert("Please enter a keyword or phrase in the search box");
		document._search.word.focus();
		return false;
	}
	var re5digit=/\d{4}/ //regular expression defining a 5 digit number
	if (srchStr.search(re5digit)==-1) { //if match failed
		return true;
	}
	else {
		document.location="http://www.nationwide.co.uk/search/start.aspx?article=1451";
		return false;
	}
}

//-------------------------------------------------------------
// INTERNET BANKING DEMO FORM LAUNCHER
function openTutorial(sID){
	if(document.frmTutorial.comboSelectTutorial.options[document.frmTutorial.comboSelectTutorial.selectedIndex].value!=-1){
		//launchSim(mID+'&amp;mode=sm',false,true,false); return;
		startSequence(sID); return;
	}
	else{
		alert('Please select a tutorial from the drop down box.')
	}
}// END IB DEMO
function readCookie(name){
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function writeCookie(name, value, hours){
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  var strCookie = name + "=" + escape(value) + expire + "; path=/";
  document.cookie = strCookie;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
// START ACCESSIBILITY ENHANCEMENTS

var accBackground="#003";
var accHighlightBGColor="#003";
var accHighlightColor="#fff";
var accHighlightOutline="2px solid red !important";
var accTextDecoration="none";
var origFontWeight = "";
var origBackground = "";
var origColor = "";
var origBGrep = "";
var origBGpos = "";
var origBGColor = "";
var origBGImage = "";
var origOutline = "";
var origTextDecoration = "";
var enableAccessibilityHotKey = false; //used for pressing letter 'a' to activate
var accP;
var accP_text;
var accPappended;
var accessKeysDisabled = false;
var bodyEl;
var mtgPage = false;

function showSkipLinks() {

// need to be sure that destination of skip links are present 
// on page (some templates do not have them). If not found, remove the
// related skip link in the header
//(mtgPage);
var pagenavSkipdestFound = false;
var maincontentSkipdestFound = false;
var footerSkipdestFound = false;
var skipLinksFound = (document.getElementById("skippies")!=null);
if (skipLinksFound){
	var sk_a = document.getElementsByTagName("a");
	for (i=0; i<sk_a.length; i++)
		{
		//found the skip link dest?
		if (sk_a[i].id == "pagenav-skipdest") {pagenavSkipdestFound = true};
		if (sk_a[i].id == "maincontent-skipdest") {maincontentSkipdestFound = true};
		if (sk_a[i].id == "footer-skipdest") {footerSkipdestFound = true};

		bodyEl = document.getElementsByTagName("body")[0];
		accP = document.createElement("p");
		accP.setAttribute("id","accessibilityHilighter");
		accP_text = document.createTextNode("Press comma key [,] for more accessibility options");
		accP.appendChild(accP_text);

		if (sk_a[i].className=="skip-link")
			{
			sk_a[i].onfocus=function(e){
				var viewportwidth;
				if (typeof window.innerWidth != 'undefined'){
				viewportwidth = window.innerWidth;
				}
				else if ((typeof document.documentElement != 'undefined') && (typeof document.documentElement.clientWidth !='undefined') && (document.documentElement.clientWidth != 0)){
				viewportwidth = document.documentElement.clientWidth;
				}
				else {
				viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
				}
				if (mtgPage){
					viewportwidth = 756;
				}
				this.style.width=viewportwidth + "px";
				this.style.padding="16px 0";
				this.style.fontSize="medium";
				this.style.height="auto";
				this.style.textIndent="20px";
				this.style.backgroundColor="#006";
				this.style.borderBottom="3px solid black";
				this.style.outline="none";
				this.style.backgroundImage="url(/_common_images/accessibility-feature.gif)";
				if (document.getElementById("accessibilityHilighter")==null) {
					bodyEl.appendChild(accP);
					}
					accPappended = document.getElementById("accessibilityHilighter");
					accPappended.style.display = "block";
					accPappended.style.marginTop = "10px";
					enableAccessibilityHotKey = true;
				}
			sk_a[i].onblur=function(e){
				this.style.width="0";
				this.style.padding="0";
				this.style.fontSize="1px";
				this.style.height="1px";
				this.style.textIndent="-30000px";
				this.style.backgroundColor="transparent";
				this.style.backgroundImage="none";
					accPappended = document.getElementById("accessibilityHilighter");
					accPappended.style.display="none";
					enableAccessibilityHotKey = false;
				}
			}
		}
	//remove skip links to missing destinations
	if (!pagenavSkipdestFound) {document.getElementById("skipto-pagenav").style.display="none";};
	if (!maincontentSkipdestFound) {document.getElementById("skipto-maincontent").style.display="none";};
	if (!footerSkipdestFound) {document.getElementById("skipto-footer").style.display="none";};
	}
}
function highlightLinksAndFormControls() {
var tababbleItems = document.getElementsByTagName("*");
for (i=0; i<tababbleItems.length; i++){
	if(((tababbleItems[i].tagName.toLowerCase()=="a")&&(tababbleItems[i].className!="skip-link"))||(tababbleItems[i].tagName.toLowerCase()=="input")||(tababbleItems[i].tagName.toLowerCase()=="textarea")||(tababbleItems[i].tagName.toLowerCase()=="select"))
		{
		tababbleItems[i].onfocus=function(e) {
				//store the existing background images and colours:
				origBackground = this.style.background;
				origBGColor = this.style.backgroundColor;
				origBGImage = this.style.backgroundImage;	
				origBGpos = this.style.backgroundPosition;
				origBGrep = this.style.backgroundRepeat;
				origColor = this.style.color;
				origFontWeight = this.style.fontWeight;
				origOutline = this.style.outline;
				origTextDecoration = this.style.textDecoration;				
				//now replace with our accessibility settings
				if (this.parentNode.parentNode.parentNode.parentNode.id=="footer") {
					this.style.color = "red";
					}
				else {
					this.style.backgroundColor = accHighlightBGColor;
					this.style.color = accHighlightColor;
					}
				this.style.outline = accHighlightOutline;
				this.style.textDecoration = accTextDecoration;
				if (this.parentNode.parentNode.parentNode.id=="productnav") {
					this.childNodes[1].style.color = "red";
					}
		 }
		tababbleItems[i].onblur=function(e) {
				//restore the original settings when leaving that link/field
				if (this.parentNode.parentNode.parentNode.parentNode.id=="footer") {
					this.style.color = origColor;
					}
				else {
					this.style.backgroundColor = origBGColor;
					this.style.color = origColor;
					}
				this.style.fontWeight = origFontWeight;
				this.style.outline = origOutline;
				this.style.textDecoration = origTextDecoration;
				if (this.parentNode.parentNode.parentNode.id=="productnav") {
					this.childNodes[1].style.color = origColor;
					}
		 }
		}
	}
}
function stripAccessKeyInfo(el) {
	if (el) 
	{
	el.setAttribute("title","");
	el.setAttribute("accesskey","");
	}
}
function disableAccessKeys(){
	accessKeysDisabled = true;
	if (accessKeysDisabled)
	{
		stripAccessKeyInfo(document.getElementById("p_search_text"));
		stripAccessKeyInfo(document.getElementById("maincontent-skipdest"));
		stripAccessKeyInfo(document.getElementById("contactus-link"));
		stripAccessKeyInfo(document.getElementById("sitemap-link"));
	}
}
function accessHotKey(){
	window.document.onkeypress=function(e){
	if (enableAccessibilityHotKey)
	 {
		var code;
		if (!e) var e = window.event;
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;
		var character = String.fromCharCode(code);
		if (character==",")
		 {
			//location.href="/about_nationwide/accessibility/web_access.htm#options";
			location.href="/accessibility/default.htm?ref=" +location.href;
			}
		}
	}
}
function initAccessibilityFeatures(){
//these apply to all users:
showSkipLinks(); // makes skip links visible for tabbing/kbd users
accessHotKey(); // allows hotkey [,] for jump to accessibility page
var showHighlights = false;
var useAccesskeys = true;

// these are the optional features:
if(readCookie("accessibility").length>0) {
	//	cookie found. Let's see what they've set
	var arrAccCookie = readCookie("accessibility").split("@@");
	for (i=0; i<arrAccCookie.length; i++) {
			if (arrAccCookie[i]=="focusHilight=true") {
				showHighlights = true;
				}
			if (arrAccCookie[i]=="accessKeys=false") {
				useAccesskeys = false;
				}
		}
	if (showHighlights) {
		highlightLinksAndFormControls();
		}
	if (!useAccesskeys) {
		disableAccessKeys();
		}
	}
else {
	disableAccessKeys();
	}
}
addEvent(window, 'load', initAccessibilityFeatures, false);

// END ACCESSIBILITY ENHANCEMENTS
// - - - - - - - 

/* START =Concertina */
/*
We may want to migrate this to jQuery for smoother 
transitions. For now it's hand-rolled/custom.
*/

//global constants
var collapsed = false;
var useShowAllLink = false;
var hideAllTitle = "Hide all the topics in this list";
var showAllTitle = "Show all the topics in this list";
var hideAllText = "Hide all";
var showAllText = "Show all";
var plusImageURL = "url(/_common_images/concertinaPlus.gif)";
var minusImageURL = "url(/_common_images/concertinaMinus.gif)";
var dontShowAll = "";
//check to see if fragment identifier in URL
var u = location.href;
var anch = u.split("#")[1];

function togglePlusMinus(whichLink, plusOrMinus){
	if (plusOrMinus=="plus")	{
		whichLink.style.backgroundImage = plusImageURL;
		whichLink.style.backgroundRepeat = "no-repeat";
		whichLink.style.backgroundPosition = "4px 4px";
	}
	if (plusOrMinus=="minus")	{
		whichLink.style.backgroundImage = minusImageURL;
		whichLink.style.backgroundRepeat = "no-repeat";
		whichLink.style.backgroundPosition = "4px 4px";
	}
}
function concertinaOpenCloseAll(source,displayState){
	if(displayState=="open"){
		displayState = "block";
		collapsed = false;
	}
	if(displayState=="close"){
		displayState = "none";
		collapsed = true;
	}
	if(source.tagName!=null){
		//only handling this individual concerina, not all of them
		var ul = source.parentNode;
	}
	else{
		var ul = document.getElementsByTagName("ul");
	}
	if(ul.length>0){
		for(i=0; i<ul.length; i++){
			if(ul[i].className=="concertina"){
				var ul_divs = ul[i].getElementsByTagName("div");
				for(j=0; j<ul_divs.length; j++){
					if (ul_divs[j].className=="ListHead"){
						if(collapsed){
							togglePlusMinus(ul_divs[j].getElementsByTagName("a")[0],"plus");
						}
						else{
							togglePlusMinus(ul_divs[j].getElementsByTagName("a")[0],"minus");
						}
					}
					if(ul_divs[j].className=="ListBody"){
						ul_divs[j].style.display=displayState;
					}
				}
			} // end of if ul concertina class
		} //end of ul for loop
	}
	else{
		if(ul.getElementsByTagName){
			var ul_divs = ul.getElementsByTagName("div");
			for(k=0; k<ul_divs.length; k++){
				if (ul_divs[k].className=="ListHead"){
					if(collapsed){
						togglePlusMinus(ul_divs[k].getElementsByTagName("a")[0],"plus");
					}
					else{
						togglePlusMinus(ul_divs[k].getElementsByTagName("a")[0],"minus");
					}
				}
				if(ul_divs[k].className=="ListBody"){
					ul_divs[k].style.display=displayState;
				}
			}
		}
	}
}
function showHideSingleLink(thisLink){
var listbody = thisLink.parentNode.parentNode.getElementsByTagName("div")[1]	;
if (listbody.style.display =="none"){
	listbody.style.display = "block";
	togglePlusMinus(thisLink,"minus");
	}
else{
	listbody.style.display = "none";
	togglePlusMinus(thisLink,"plus");
	}
}
function addHoverBehaviourtoTab()
{
	$(".ListHead a.toggleSwitch, a.concertina_showall").focus(function(){
	$(this).addClass("hover");
	}).blur(function(){
	$(this).removeClass("hover");
	});
}
function initConcertina(){
concertinaOpenCloseAll(this,'close');
var ul = document.getElementsByTagName("ul");
for (i=0; i<ul.length; i++){
	if (ul[i].className=="concertina"){
		//add show/hide all link after list if there is more than one list item contained
		var listCount = ul[i].getElementsByTagName("li").length;
		useShowAllLink = ((listCount > 1)&&(!dontShowAll));
		if (useShowAllLink){
			var showAllLink = document.createElement("a");
			var showAllLinkText = document.createTextNode(showAllText);
			showAllLink.setAttribute("href","#");
			showAllLink.setAttribute("class","concertina_showall");
			showAllLink.setAttribute("className","concertina_showall");
			showAllLink.setAttribute("title", showAllTitle);
			showAllLink.appendChild(showAllLinkText);
			ul[i].appendChild(showAllLink, ul[i].parentNode);
			showAllLink.onclick = function(e){
				if (collapsed){
					concertinaOpenCloseAll(this,'open');
					this.setAttribute("title", hideAllTitle);
					this.innerHTML=hideAllText;
					}
				else{
					concertinaOpenCloseAll(this,'close');
					this.setAttribute("title", showAllTitle);
					this.innerHTML=showAllText;
					}
				return false;
				}
			}
		//find the ListHead divs
		var ul_divs = ul[i].getElementsByTagName("div");
		for (j=0; j<ul_divs.length; j++){
			if (ul_divs[j].className=="ListHead"){
				//now find the link that's inside that listHead
				var this_a = ul_divs[j].getElementsByTagName("a")[0];
				this_a.onclick = function(e){
						showHideSingleLink(this);
						return false;
					}
				// check to see if this link is the target of an external link 
				// (with a fragment identifier, e.g. a href="QandA.htm#q5
				if ((anch)&&(anch.length>0)){
					if (this_a.name == anch){
						showHideSingleLink(this_a);
						}
					}
				}
			}
		} // end of if ul concertina class
	} //end of ul for loop
	if (jQueryUsed) addHoverBehaviourtoTab();
}
/* END =Concertina */

	function setCookiesInMortgages(){
		var h = document.location.href.toLowerCase();
		if(h.indexOf("/mortgages/") != -1){
			if(h.indexOf("/mortgages/firsttimebuyers") != -1){
				writeCookie("buyerType","ftb",(24*7));
			}
			if(h.indexOf("/mortgages/newcustomers/movinghome.htm") != -1){
				writeCookie("buyerType","nc-mh",(24*7));
			}
			if(h.indexOf("/mortgages/newcustomers/remortgaging.htm") != -1){
				writeCookie("buyerType","nc-r",(24*7));
			}
			if(h.indexOf("/mortgages/existingcustomers/movinghome.htm") != -1){
				writeCookie("buyerType","ec-mh",(24*7));
			}
			if(h.indexOf("/mortgages/existingcustomers/topupmortgage.htm") != -1){
				writeCookie("buyerType","ec-bm",(24*7));

			}
			if(h.indexOf("/mortgages/existingcustomers/switchmortgagemiddeal.htm") != -1){
				writeCookie("buyerType","ec-sf",(24*7));
			}
			if(h.indexOf("/mortgages/existingcustomers/switchmortgagedealending.htm") != -1){
				writeCookie("buyerType","ec-de",(24*7));
			}
		}
	}
	setCookiesInMortgages();

var personalLoanFlashToolUsageCount = 1;
function personalLoanFlashToolUsage(){
	// page taggging //////////////////////////////
	s.products = "Product;Personal Loan;;;;evar37=Loan";
	s.prop4 = s.pageName + " (" + (personalLoanFlashToolUsageCount) + ")";
	s.eVar4 = "Personal Loan - Flash";
	s.eVar37 = "Loan"
	s.events = "event4";
	s.linkTrackVars = "products,events,prop4,eVar4,eVar37";
	s.linkTrackEvents = "event4";
	s.tl(true, "o","Tool usage - Personal Loan - Flash");
	s.products="";s.prop4="";s.eVar4="";s.eVar37="";s.events="";s.linkTrackVars="None";s.linkTrackEvents="None";
	personalLoanFlashToolUsageCount++;
}
// do not load automatically




/* ^^^ All non-jQuery (standard) javascript *above here please) ^^^ */ 
/* ===========================================================================*/
/* All jQuery scripts *below* here please ...*/
/*  START jQuery functions*/ 
function doJQueryFunctions(){
if (jQueryUsed){	
		
var unsupported_safari = (((navigator.userAgent.indexOf("Version/3")==-1)&&(navigator.userAgent.indexOf("Version/4")==-1))&&($.browser.safari));
var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() );
var is_ie;
var is_ie_6;
var is_ie_7;
var is_ie_8;
var is_not_ie = (!is_ie);
var is_safari;
var is_mozilla;
var is_opera;
var browserVersion;
browserVersion = parseInt($.browser.version);
is_ie = ($.browser.msie);
is_ie_6 = (is_ie && (browserVersion==6));
is_ie_7 = (is_ie && (browserVersion==7));
is_ie_8 = (is_ie && (browserVersion==8));
if (is_chrome) {unsupported_safari = false;}
is_safari = ($.browser.safari);
is_mozilla = ($.browser.mozilla);
is_opera = ($.browser.opera);
var supports_png24 = true;
if ($.browser.msie) {
if (($.browser.version) == "6.0") {
	supports_png24 = false;
	}
}
// =browser identification applied to body for CSS use
if (is_ie) $("body").addClass("ie");
if (is_ie_6) $("body").addClass("ie6");
if (is_ie_7) $("body").addClass("ie7");
if (is_ie_8) $("body").addClass("ie8");
if (is_chrome) $("body").addClass("chrome");
if (is_opera) $("body").addClass("opera");
if ((is_safari)&&(!unsupported_safari)) $("body").addClass("safari");
if (is_mozilla) $("body").addClass("mozilla");
if ((is_chrome)||(is_opera)||((is_safari)&&(!unsupported_safari))||(is_mozilla)) $("body").addClass("notie");


function addProductNavTabGradients(){
	$("a.active").parent().prev().addClass("activeTabLeft");
	$("a.active").parent().next().addClass("activeTabRight");
	$("a.active").parent().prev().find("a").append("<div class=\"added\">");
	$("a.active").parent().next().find("a").append("<div class=\"added\">");
}
addProductNavTabGradients();


/* mortgage apply page-ab */
function mortgageApply(){
	if($("div#mortgageApply").length>0){
		// set up
		$("div#mortgageApply .step").not(".one").hide();
		$("div#mortgageApply ul#steps li.one").data("step","one");
		$("div#mortgageApply ul#steps li.two").data("step","two");
		$("div#mortgageApply ul#steps li.three").data("step","three");
		$("div#mortgageApply ul#steps li.four").data("step","four");
		$("div#mortgageApply ul#steps li.five").data("step","five");
		//steps click
		$("div#mortgageApply ul#steps li").click(function(){	
			$(".step").hide();	
			$("div#mortgageApply ul#steps li").removeClass("selected");
			$("div#mortgageApply ul#steps li.last").removeClass("selected");
			$("div#mortgageApply ul#steps li.last-selected").addClass("last");
			$("div#mortgageApply ul#steps li.last").removeClass("last-selected");
			if($(this).hasClass("last")){	
				$(this).removeClass("last");
				$(this).addClass("last-selected");
			}
			else{
				$(this).addClass("selected");
			}
			$("div#mortgageApply div." + $(this).data("step")).show();
			return false;
		});
		//steps hover
		$("div#mortgageApply ul#steps li").hover(function(){

			$("div#mortgageApply .step").hide();		
			$("div#mortgageApply div." + $(this).data("step")).show();

			if(!$(this).hasClass("last") && !$(this).hasClass("last-selected")){ //completed class
					$(this).addClass("hover");
				}else{
					$(this).addClass("last-hover");
				}
		},
		function(){
			if(!$(this).hasClass("last") && !$(this).hasClass("last-selected")){ //completed class
					$(this).removeClass("hover");
				}else{
					$(this).removeClass("last-hover");
				}					
			$("div#mortgageApply ul#steps li").each(function(){
				if(	$(this).hasClass("selected") || $(this).hasClass("last-selected") ){	
					$(".step").hide();
					$("div." + $(this).data("step")).show();			
				}
			});					
		});
	}
}
mortgageApply();
function mortgageRatesButton(){
//	btnMortgageRates
	$("#btnMortgageRates").click(function(){
		var buyertype = $("#selectMortgageRates").val();
		var propertyvalue = $("#txtValueOfProperty").val()
		var mortgagerequired = $("#txtMortgageRequired").val()
		
		if(isNaN(propertyvalue) || propertyvalue==""){propertyvalue = 0;}
		if(isNaN(mortgagerequired) || mortgagerequired==""){mortgagerequired = 0;}		
		
		var rateUrl = "/mortgages-november09/interestrates-types/rates.htm?buyerType=" + buyertype + "&propertyValue=" + propertyvalue + "&mortgageAmount=" + mortgagerequired
		window.location = rateUrl;

		return false;
	});
}
mortgageRatesButton();
/* end */

//red/blue/yellow collapsible panel
//	/_common_images/collapsiblepanel/
function setupCollapsiblePanel(){
	if ($(".collapsibleInfoPanelWrapper").length > 0){
		//if ($.browser.msie == true) {document.execCommand('BackgroundImageCache', false, true);}
		//hide them all, set up the cursor style, add in the images, title attributes etc..		
		$(".collapsibleInfoPanelWrapper>.collapsibleInfoPanel>.collapsibleInfoPanelContent").hide();
		$(".collapsibleInfoPanelWrapper>.collapsibleInfoPanel>h3>a").css("cursor","pointer");
		$(".collapsibleInfoPanelWrapper>.collapsibleInfoPanel>h3>a").attr("title","Click to hide / reveal content under this heading (keyboard users hit Return key)");		
		$(".collapsibleInfoPanelWrapper.blue>.collapsibleInfoPanel>h3>a").css("background","url(/_common_images/collapsiblepanel/sprite.gif) 0px -21px no-repeat");
		$(".collapsibleInfoPanelWrapper.red>.collapsibleInfoPanel>h3>a").css("background","url(/_common_images/collapsiblepanel/sprite.gif) -564px -21px no-repeat");
		$(".collapsibleInfoPanelWrapper.yellow>.collapsibleInfoPanel>h3>a").css("background","url(/_common_images/collapsiblepanel/sprite.gif) -1128px -21px no-repeat");
		$(".collapsibleInfoPanelWrapper.aqua>.collapsibleInfoPanel>h3>a").css("background","url(/_common_images/collapsiblepanel/sprite.gif) -1692px -21px no-repeat");			
		//click toggle
		$(".collapsibleInfoPanelWrapper>.collapsibleInfoPanel>h3>a").toggle(function(){
			$(this).parent().siblings(".collapsibleInfoPanelContent").children().fadeIn(1100);
			$(this).parent().siblings(".collapsibleInfoPanelContent").slideDown(1000);	
		}, 	function(){
			$(this).parent().siblings(".collapsibleInfoPanelContent").children().fadeOut(800);	
			$(this).parent().siblings(".collapsibleInfoPanelContent").slideUp(1000);
		});
		
		//hover effect
		$(".collapsibleInfoPanelWrapper>.collapsibleInfoPanel>h3>a").hover(function(){
			$(this).addClass("hovered");
		}, function(){
			$(this).removeClass("hovered");
		});					
		//focus/blur effect
		$(".collapsibleInfoPanelWrapper>.collapsibleInfoPanel>h3>a")
			.focus(function(){$(this).addClass("hovered");})
			.blur(function(){$(this).removeClass("hovered");});		
			
	}
}
setupCollapsiblePanel();

function rotateImage_PublicAffairsAndPolicy(){
	//only bother if the id exists on the page
	if($("#publicaffairs-img-rotate").length > 0)
	{		
		var NUMBER_OF_IMAGES = 17
		var img_src = "";
		var img_alt = "";
		var img_anchor = "";			
		var rnd = Math.ceil(Math.random()*NUMBER_OF_IMAGES);
		switch(rnd){
		case 1:img_src = "/publicaffairs/210/12171_033_210px.jpg"; img_alt = "Ian Pearson MP speaking at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_033.jpg"; break;
		case 2:img_src = "/publicaffairs/210/12171_044_210px.jpg"; img_alt = "Dr Vince Cable MP speaking at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_044.jpg"; break;				
		case 3:img_src = "/publicaffairs/210/12171_052_210px.jpg"; img_alt = "David Harker (Chief Executive of Citizens Advice) speaking at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_052.jpg"; break;
		case 4:img_src = "/publicaffairs/210/12171_057_210px.jpg"; img_alt = "Alison Seabeck MP and Maxine Taylor (Nationwide’s Divisional Director) at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_057.jpg"; break;
		case 5:img_src = "/publicaffairs/210/12171_058_210px.jpg"; img_alt = "David Harker (Chief Executive of Citizens Advice), Tony Prestedge (Executive Director at Nationwide) and Andy Love MP at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_058.jpg"; break;
		case 6:img_src = "/publicaffairs/210/12171_059_210px.jpg"; img_alt = "David Harker (Chief Executive of Citizens Advice), Mary Creagh MP and Caroline Hallatt (Nationwide’s Head of Corporate Responsibility) at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_059.jpg"; break;
		case 7:img_src = "/publicaffairs/210/12171_060_210px.jpg"; img_alt = "David Harker (Chief Executive of Citizens Advice), David Amess MP and Caroline Hallatt (Nationwide’s Head of Corporate Responsibility) at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_060.jpg"; break;
		case 8:img_src = "/publicaffairs/210/12171_061_210px.jpg"; img_alt = "David Harker (Chief Executive of Citizens Advice), George Mudie MP and Caroline Hallatt (Nationwide’s Head of Corporate Responsibility) at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_061.jpg"; break;
		case 9:img_src = "/publicaffairs/210/12171_063_210px.jpg"; img_alt = "David Harker (Chief Executive of Citizens Advice), Doug Naysmith MP (1997-2010) and Maxine Taylor (Divisional Director at Nationwide) at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_063.jpg"; break;
		case 10:img_src = "/publicaffairs/210/11931_033_210px.jpg"; img_alt = "Sylvia Heal MP (1997-2010) and Maxine Taylor, Nationwide’s Divisional Director for Corporate Affairs, at the Nationwide Education parliamentary drop in session";img_anchor = "/publicaffairs/sized/11931_033.jpg"; break;
		case 11:img_src = "/publicaffairs/210/12171_014_210px.jpg"; img_alt = "Mark Hoban MP, Graham Beale (Chief Executive of Nationwide), David Harker (Citizens Advice), Dr Vince Cable M and Ian Pearson MP at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_014.jpg"; break;
		case 12:img_src = "/publicaffairs/210/RichardCabornMP-Carol_210px.jpg"; img_alt = "Caroline Hallatt, Nationwide’s Head of Corporate Responsibility, and Richard Caborn, MP for Sheffield Central (1983-2010), at the British International Disability Swimming Championships";img_anchor = "/publicaffairs/sized/RichardCabornMP-Carol.jpg"; break;
		case 13:img_src = "/publicaffairs/210/12171_040_210px.jpg"; img_alt = "Mark Hoban MP speaking at the launch of MoneyActive";img_anchor = "/publicaffairs/sized/12171_040.jpg"; break;
		case 14:img_src = "/publicaffairs/210/RichardCabornMP_210px.jpg"; img_alt = "Caroline Hallatt, Nationwide’s Head of Corporate Responsibility, and Richard Caborn, MP for Sheffield Central (1983-2010), and Gordon Neale, Director of Events at DSE, at the British International Disability Swimming Championships";img_anchor = "/publicaffairs/sized/RichardCabornMP.jpg"; break;
		case 15:img_src = "/publicaffairs/210/NickCleggMP_small.jpg"; img_alt = "Nick Clegg MP supporting MoneyActive";img_anchor = "/publicaffairs/sized/NickCleggMP.jpg"; break;
		case 16:img_src = "/publicaffairs/210/anne-snelgrove-mp-01.jpg"; img_alt = "Anne Snelgrove MP (2005-2010) viewing a Nationwide Education lesson";img_anchor = "/publicaffairs/sized/NickCleggMP.jpg"; break;
		case 17:img_src = "/publicaffairs/210/anne-snelgrove-mp-02.jpg"; img_alt = "Anne Snelgrove MP (2005-2010) viewing a Nationwide Education lesson";img_anchor = "/publicaffairs/sized/NickCleggMP.jpg"; break;
		default:break;
		}
		if(img_src!="" && img_alt!="" && img_anchor!="")
		{
			$("#publicaffairs-img-rotate").show();
			$("#publicaffairs-img-rotate").attr("src",img_src);
			$("#publicaffairs-img-rotate").attr("alt",img_alt);
			$("#publicaffairs-img-rotate").wrap("<a href=\"" + img_anchor + "\" target=\"_blank\"></a>");					
		}
	}
}
rotateImage_PublicAffairsAndPolicy();

function applyProductNavHoverWithTab()
	/* Top level tabs - apply hover behaviour for tabbing/keyboard users */
	{
	$("div#productnav>ul>li>a:not(a.active)")
		.focus(function(e){$(this).addClass("productNavhover");})
		.blur(function(e){$(this).removeClass("productNavhover");});	
	}
			
function applyProductSubNavHoverWithTab()
/* tab subnavigation - apply hover behaviour for tabbing/keyboard users */
{
$("#headernav-subnav ul li a")
	.focus(function(e){$(this).addClass("productSubNavhover");})
	.blur(function(e){$(this).removeClass("productSubNavhover");});
}	
function applyLeftNavHoverWithTab()
/* left nav - apply hover behaviour for tabbing/keyboard users */
{
	$("div#leftnav li a")
		.focus(function(e){$(this).addClass("leftNavHover");})
		.blur(function(e){$(this).removeClass("leftNavHover");});
}	
function applyLeftNavHoverWithTab_mtg()
/* left nav - apply hover behaviour for tabbing/keyboard users */
{
	$("div#mtge-links a")
		.focus(function(e){$(this).addClass("mtgeHover");})
		.blur(function(e){$(this).removeClass("mtgeHover");});
}	
applyProductNavHoverWithTab();
applyProductSubNavHoverWithTab();
applyLeftNavHoverWithTab();
applyLeftNavHoverWithTab_mtg();	

$(".breadcrumbtext").click(function(e){
	$("#cc-tabs-wrapper").slideToggle("medium");
});

var unsupported_safari = (((navigator.userAgent.indexOf("Chrome")==-1) && (navigator.userAgent.indexOf("Version/3")==-1)&&(navigator.userAgent.indexOf("Version/4")==-1))&&($.browser.safari && (navigator.userAgent.indexOf("Chrome")!= -1)));

/* footer show/hide stuff */
function footerExpandCollapse(){
if(!unsupported_safari){
	//hide 'Explore Nationwide' for all pages
	$("#footer .footer-inner, #footer-homepage.collapse .footer-inner").hide();
	//hide 'Explore our products' but *only* on the home page
	$("#footer .footer-inner").hide();
	
	$("#footer h4 a").toggle(function(e){
			$("#footer span#exploreInd").addClass("expanded");
			$("#footer .footer-inner").slideDown('medium');
			return false;
		}, function(e){
			$("#footer span#exploreInd").removeClass("expanded");
			$("#footer .footer-inner").slideUp('medium');
			return false;
		});
	$("#footer-homepage h4 a").toggle(function(e){
			$("#footer-homepage span#exploreInd").addClass("expanded");
			$("#footer-homepage .footer-inner").slideDown('medium');
			return false;
		}, function(e){
			$("#footer-homepage span#exploreInd").removeClass("expanded");
			$("#footer-homepage .footer-inner").slideUp('medium');
			return false;
		});
	}
}
footerExpandCollapse();

function applyButtonStyles(){
	//start button behaviour
	$(".darkbg .button").wrap("<b class=\"button\"></b>")
	$("a.button, input.button").addClass("buttonstyles");
	$("a.apply, input.apply").addClass("applyButton");
	$("a.info, input.info").addClass("infoButton");
	$("a.button.big, input.button.big").addClass("bigFatButton");

	$("a.button, input.button").each(function(e){
		var btLength;
		if ($(this).html()) {
			btLength = $(this).html().length;
			}
		else {
			btLength = $(this).attr("value").length+3;
			}
		if (btLength<5) {
			$(this).addClass("smallbutton");
		}
		if ((btLength>10) && (btLength<21)) {
			$(this).addClass("bigbutton");
		}
		if ((btLength>20) && (btLength<24)) {
			$(this).addClass("hugebutton");
		}
		if (btLength>=24) {
			$(this).addClass("megabutton");
		}
	});

	$("a.button:not(\"#exitAnd404PagewrapperInner #primaryCampaign a\"), input.button").each(function(){
		var buttonType="";
		if ($(this).hasClass("apply")){buttonType="Apply";}
		if ($(this).hasClass("info")) {buttonType="Info";}
		var clickStyle = "button" + buttonType + "Click";
		var hoverStyle = "button" + buttonType + "Hover";
		$(this)
			.mousedown(function(e){	
				$(this).removeClass(clickStyle);
				$(this).addClass(clickStyle);
			})
			.mouseup(function(e){
				$(this).removeClass(clickStyle);
			})
			.mouseover(function(e){
				$("a.apply, input.apply").removeClass(clickStyle);
				$(this).addClass(hoverStyle);
			})
			.mouseout(function(e){
				$(this).removeClass(hoverStyle);
			})
			.focus(function(e){
				$(this).addClass(hoverStyle);
			})
			.blur(function(e){
				$(this).removeClass(hoverStyle);
			});
	});
	//end button behaviour
}
applyButtonStyles();

var thisActBarBgPos;
var thisActBarPosX;
var thisActBarPosY;
	
function actionBarButtonBehaviour(){	
	//for mousers	
	$("div.actionBar div b").hover(function(){
		thisActBarBgPos = $(this).css("background-position");
		if(thisActBarBgPos == 'undefined' || thisActBarBgPos == null){
			thisActBarBgPos = $(this).css('background-position-x') + " " + $(this).css('background-position-y');
		}
		thisActBarBgPos = thisActBarBgPos.replace(/px/g,"").split(" ");
		thisActBarPosX = thisActBarBgPos[0];
		thisActBarPosY = thisActBarBgPos[1];
		$(this).css("background-position","-130px " + thisActBarPosY + "px");
		},function(){
			$(this).css("background-position","-5px " + thisActBarPosY + "px");
		})
	
	$("div.actionBar div b").mousedown(function(){
			thisActBarBgPos = $(this).css("background-position");
			if(thisActBarBgPos == 'undefined' || thisActBarBgPos == null){
				thisActBarBgPos = $(this).css('background-position-x') + " " + $(this).css('background-position-y');
			}
			thisActBarBgPos = thisActBarBgPos.replace(/px/g,"").split(" ");
			thisActBarPosX = thisActBarBgPos[0];
			thisActBarPosY = thisActBarBgPos[1];
			$(this).css("background-position","-255px " + thisActBarPosY + "px");
		}).mouseup(function(){
			thisActBarBgPos = $(this).css("background-position");
			if(thisActBarBgPos == 'undefined' || thisActBarBgPos == null){
				thisActBarBgPos = $(this).css('background-position-x') + " " + $(this).css('background-position-y');
			}
			thisActBarBgPos = thisActBarBgPos.replace(/px/g,"").split(" ");
			thisActBarPosX = thisActBarBgPos[0];
			thisActBarPosY = thisActBarBgPos[1];
			$(this).css("background-position","-130px " + thisActBarPosY + "px");
		})
		
	//for kbd peeps
	$("div.actionBar div a").focus(function(){
		thisActBarBgPos = $(this).next().css("background-position");
		if(thisActBarBgPos == 'undefined' || thisActBarBgPos == null){
			thisActBarBgPos = $(this).next().css('background-position-x') + " " + $(this).next().css('background-position-y');
		}
		thisActBarBgPos = thisActBarBgPos.replace(/px/g,"").split(" ");
		thisActBarPosX = thisActBarBgPos[0];
		thisActBarPosY = thisActBarBgPos[1];
		$(this).next().css("background-position",(thisActBarPosX-125) + "px " + thisActBarPosY+ "px");
		}).blur(function(){
			$(this).next().css("background-position",thisActBarPosX + "px " + thisActBarPosY+ "px");
		})

}
actionBarButtonBehaviour();

function tidyUpHeaderSublinks(){
	// remove the right-most 'pipe' on the links in blue header section
	$("#headernav-subnav li:last a").addClass("headernavLastLink");
}
tidyUpHeaderSublinks();

function doFlashReplace() {
	var requiredFlashMajorVersion = 8;
	var requiredFlashMinorVersion = 0;
	var requiredFlashRevision = 0;
	flashCapable = DetectFlashVer(requiredFlashMajorVersion, requiredFlashMinorVersion, requiredFlashRevision);
	var safariSmartAd = (is_safari && ($("div.smartad").length!=0));
	if (flashCapable && (!safariSmartAd)){
		$(".doFlashReplace").each(function(){
			//build up embed code
			var flashObjectEmbedCode;
			//find attributes for flash movie
			var $thisImage = $(this).find("img:not(.clickInd)");
			//get the URL from the href and pass it on to the Flash movie
			var flashButtonLink = $(this).find("a.hpMoreLink").attr("href");
			// convert the qrystring format to the format that Flash understands
			// change & to %26
			flashButtonLink = flashButtonLink.replace(/\&/g,"%26");
			//alert(flashButtonLink);
			var swfSrc = $thisImage.attr("src").replace(".gif","").replace(".jpg","").replace(".png","") + ".swf?flashButtonLink=" + flashButtonLink;
			//alert(swfSrc)
			var swfFlashVars;
			var swfWidth=$thisImage.width();
			var swfHeight=$thisImage.height();
			$(this).width(swfWidth);
			$(this).height(swfHeight);
			//check for overridden flash attributes
			if (typeof($thisImage.attr("flashsrc")) != "undefined") {
				if ($thisImage.attr("flashsrc").length>0) {swfSrc=$thisImage.attr("flashsrc")};
			}
			if (typeof($thisImage.attr("flashwidth")) != "undefined") {
				if ($thisImage.attr("flashwidth").length>0) {swfWidth=$thisImage.attr("flashwidth")};
			}
			if (typeof($thisImage.attr("flashheight")) != "undefined") {
				if ($thisImage.attr("flashheight").length>0) {swfHeight=$thisImage.attr("flashheight")};
			}
			if (typeof($thisImage.attr("flashvars")) != "undefined") {
				if ($thisImage.attr("flashvars").length>0) {swfFlashVars=$thisImage.attr("flashvars")};
			}
			flashObjectEmbedCode = "<div class=\"objectWrapper\">";
			flashObjectEmbedCode += "\n<object";
			flashObjectEmbedCode += " classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
			flashObjectEmbedCode += " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"";
			flashObjectEmbedCode += " width=\"" + swfWidth + "\"";
			flashObjectEmbedCode += " height=\"" + swfHeight + "\"";
			flashObjectEmbedCode += ">";
			flashObjectEmbedCode += "\n<param name=\"wmode\" value=\"opaque\" \/>";
			flashObjectEmbedCode += "\n<param name=\"movie\" value=\"" + swfSrc + "\" \/>";
			flashObjectEmbedCode += "\n<param name=\"width\" value=\"" + swfWidth + "\" \/>";
			flashObjectEmbedCode += "\n<param name=\"height\" value=\"" + swfHeight + "\" \/>";
			flashObjectEmbedCode += "\n<param name=\"FlashVars\" value=\"" + swfFlashVars + "\" \/>";
			flashObjectEmbedCode += "\n<param name=\"quality\" value=\"high\">";
			flashObjectEmbedCode += "\n<embed";
			flashObjectEmbedCode += "\n src=\"" + swfSrc + "\"";
			flashObjectEmbedCode += "\n width=\"" + swfWidth + "\"";
			flashObjectEmbedCode += "\n height=\"" + swfHeight + "\"";
			flashObjectEmbedCode += "\n FlashVars=\"" + swfFlashVars + "\"";
			flashObjectEmbedCode += "\n quality=\"high\"";
			flashObjectEmbedCode += "\n wmode=\"opaque\"";
			flashObjectEmbedCode += "\n type=\"application/x-shockwave-flash\"";
			flashObjectEmbedCode += "\n pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"";
			flashObjectEmbedCode += ">";
			flashObjectEmbedCode += "\n<\/embed>";
			flashObjectEmbedCode += "\n<\/object>";
			flashObjectEmbedCode += "\n<\/div>";
			//embed flash movie, position using abs pos over existing html version
			$(this).append(flashObjectEmbedCode).addClass("hasFlash");
			//make sure survey can fit over top if launched
			$("#notifications").css("z-index","3000");
		});
	}
	$(".doFlashReplace").css("background","none");
	$(".doFlashReplace img, .doFlashReplace a").css("visibility","visible")
}

if (!unsupported_safari) {
	doFlashReplace();
}

function doFlashReplaceExt(){
	var requiredFlashMajorVersion = 9;
	var requiredFlashMinorVersion = 0;
	var requiredFlashRevision = 0;
	flashCapable = DetectFlashVer(requiredFlashMajorVersion, requiredFlashMinorVersion, requiredFlashRevision);
	var safariSmartAd = (is_safari && ($("div.smartad").length!=0));
	if (flashCapable && (!safariSmartAd))
	{
		$(".doFlashReplaceExt").each(function(){
			//build up embed code
			var flashObjectEmbedCode;
			//find attributes for flash movie
			var $thisImage = $(this).find("img:not(.clickInd)");
			//get the URL from the href and pass it on to the Flash movie
			var flashButtonLink = $(this).find("a.hpMoreLink").attr("href");
			// convert the qrystring format to the format that Flash understands
			// change & to %26
			flashButtonLink = flashButtonLink.replace(/\&/g,"%26");
			//alert(flashButtonLink);
			var swfSrc = $thisImage.attr("src").replace(".gif","").replace(".jpg","").replace(".png","") + ".swf?flashButtonLink=" + flashButtonLink;
			var swfWidth=$thisImage.width();
			var swfHeight=$thisImage.height();
			$(this).width(swfWidth);
			$(this).height(swfHeight);
			//check for overridden flash attributes
			if (typeof($thisImage.attr("flashsrc")) != "undefined") {
				if ($thisImage.attr("flashsrc").length>0) {swfSrc=$thisImage.attr("flashsrc")};
			}
			if (typeof($thisImage.attr("flashwidth")) != "undefined") {
				if ($thisImage.attr("flashwidth").length>0) {swfWidth=$thisImage.attr("flashwidth")};
			}
			if (typeof($thisImage.attr("flashheight")) != "undefined") {
				if ($thisImage.attr("flashheight").length>0) {swfHeight=$thisImage.attr("flashheight")};
			}
			var movieUrl = "http://media.nationwide.co.uk/swfs/flashVideo.swf?flashButtonLink=/savings/bonds/footballbond/introduction.htm%3Fsource=nationwide%26campaign=footballbond%26execution=footballbond_andyandlou_home_slot1_07062010%26intcmp=Intcmp_int020";
			if(document.location.href.indexOf("/savings/default.htm") != -1){
				movieUrl = "http://media.nationwide.co.uk/swfs/nw_home_feature_ladies_500x300.swf?flashButtonLink=/savings/notice_accounts/championsaver/Introduction.htm%3Fsource=nationwide%26campaign=championsaver%26execution=butterflies_savings_slot1_07062010";
			}
			flashObjectEmbedCode = "<div class=\"objectWrapper\">";
			flashObjectEmbedCode += "\n<object";
			flashObjectEmbedCode += " classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"";
			flashObjectEmbedCode += " codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"";
			flashObjectEmbedCode += " width=\"" + swfWidth + "\"";
			flashObjectEmbedCode += " height=\"" + swfHeight + "\"";
			flashObjectEmbedCode += ">";
			flashObjectEmbedCode += "\n<param name=\"wmode\" value=\"opaque\" \/>";
			flashObjectEmbedCode += "\n<param name=\"movie\" value=\""+movieUrl+"\" \/>";
			flashObjectEmbedCode += "\n<param name=\"width\" value=\"" + swfWidth + "\" \/>";
			flashObjectEmbedCode += "\n<param name=\"height\" value=\"" + swfHeight + "\" \/>";
			flashObjectEmbedCode += "\n<param name=\"quality\" value=\"high\">";
			flashObjectEmbedCode += "\n<param name=\"allowScriptAccess\" value=\"always\">";
			flashObjectEmbedCode += "\n<embed";
			flashObjectEmbedCode += "\n src=\""+movieUrl+"\"";
			flashObjectEmbedCode += "\n width=\"" + swfWidth + "\"";
			flashObjectEmbedCode += "\n height=\"" + swfHeight + "\"";
			flashObjectEmbedCode += "\n quality=\"high\"";
			flashObjectEmbedCode += "\n allowScriptAccess=\"always\"";
			flashObjectEmbedCode += "\n wmode=\"opaque\"";
			flashObjectEmbedCode += "\n type=\"application/x-shockwave-flash\"";
			flashObjectEmbedCode += "\n pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"";
			flashObjectEmbedCode += ">";
			flashObjectEmbedCode += "\n<\/embed>";
			flashObjectEmbedCode += "\n<\/object>";
			flashObjectEmbedCode += "\n<\/div>";
			//embed flash movie, position using abs pos over existing html version
			$(this).append(flashObjectEmbedCode).addClass("hasFlash");
			
			//make sure survey can fit over top if launched
			$("#notifications").css("z-index","3000");
		});
	}
	$(".doFlashReplaceExt").css("background","none");
	$(".doFlashReplaceExt img, .doFlashReplaceExt a").css("visibility","visible");
}

if (!unsupported_safari) {
	doFlashReplaceExt();
	$("#flashoverlay").css("display", "block");
}
	
function screenReaderFriendlyMoreInfoLinks(){
	$("a[title]").not("a[title]>a[title]").each(function(){
	var strTitle = $(this).attr("title");
	$(this)
	.addClass("srhelpAdded")
	.append("<span class=\"srhelp\">. " + strTitle + "</span>");
	})
}
if (!is_safari) screenReaderFriendlyMoreInfoLinks();
$("span.srhelp").css({display: "block",position: "absolute",textIndent: "-30000px",overflow: "hidden",height:"0px",width:"0px"});

function clickableParents_generic(){
	$(".clickableParent:not(#insurance-wrapper .clickableParent, div.hasFlash)").each(function(){
	 var $thisLink = $(this).find("a:first, a.buttonPuretext");
		var $thisLinkHref = $thisLink.attr("href");
		var $thisLinkTarget = $thisLink.attr("target");
		var $thisLinkTitle = $thisLink.attr("title");
		var $thisLinkClick = "";
		if ($thisLinkTitle=="") {
			$thisLinkTitle = $thisLink.text();
		}
		if ($thisLink.hasClass("flashTakeoverLink"))
		{
			$thisLinkClick = " onclick=\"doSmartAd();return false;\"";
		}
		if (typeof($thisLinkTarget)!="undefined") {
			if ($thisLinkTarget.length>0) {
				$thisLinkTarget=" target=\"" + $thisLinkTarget + "\"";
			}
			else {
				$thisLinkTarget="";
			}
		}
	// the inline style - height and display - is only there to fix an irritiating bug in IE whereby 
	// background image on some headings was being removed. And other oddities related to
	// the clickable Parent stuff
	var nastyIEHack=" style=\"height:auto;display:block;\"";
	if (homePageClickableLink){
		//auto does not work for home page scenario. Need 1%.
		var nastyIEHack=" style=\"height:1%;display:block;\"";
	}
	$(this).wrapInner("<a" + nastyIEHack + " href=\"" + $thisLinkHref + "\"" + $thisLinkTarget + " class=\"addedLink noreposition\" tabindex=\"-1\" title=\"" + $thisLinkTitle + "\"" + $thisLinkClick + "></a>");
	});
}
clickableParents_generic();

function clickableParents_insuranceHomepage(){
	$("#insurance-wrapper .clickableParent").each(function(){
	 var $thisLink = $(this).find("div.container_content ul li a:first");
		var $thisLinkHref = $thisLink.attr("href");
		var $thisLinkTarget = $thisLink.attr("target");;
		var $thisLinkTitle = $thisLink.attr("title");
		if ($thisLinkTitle=="")$thisLinkTitle = $thisLink.text();
		if (typeof($thisLinkTarget)!="undefined") {
			if ($thisLinkTarget.length>0) {
				$thisLinkTarget=" target=\"" + $thisLinkTarget + "\"";
			}
			else {
				$thisLinkTarget="";
			}
		}
	$(this).find("p,img,h1,h2,h3").wrap("<a href=\"" + $thisLinkHref + "\"" + $thisLinkTarget + " class=\"addedLink noreposition\" tabindex=\"-1\" title=\"" + $thisLinkTitle + "\"></a>");
	});
}
clickableParents_insuranceHomepage();

function setUpSearchBoxes(){
	defSrchTxt = "Enter keyword or phrase";
	defAskTxt = "Ask a question";
	var srch = $("#p_search_text");
	var ask = $("#txtAsk");
	if (srch) //only run if there's a search box there!
	{
		if(srch.val()=="")srch.val(defSrchTxt);

		srch.click(function(){
			if ($(this).val()==defSrchTxt)srch.val("");
		})
		srch.focus(function(){
			$(this).select();
		})
	}
	if (ask) //only run if there's a search box there!
	{
		ask.val(defAskTxt);
		ask.click(function(){
			if ($(this).val()==defAskTxt)ask.val("");
		})
		ask.focus(function(){
			$(this).select();
		})
	}
}
setUpSearchBoxes();

function leftNavHasSubSection(){
	$("li.currentSection:has(ul)").each(function(){
		if ($(this).find("li.currentPage").length>0){
			$(this).addClass("hasSubSection");
		}
	})
	$("li.currentPage:has('ul')").addClass("hasSubSubSection");
}
leftNavHasSubSection();

function exclusiveOffersTermsLinks(){
	$("p.exclusiveOffersTerms a, a.exclusiveOffers").each(function(){
		$(this)
			.attr("title","Open terms and conditions in a new window")
			.click(function(){
				popUpWin($(this).attr("href"), "standard", "800", "550");
				return false;
			})
	});
}
exclusiveOffersTermsLinks();

function homeExitPageEffects_Rebrand(){
	if ($("#hpNov09").length>0){
		function passAskQuestionToMainSearch(){
			$("#frmAsk").submit(function(){
				if ($("#txtAsk").val() != "" && $("#txtAsk").val() != defAskTxt){
					$("#p_search_text").val($("#txtAsk").val());
					$("form[name=_search]").submit();
				}
				else{
					$("#txtAsk").focus();
					alert('Please enter a keyword or phrase in the ask box');
				}
				return false;
			})
		}
		passAskQuestionToMainSearch();
		
		/* add red pipes to popular searches */
		$("#hpNov09 #popular ul li:not(#popular ul li:last)").find("a").after("<b>|</b>")
		/* Use 'ask' form to pass through to search */
	
		/* popups in popular searches */
		$("#hpNov09 #popular a.popup").click(function(){
			popUpWin($(this).attr("href"),'console',790,700);
			return false;
		});
	}

	if (($("#hpNov09").length>0)||($("#exitAnd404Pagewrapper").length>0)){

		/* View rates on home/exit page */
		function viewRatesFromHomePage()
		{
			$("#frmHomeExitPageViewRates").submit(function(){
			var ratePage = $("#ddlHomeExitPageViewRates").val();
			if (ratePage!="Please select")
				{
				location.href = ratePage;
				}
			return false;
			});
		}
		viewRatesFromHomePage();

		//home/exit page click state effect
		$("#ibSignOnLink a, #signon-link a").mouseover(function(){
			$(this).addClass("hovered")
		}).mousedown(function(){
			$(this).removeClass("hovered")
			$(this).addClass("clicked")
		}).mouseup(function(){
			$(this).removeClass("clicked")
		}).mouseout(function(){
			$(this).removeClass("clicked")
			$(this).removeClass("hovered")
		});

		/* Exit page colour shift on quick links top menu*/
		$("#quickLinksList li:first").css("border-top","1px solid #e8e9ea")

		/* news ticker */
		var newsTickerCount = 0;
		var textInternval;
		$("#newsMessage").data("originalMsg",$("#newsMessage span").text());
		function doNewsTicker(){
			newsTickerCount++;
			$("#newsMessage span a").hide();
			$("#newsMessage strong")
				.fadeTo('fast',0.1)
				.fadeTo('fast',1)
				.fadeTo('fast',0.1)
				.fadeTo('fast',1,function(){
				var newsMsg = $("#newsMessage").data("originalMsg");
				var newsMsgLength = newsMsg.length;
				$("#newsMessage span a").text("").show();
				var i=0;
				function buildNewsLineText()
				{
					$("#newsMessage span a").text($("#newsMessage span a").text() + newsMsg.charAt(i));
					i++;                                                      
				}
				textInternval = setInterval(buildNewsLineText, 60);
			})
			clearInterval(textInternval);
		}
		//doNewsTicker();
		//setInterval(doNewsTicker, 6000);
		//go button hover effect
		$("input#btnHomeExitPageViewRatesGo").mouseover(function(){
			$(this).addClass("hovered")
		}).mouseout(function(){
			$(this).removeClass("hovered")
			$(this).removeClass("clicked")
		}).mousedown(function(){
			$(this).removeClass("hovered")
			$(this).addClass("clicked")
		})
	}
}
homeExitPageEffects_Rebrand();

//Stop IE flicker
if ($.browser.msie == true) {document.execCommand('BackgroundImageCache', false, true);}

function submitHover(){			
	$("#goRedirect, .goRedirect").hover(function(){$(this).attr("src","/_common_images/mortgage/gobutton.gif");
	},function(){$(this).attr("src","/_common_images/go-grey.gif");}); 
}
submitHover();

/*hpMoreLinks which include .wrap (wrapping text, shift chevrons to end of second line*/
function hpMoreLinkWrap(){
	if($("a.hpMoreLink").length>0){
		var chevronImg = $("a.hpMoreLink.wrap").css("background-image");
		$("a.hpMoreLink.wrap").css("background","none");
		$("a.hpMoreLink.wrap").append("<span></span>");
		$("a.hpMoreLink.wrap span").css({"display":"inline", "padding-left":"10px","margin-left":"5px"} );			
		$("body.ie a.hpMoreLink.wrap span").text(" ");
		if($("body").hasClass("opera"))
			$("a.hpMoreLink.wrap span").css("background"," " + chevronImg + " repeat scroll right -245px");
		else
			$("a.hpMoreLink.wrap span").css("background","rgba(255, 255, 255, 1.0) " + chevronImg + " repeat scroll right -245px");			
	}
}
hpMoreLinkWrap();
	
	/*
	END panelLinks layout 
	*/

if ($("#newsline_cycler").length>0){
	$("#newsline_cycler").cycle({
		fx:'scrollLeft',
		speed:800,
		timeout:5000,
		pause:1
		})
}

if($("#invPplLikeMeFader").length>0){
	$("#invPplLikeMeFader").cycle("fade");
}

function mortgageRatesButton(){
	$("#btnMortgageRates").click(function(){
				var buyertype = $("#selectMortgageRates").val();
				var propertyvalue = $("#txtValueOfProperty").val();
				var mortgagerequired = $("#txtMortgageRequired").val();                       
				if(isNaN(propertyvalue) || propertyvalue==""){propertyvalue = 0;}
				if(isNaN(mortgagerequired) || mortgagerequired==""){mortgagerequired = 0;}                        
				var rateUrl = "/mortgages/interestrates-types/rates.htm?buyerType=" + buyertype + "&propertyValue=" + propertyvalue + "&mortgageAmount=" + mortgagerequired
				window.location = rateUrl;
				return false;
	});
}
mortgageRatesButton();

function btnGoHover(){ 
	if($(".btnGo").length>0){		
		$(".btnGo").hover(function(){$(this).attr("src","/_common_images/buttons/btn_go_hover.gif");},function(){$(this).attr("src","/_common_images/buttons/btn_go_normal.gif");});
		$(".btnGo").mousedown(function(){$(this).attr("src","/_common_images/buttons/btn_go_click.gif");$(this).data("isDown","true");});
		$(".btnGo").mouseup(function(){$(this).attr("src","/_common_images/buttons/btn_go_normal.gif");$(this).data("isDown","false");});
		/*imgs only*/
		$("img.btnGo").mousemove(function(){if($(this).data("isDown")=="true"){$(this).attr("src","/_common_images/buttons/btn_go_hover.gif");$(this).data("isDown","false");}});
	}
}	
btnGoHover(); 

function btnCompareHover(){
	if($(".btnCompare").length > 0){
		$(".btnCompare").mouseover(function(){$(this).removeClass("btnCompare");$(this).addClass("btnCompareHover");});
		$(".btnCompare").mouseout(function(){$(this).addClass("btnCompare");$(this).removeClass("btnCompareHover");$(this).removeClass("btnCompareClick");});
		$(".btnCompare").mousedown(function(){$(this).removeClass("btnCompareHover");$(this).addClass("btnCompareClick");});            
	}
}
btnCompareHover();

function mortgageQuoteApplyButton(){
	if($(".btnQuoteApply").length > 0){
		$(".btnQuoteApply").mouseover(function(){$(this).addClass("btnQuoteApplyHover");});
		$(".btnQuoteApply").mouseout(function(){$(this).addClass("btnQuoteApply").removeClass("btnQuoteApplyHover").removeClass("btnQuoteApplyClick");});
		$(".btnQuoteApply").mousedown(function(){$(this).removeClass("btnQuoteApplyHover").addClass("btnQuoteApplyClick");});          
	}
}
mortgageQuoteApplyButton();

function setButtons(){
	if($(".btn").length > 0){
		$(".btn").mouseover(function(){$(this).addClass("btnHover");});
		$(".btn").mouseout(function(){$(this).addClass("btn").removeClass("btnHover").removeClass("btnClick");});
		$(".btn").mousedown(function(){$(this).removeClass("btnHover").addClass("btnClick");});          
	}
}
setButtons();

function applySteps(spriteUrl){
	function viewStep(e){
		var realElement = this;
		if(e.type == "focus")
			realElement = $(this).parent()[0];
		if(!$(realElement).hasClass("stepSelected")){
			var hPos = $(realElement).css("backgroundPosition");
			hPos = hPos.split(" ")[0];
			var vPos = "-83px"
			if($("div.applySteps>ol>li").index($(realElement)) == $("div.applySteps>ol>li").size()-1)
				vPos = "-80px";

			$(realElement).css({
				"backgroundPosition":hPos + " " + vPos,
				"z-index":$("div.applySteps>ol>li").size()+1
			});
			$("div.applySteps div.contentBox").html("<div id=\"step" + ($("div.applySteps>ol>li").index($(realElement))+1) + "\"></div>" + $(realElement).children("div.content").html());
			setButtons();
		}
	}
	function hideStep(e){
		var realElement = this;
		if(e.type == "blur")
			realElement = $(this).parent()[0];
		if(!$(realElement).hasClass("stepSelected")){
			var hPos = $(realElement).css("backgroundPosition");
			hPos = hPos.split(" ")[0];
			$(realElement).css({
				"backgroundPosition":hPos + " 0",
				"z-index":$("div.applySteps>ol>li").size() - $("div.applySteps>ol>li").index($(realElement))
			});
			$("div.applySteps div.contentBox").html("<div id=\"step" + ($("div.applySteps>ol>li").index($("div.applySteps>ol>li.stepSelected"))+1) + "\"></div>" + $("div.applySteps>ol>li.stepSelected").children("div.content").html());			
			setButtons();
		}
	}	
	$("div.applySteps>ol>li div.step").css({"text-indent":"-3000px"});
	$("div.applySteps>ol>li div.content").hide();
	$("div.applySteps").append("<div class=\"contentBox\"></div>");
	var olWidth = ($("div.applySteps>ol>li").size() * 104) - 15;
	var contentBoxWidth = parseInt($(".applySteps .contentBox").width()) + parseInt($(".applySteps .contentBox").css("padding-left")) + parseInt($(".applySteps .contentBox").css("padding-right"));
	var olMarginLeft = Math.round((contentBoxWidth - olWidth) / 2);
	$("div.applySteps>ol").css({
		"margin":"10px 0 0 " + olMarginLeft + "px",
		"padding":"0",
		"overflow":"hidden"
	});
	$("div.applySteps>ol>li").css({
		"background-image":"url("+spriteUrl+")",
		"position":"relative",
		"float":"left",
		"height":"83px",
		"width":"116px",
		"margin-right":"-12px"
	})
	.each(function(n){
		$(this).css({
			"backgroundPosition":"-"+116*n+"px 0",
			"z-index":$("div.applySteps>ol>li").size()-n
		})
		.children("div.step").wrap("<a href=\"#\"></a>");
	})
	.filter(":last").css({
		"width":"89px",
		"height":"80px",
		"margin-right":"0"
	}).end()
	.hover(viewStep,hideStep)
	.children("a").bind("focus",viewStep).bind("blur",hideStep).end()
	.click(function(){
		$("div.applySteps>ol>li").removeClass("stepSelected")
		.each(function(n){
			$(this).css({
				"backgroundPosition":"-"+116*n+"px 0",
				"z-index":$("div.applySteps>ol>li").size()-n
			});
		})
		var hPos = $(this).css("backgroundPosition");
		hPos = hPos.split(" ")[0];
		var vPos = "-166px"
		if($("div.applySteps>ol>li").index($(this)) == $("div.applySteps>ol>li").size()-1)
			vPos = "-160px";
		$(this).css({
			"backgroundPosition":hPos + " " + vPos,
			"z-index":$("div.applySteps>ol>li").size()+2
		})
		.addClass("stepSelected");
		$("div.applySteps div.contentBox").html("<div id=\"step" + ($("div.applySteps>ol>li").index($(this))+1) + "\"></div>" + $(this).children("div.content").html());
		setButtons();		
	})
	$("div.applySteps>ol>li:first").trigger("click");
}

function createApplySteps(){
	var applyStepsId, spriteUrl;
	applyStepsId = $("div.applySteps").attr("id");
	switch(applyStepsId){
		case "currentAccountApply":
			spriteUrl = "/_common_images/current_account_apply_sprite.gif";
			break;
		case "mortgageApply":
			spriteUrl = "/_common_images/apply_big_sprite.gif";
			break;
	}
	applySteps(spriteUrl);
}
createApplySteps()

function MortgagesConvertBulletsToRadioButtons(){
	//used for radio buttons to choose a set of FAQs / concertinas
	if($("ul#MortgagesConvertBulletsToRadioButtons").length > 0){		
		$("div.radioSlide").hide();
		$("div.radioSlide h2").remove();
		$("ul#MortgagesConvertBulletsToRadioButtons").wrap(
			$("<form>").css("margin-bottom","20px")
		)
		$("ul#MortgagesConvertBulletsToRadioButtons li a").each(function(i){
			$("<input type='radio' name='bulletRadio'>").attr({
				"id":"bulletRadio" + i,
				"value":"a" + i
			})
			.insertBefore($("ul#MortgagesConvertBulletsToRadioButtons"))
			.wrap($("<label></label>").attr("for","bulletRadio" + i).css("display","block"))
			.after($(this).text())
			.click(function(){
				if($("div.radioSlide:eq(" + i + ")").is(":visible"))return false;			
				$("input[name=bulletRadio]").removeAttr("checked");
				$(this).attr("checked","checked");
				$("div.radioSlide:visible").slideUp();
				$("div.radioSlide:eq(" + i + ")").slideDown();
			});
		});
		$("ul#MortgagesConvertBulletsToRadioButtons").remove();
	}
}
MortgagesConvertBulletsToRadioButtons();

function MortgageOverpaymentsConvertBulletsToRadioButtons(){
	var MortgageOverpaymentsMethodChecked = false;
	var MortgageOverpaymentsTypeChecked = false;
	$(".method-area").css({'float':'right','width':'50%'});
	$(".type-area").css({'float':'left','width':'50%'});
	$("h3.Overpayments-heading").css("padding-bottom","10px")
	$("div.method-area").css("padding-bottom","10px");
	$("div.type-area").css("padding-bottom","10px");
	if($("ul.MortgageOverpaymentsBuyerType").length > 0){
		$("div.Overpayments-info").hide();
		$("h2.Overpayments-results").hide(); 
		$("div.Overpayment-method").hide();
		$("div.Overpayment-type").hide();
		$("div.Overpayments-details-for-all-nw-customers").hide();
		$("ul.MortgageOverpaymentsBuyerType li a").each(function(i){
			$("<input type='radio' name='bulletRadio1'>").attr({
				"id":"bulletRadio1" + i,
				"value":"a" + i
			})
			.insertBefore($("ul.MortgageOverpaymentsBuyerType"))
			.wrap($("<label></label>").attr("for","bulletRadio1" + i).css("display","block"))
			.after($(this).text())
			.click(function(){
				if($("div.Overpayments-info:eq(" + i + ")").is(":visible")){
					return false;
				}
				$("div.Overpayments-info:visible").hide();
				$("div.Overpayments-info:eq(" + i + ")").show();
			});
		});
		$("ul.MortgageOverpaymentsBuyerType").remove();
			
		$("ul.MortgageOverpaymentsMethod li a").each(function(i){
			$("<input type='radio' name='bulletRadio2'>").attr({
				"id":"bulletRadio2" + i,
				"value":"a" + i
			})
			.insertBefore($("ul.MortgageOverpaymentsMethod"))
			.wrap($("<label></label>").attr("for","bulletRadio2" + i).css("display","block"))
			.after($(this).text())
			.click(function(){
				if($("div.Overpayment-method:eq(" + i + ")").is(":visible"))return false;
				if(MortgageOverpaymentsTypeChecked){
					if(!MortgageOverpaymentsMethodChecked){
						MortgageOverpaymentsMethodChecked = true;
						$("input[name=bulletRadio3]:checked").click();
					}
					$("div.Overpayment-method:visible").hide();
					$("tr.methodrow:visible").hide();
					$("h2.Overpayments-results").show();
					$("div.Overpayment-method:eq(" + i + ")").show();
					$("tr.methodrow:eq(" + i + ")").show();
					$("div.Overpayments-details-for-all-nw-customers").show();
				}
				MortgageOverpaymentsMethodChecked = true;
			});
		});
		$("ul.MortgageOverpaymentsMethod").remove();
				
		$("ul.MortgageOverpaymentsMortgageType li a").each(function(i){
			$("<input type='radio' name='bulletRadio3'>").attr({
				"id":"bulletRadio3" + i,
				"value":"a" + i
			})
			.insertBefore($("ul.MortgageOverpaymentsMortgageType"))
			.wrap($("<label></label>").attr("for","bulletRadio3" + i).css("display","block"))
			.after($(this).text())
			.click(function(){
				if($("div.Overpayment-type:eq(" + i + ")").is(":visible")){
					return false;
				}
				if(MortgageOverpaymentsMethodChecked){
					if(!MortgageOverpaymentsTypeChecked){
						MortgageOverpaymentsTypeChecked = true;
						$("input[name=bulletRadio2]:checked").click();
					}
					$("div.Overpayment-type:visible").hide();
					$("div.Overpayment-type:eq(" + i + ")").show();
					$("div.Overpayments-details-for-all-nw-customers").show();	
				}	
					MortgageOverpaymentsTypeChecked = true;
			});
		});
		$("ul.MortgageOverpaymentsMortgageType").remove();
	}
}
MortgageOverpaymentsConvertBulletsToRadioButtons();

function nfiredirect(){
	if($("h1#nfi-redirect").length > 0)setTimeout(function(){document.location="http://www.nationwide-intermediary.co.uk/content/calculators/aff_calc.aspx"},10000)
}
nfiredirect();

/* LV page tagging under Insurance folder only	*/
function lvPageTags(){
	if(document.location.pathname.toLowerCase().indexOf("/insurance/")){
		if(
		   document.location.pathname.toLowerCase().indexOf("/insurance/default.htm") == 0 ||
		   document.location.pathname.toLowerCase().indexOf("/insurance/car_insurance/introduction.htm") == 0 ||
		   document.location.pathname.toLowerCase().indexOf("/insurance/buytolet_business_ins/default.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/car_insurance/summary.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/car_insurance/qanda.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/car_insurance/quote.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/car_insurance/apply_when.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/car_insurance/apply_after.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/travel_insurance/apply.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/travel_insurance/apply_single_before.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/travel_insurance/apply_single_when.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/travel_insurance/apply_single_when.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/travel_insurance/apply_single_after.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/travel_insurance/apply_annual_before.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/travel_insurance/apply_annual_when.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/travel_insurance/apply_annual_after.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/buy_to_let/introduction.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/buy_to_let/summary.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/buy_to_let/qanda.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/buy_to_let/apply.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/buy_to_let/apply_when.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/buy_to_let/apply_after.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/shop_insurance/introduction.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/shop_insurance/summary.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/shop_insurance/qanda.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/shop_insurance/apply.htm") == 0 ||	 
		   document.location.pathname.toLowerCase().indexOf("/insurance/shop_insurance/apply_when.htm") == 0 ||
		   document.location.pathname.toLowerCase().indexOf("/insurance/shop_insurance/apply_after.htm") == 0 ||
		   document.location.pathname.toLowerCase().indexOf("/insurance/offices_surgeries/introduction.htm") == 0 ||
		   document.location.pathname.toLowerCase().indexOf("/insurance/offices_surgeries/summary.htm") == 0 ||
		   document.location.pathname.toLowerCase().indexOf("/insurance/offices_surgeries/qanda.htm") == 0 ||
		   document.location.pathname.toLowerCase().indexOf("/insurance/offices_surgeries/apply.htm") == 0 ||
		   document.location.pathname.toLowerCase().indexOf("/insurance/offices_surgeries/apply_when.htm") == 0 ||  
		   document.location.pathname.toLowerCase().indexOf("/insurance/offices_surgeries/apply_after.htm") == 0  
		)
		{ 
			$("a.apply,#container2 a[href^=https],a.button.info[href^=https],div.container li a[href^=https]").each(function(){
	 			SiMigrateCookie(this);
			});
		}	
	}
}
lvPageTags();

	function applyTableStyles()
	{
		var biggestHeight=0;
		var smallestHeight=1000;
		var heightDifference=0;
		$("div.simpleTable").each(function(){
			var thisRowCount = $(this).find("tr").size();
			if (thisRowCount>6) {$(this).find("tr:even").addClass("alt");}
			$(this).find("thead tr:first th")
			.css("padding","0")
			.wrapInner("<div class=\"thRightBG\"></div>");
			$(this).find("caption")
			.css("padding","0")
			.wrapInner("<div class=\"captionRightBG\"></div>");
			$(this).find("div.tableFooter")
			.css("padding","0")
			.wrapInner("<div class=\"tableFooterRightBG\"></div>");
		});
		/* start real bodge*/
		$("div.simpleTable table thead th div.thRightBG").each(function(){
			//$(this).css("padding-top",topPadding);
			if ($(this).height()>biggestHeight) {biggestHeight=$(this).height()}
			if ($(this).height()<smallestHeight) {smallestHeight=$(this).height()}
		});
		heightDifference = biggestHeight-smallestHeight;
		//var adjustedTopPadding = (heightDifference + 30) + "px";
		$("div.simpleTable table thead th div.thRightBG").each(function(){
			if ($(this).height()<biggestHeight) {
				//add in the extra padding to equalise heights
				adjustedTopPadding = (biggestHeight-$(this).height()+30)+"px";
				$(this).css("padding-top",adjustedTopPadding);
			}
		});
		/* end real bodge*/

/*		$("div.simpleTable tr").hover(function(){$(this).addClass("hovered");},function(){$(this).removeClass("hovered");}); */
	}
	applyTableStyles();

/*home ins overview button states*/

function doHomeInsButtonStates(){
	if($("#homeInsOverviewQuote").length>0){
		$("#homeInsOverviewQuote a.GetAQuote").mouseover(function(){
			$(this).css("background-position","-174px 0");  
		});	
		$("#homeInsOverviewQuote a.GetAQuote").mouseout(function(){
			$(this).css("background-position","0px 0");  
		});	
		$("#homeInsOverviewQuote a.GetAQuote").mousedown(function(){
			$(this).css("background-position","-348px 0");  
		});	
		$("#homeInsOverviewQuote a.GetAQuote").mousemove(function(){
			$(this).css("background-position","-174px 0");  
		});	
		$("#homeInsOverviewQuote a.RetrieveAQuote ").mouseover(function(){
			$(this).css("background-position","-174px -50px");  
		});
		$("#homeInsOverviewQuote a.RetrieveAQuote ").mouseout(function(){
			$(this).css("background-position","0px -50px");  
		});	
		$("#homeInsOverviewQuote a.RetrieveAQuote").mousedown(function(){
			$(this).css("background-position","-348px -50px");  
		});	
		$("#homeInsOverviewQuote a.RetrieveAQuote").mousemove(function(){
			$(this).css("background-position","-174px -50px");  
		});	
	}
}
doHomeInsButtonStates();
/*end home ins overview button states*/
/* Experimental stuff below here */
function addARIAattributes(){
	$("#globallinks, #productnav, #breadcrumb, #leftnav, #footer, #hp-latest-news").attr("role","navigation");
	$("#search").attr("role","search");
	$("div.moreinfo").attr("role","contentinfo");
	$("#headerleft").attr("role","banner");
}
addARIAattributes();
		
$("#err404trySearch").click(function(){
	$("#p_search_text").css("background","#fae7cb").css("border","1px solid #ff9900");
	$("#p_search_text").focus();
	$("#p_search_text").keypress(function(){
		$(this).css("background","#fff").css("border","1px solid #000");
	});
	return false;
});

function multiAdSwitcher(){
	$("div.multiAdSwitcher")
	.wrap("<div class=\"multiAdSwitcherWrapper\">")
	.after("<div id='cnav'>")
	.cycle({
		fx:'fade',
		speed:300,
		timeout:8000,
		pager:'#cnav',
		pause:1
		});
		var pauseText = "Pause advert playback";
		var playText = "Advert playback is currently paused. Click to resume adverts";
		$("#cnav").append("<span id=\"pauseControl\" title=\"" + pauseText +"\"><a href=\"#\"><img src=\"/_common_images/pause.gif\" alt=\"" + pauseText +"\"></a></span>")
		$("#pauseControl a").toggle(function(){
				//pause adverts
				$("div.multiAdSwitcher").cycle('pause');
				$(this).css("background","url(/_common_images/sprites/multi-ad-controls.gif) -69px -34px");
				$("#pauseControl a")
					.attr("title",playText);
			},function(){
				//play adverts
				$("div.multiAdSwitcher").cycle('resume');
				$(this).css("background","url(/_common_images/sprites/multi-ad-controls.gif) -69px 0");
				$("#pauseControl a")
					.attr("title",pauseText);
		});
		var cnavid=1;
		$("#cnav>a").each(function(){
			$(this).attr("id","cnav" + cnavid);
			cnavid++;
		});
}
multiAdSwitcher();
	
function mortgateSwitcherAdbodge()
{
	var thisId = 0;
	$("#flexAdSwitcherLinks li").each(function(){
		$(this).wrapInner("<a href=\"#\" rel=\"" + thisId + "\"></a>");
		thisId++;
	})
	$("#flexAdSwitcherLinks li a").each(function(){
		$(this).click(function(){
			var thisLink=$(this).attr("rel");
			$("#cnav a:eq(" + thisLink + ")").click();
			return false;
		});
	})
	$("div.flExBens").each(function(){
		if($(this).height()<130) {$(this).height(140)}
	});
}
mortgateSwitcherAdbodge();
	

/* mortgage questionnaire launcher */
function qLaunch(path, popUpLocation){
	if(document.location.pathname.indexOf(path) == 0){
		var nextLocation = "";
		var launched = false;
		var splitCookie = document.cookie.split(";");
		var valPos, qVal
		for(var x=0; x < splitCookie.length; x++){
			valPos = splitCookie[x].indexOf("=");
			if(splitCookie[x].indexOf("questionnaire") == 0){
				if(valPos > -1){
					qVal = splitCookie[x].substring(valPos+1);
					if(qVal = "true")launched = true;
				}
			}
		}
		$('a').click(function(){
			nextLocation = this.pathname;
			if(nextLocation.charAt(0) != "/"){
				nextLocation = "/" + nextLocation;
			}
		});
		window.onbeforeunload = function(){
			if(!launched){
				if(nextLocation.indexOf(path) != 0){
					window.open(popUpLocation, "myWin");
					document.cookie = "questionnaire=true;path=" + path + ";max-age=604800;";
				}
			}
		};
	}
}

//Support Page function

$("#ccsearch").submit(function(){
	var term = $("#ccsearchtxt").val();
	var searchurl = "http://www.nationwide.co.uk/search/Search.aspx?word=" + term + "&type=nlq&category=1445";
	location.href=searchurl;
	return false;
})
$("#mortgagesearch").submit(function(){
	var term = $("#mortgagesearchtxt").val();
	var searchurl = "http://www.nationwide.co.uk/search/Search.aspx?word=" + term + "&type=nlq&category=1449";
	location.href=searchurl;
	return false;
})

function PEBapplySelector(){
	if($("ol#pebApplySteps").size() > 0){
		$("ul#pebApplyOptions li a").each(function(i){
			text = $(this).text();
			$("<label for=\"planType"+i+"\"><input type=\"radio\" id=\"planType"+i+"\" name=\"planType\" />"+text+"</label>").appendTo("ol#pebApplySteps .appStep4");
		});
		$("ul#pebApplyOptions").remove();
		$(".actionBar:first").clone().insertBefore(".actionBar:first");
		$(".actionBar:gt(0)").hide();
		$(".actionBar:first p").text("Please select Deposit Plan or ISA Plan.");
		$(".actionBar:first span").text("It’s quick and easy to apply online");
		$(".actionBar:first .applyNow a").click(function(){
			alert("Please select Deposit Plan or ISA Plan from stage 4 of the online application process.");
			$("#planType0").focus();
			return false;
		});
		$("ol#pebApplySteps .appStep4 input:radio").click(function(){
			if($(".actionBar").size() > 2)$(".actionBar:first").remove();
			$(".actionBar").hide();
			barPos = $("ol#pebApplySteps .appStep4 input:radio").index($(this));
			$(".actionBar:eq("+barPos+")").show();
		})
	}
}
PEBapplySelector();
}

function PageTaggingInternalAdvertImpressions(){
	var intcmpID = "";
	s.products = "";
	$('a[href*=intcmp]').each(function(){			
		intcmpID=$(this).attr('href');
		intcmpID=intcmpID.split('intcmp=')[1];
		if(intcmpID.indexOf('&')!=-1){intcmpID=intcmpID.split('&')[0];}
		if(intcmpID.indexOf('#')!=-1){intcmpID=intcmpID.split('#')[0];}
		if(s.products.indexOf(intcmpID) == -1){				
			if(s.products){
				s.products+=',Internal ads;' + intcmpID + ';;;event26=1;evar47=+1';
				s.events='event26';
			}
			else{
				s.products='Internal ads;' + intcmpID + ';;;event26=1;evar47=+1';
				s.events='event26';
			}
		}
	});
	if(s.products.indexOf("Internal ads") != - 1){
		s.eVar2="";
		s.linkTrackVars="products,events,eVar2";
		s.linkTrackEvents="event26";
		s.tl(true,"o","Internal ad impression");
		s.linkTrackEvents="None";s.linkTrackVars="None";s.products="";s.events="";
	}
}
PageTaggingInternalAdvertImpressions();
}

/*  END jQuery functions*/ 
/* All addEvent function calls below here please :-) */
addEvent(window, 'load', initConcertina, false);
addEvent(window, 'load', doJQueryFunctions, false);