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="",newWindow=null,jQueryUsed=false,jQueryPluginUsed=false,hpInteractive=false,hpContext="";
var nua = navigator.userAgent;
var unsupported_safari=(((nua.indexOf("Version/3")!=-1)||(nua.indexOf("Version/4")!=-1)||(nua.indexOf("Version/5")!=-1))&&(nua.indexOf("Safari")!=-1));
var unsupported_ff4Mac=((nua.indexOf("Firefox/4")!=-1)&&(nua.indexOf("Mac OS")!=-1))?true:false;
var homePageClickableLink=false,flashCapable;
var isIE=(navigator.appVersion.indexOf("MSIE")!=-1)?true:false;
var isWin=(navigator.appVersion.toLowerCase().indexOf("win")!=-1)?true:false;
var isOpera=(nua.indexOf("Opera")!=-1)?true:false;
function ControlVersion(){var version;var axo;try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");version=axo.GetVariable("$version");}catch(e1){}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version="WIN 6,0,21,0";axo.AllowScriptAccess="always";version=axo.GetVariable("$version");}catch(e2){}}if(!version){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");version=axo.GetVariable("$version");}catch(e3){}}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(e4){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"));}}flashVer=versionMajor+"."+versionMinor+"."+versionRevision;}}else if(nua.toLowerCase().indexOf("webtv/2.6")!=-1){flashVer=4;}else if(nua.toLowerCase().indexOf("webtv/2.5")!=-1){flashVer=3;}else if(nua.toLowerCase().indexOf("webtv")!=-1){flashVer=2;}else if(isIE&&isWin&&!isOpera){flashVer=ControlVersion();}return flashVer;}
function DetectFlashVer(reqMajorVer,reqMinorVer,reqRevision){var versionStr=GetSwfVer();if(versionStr==-1){return false;}else if(versionStr!=0){if(isIE&&isWin&&!isOpera){var 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;}}
if(!unsupported_safari&&!unsupported_ff4Mac){
	var flashReplaceLink=document.createElement('LINK');
	flashReplaceLink.setAttribute("rel","stylesheet");
	flashReplaceLink.setAttribute("id","flashReplaceStylesheet");
	flashReplaceLink.setAttribute("href","/_stylesheets/flashReplace.css");
	var docHead=document.getElementsByTagName("HEAD")[0];
	docHead.appendChild(flashReplaceLink);
}
function closeWin(){
	if(newWindow!=null){if(!newWindow.closed){newWindow.close();}}
}
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 doAtlas(str_click,str_url){
	var click_img=new Image();
	if(str_click!=''&&str_url!=''){
		click_img.src="http://switch.atdmt.com/action/"+str_click;
		window.location.href=str_url;
	}
}
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;}
}
function doClickTags(str_atlas,str_click,str_url,new_win){
	var click_img=new Image();
	if(str_atlas!=''&&str_url!=''){
		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;
	}
	if(new_win!=null){window.open(str_url);}
	else{window.location.href=str_url;}
}
function clickTag(str_click,str_url,new_win){
	if(str_click!=''){
		var imgSpotlight=new Image();
		imgSpotlight.src=str_click;
		if(str_url!='' && str_url!=null){
			if(new_win!=null){window.open(str_url); return false;}
			else{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();
	}
}
function centerWindowX(screenWidth,windowWidth){
	return(screenWidth-windowWidth)/2;
}
function centerWindowY(screenHeight,windowHeight){
	return(screenHeight-windowHeight)/2;
}
function launchNavigator(userType){
	var url='/product_finder/Main.html?userType='+userType;
	var name='main';
	var windowWidth=948;
	var windowHeight=690;
	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 fs_filter(){
	for(var x=0,fl=document.frmnom_form.elements.length;x<fl;x++){
		if(document.frmnom_form.elements[x].value){
			document.frmnom_form.elements[x].value=document.frmnom_form.elements[x].value.replace(/[<>"'%;\(\)&\+]/g, "");
		}
	}
}
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");
}
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}/;
	if(srchStr.search(re5digit)==-1){
		return true;
	}
	else{
		document.location="http://www.nationwide.co.uk/search/start.aspx?article=1451";
		return false;
	}
}
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;
}
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");
		var viewportwidth;
		for(var i=0,al=sk_a.length;i<al;i++){
			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;}
			if(sk_a[i].className=="skip-link"){
				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(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;
				}
				sk_a[i].onfocus=function(){
					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(){
					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;
				};
			}
		}
		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(){
				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;
				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(){
				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(event){
		if(enableAccessibilityHotKey){
			var code;
			if(!event){event=window.event;}
			if(event.keyCode){code=event.keyCode;}
			else if(event.which){code=event.which;}
			var character=String.fromCharCode(code);
			if(character==","){
				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;
	}
	var ul,ul_divs;
	if(source.tagName!=null){
		//only handling this individual concerina, not all of them
		ul=source.parentNode;
	}
	else{
		ul=document.getElementsByTagName("ul");
	}
	if(ul.length>0){
		for(i=0;i<ul.length;i++){
			if(ul[i].className=="concertina"){
				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){
			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(){
					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(){
							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));
		}
	}
})();
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 ...*/
/* NON self-invoking jQuery functions / or public functions*/
function applyTableStyles(){
	if($("div.simpleTable").length>0){
		$("div.simpleTable:not(.simpleTableDone)").each(function(){
			var $st = $(this);
			var biggestHeight=0;
			var smallestHeight=1000;
			var thisRowCount=$st.find("tr").size();
			if(thisRowCount>6 && $st.is(":not(.noalt)")){$st.find("tr:even").addClass("alt");}
			$st.find("thead tr:has('th'):first th:not(.blank)",this)//needed a bodge for added intro row and for blank cells
			.css("padding","0")
			.wrapInner("<div class=\"thRightBG\"></div>");
			
			$st.find("thead tr th.blank",this).css({
				"background":"transparent"
			});
			
			$("caption",this)
			.css("padding","0")
			.wrapInner("<div class=\"captionRightBG\"></div>");
			
			$("div.tableFooter",this)
			.css("padding","0")
			.wrapInner("<div class=\"tableFooterRightBG\"></div>");
			
			// moved this in here so each table gets its own adjustment
			/* start real bodge*/
			$("div.thRightBG",this).each(function(){
				var $th = $(this);
				if($th.height()>biggestHeight){biggestHeight=$th.height();}
				if($th.height()<smallestHeight){smallestHeight=$th.height();}
			});
			$("div.thRightBG",this).each(function(){
				var $th = $(this);
				if($th.height()<biggestHeight){
					//add in the extra padding to equalise heights
					adjustedTopPadding=(biggestHeight-$th.height()+5)+"px";
					$th.css("padding-top",adjustedTopPadding);
				}
			});
			if($(this).hasClass("altBG")){
				$(this).find("div,th,td").each(function(){
					var altBG = $(this).css("background-image").replace("simpleTable","simpleTableAlt");
					$(this).css("background-image",altBG);
				})
				.end().css("background-image",$(this).css("background-image").replace("simpleTable","simpleTableAlt"))
				;
			}
			/* end real bodge*/
		}).addClass("simpleTableDone");
		$("div.simpleTable ~ div.simpleTable").css("margin-top","10px");
	}
}
function setcontainerheight(value){
	$("#isalimittext").height(value);
	$(".objectWrapper,object,embed").height(value);
}
/* 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;";
				}
			}
		};
	}
}
/* START self invoking or autorun jQuery functions*/
function doJQueryFunctions(){
if(jQueryUsed==true){
 $("#mainContent p a.CTA").css({border:"none",backgroundPosition:"0 -249px",paddingLeft:"20px"}).wrapInner("<span class=\"innerBorderForInlineLinks\"></span>");

//$(document).ready(function(){

$("#page #footer-final-links ul li:first").css({border:"none",marginLeft:"-9px"});

var is_chrome=/chrome/.test(nua.toLowerCase());
	var is_ie,is_ie_6,is_ie_7,is_ie_8,is_not_ie=(!is_ie),is_safari,is_mozilla,is_opera,browserVersion;
	browserVersion=parseInt($.browser.version,10);
	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_chrome);
	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").find("a").append("<div class=\"added\">");
		$("a.active").parent().next().addClass("activeTabRight").find("a").append("<div class=\"added\">");
	})();
	function repExamples(){
	    $("div.representativeExample p").css("left","0").css("top","16px").css("z-index","1000").hide();
	    var savedAlt="";	
	    if ($("#hero div.representativeExample").size()>0) {
    		$("body.ie #hero img").attr("alt","");
    	}
    	$("div.representativeExample>a.title")
	    .hover(function(){$(this).siblings("p").fadeIn(300); $(this).addClass("hover");},function(){$(this).siblings("p").fadeOut(); $(this).removeClass("hover");})
	    .focus(function(){$(this).siblings("p").fadeIn(300); $(this).addClass("hover");})
	    .blur(function(){$(this).siblings("p").fadeOut(); $(this).removeClass("hover");})
	    .click(function(){return false;});
	    $("div.representativeExample>a.title").blur();
	}
	repExamples();


function curvyCornersForIEactionBars() {
   	var $abh = 0;
	var $odd = true;
	$("body.ie6 .actionBar, body.ie7 .actionBar, body.ie8 .actionBar").each(function(){
		$(this).prepend("<b class=\"ab_r\"></b><b class=\"ab_b\"></b><b class=\"ab_tl\"></b><b class=\"ab_tr\"></b><b class=\"ab_bl\"></b><b class=\"ab_br\"></b>");
		$(this).addClass("actionBarImageBased");
	/* If existing action bars do not have secondary text inside the span element, they will break in IE as they have no elements to attach the background images to. So, need to inject some back in ... */
		if ($(this).find("span").size()==0) {
			$(this).addClass("actionBarSimple").append("<span></span>");
		}
		$abh = $(this).height();
		$odd = ($abh % 2);
		if ($odd) {
			$(this).addClass("ieOddPixelHeight");
		}
		//$(this).append("<b style='position:absolute;top:0;left:0;z-index:20000'>" + $abh + " " + $odd + "</b>");
	});
	$(".ab_r,.ab_b,.ab_tl,.ab_tr,.ab_bl,.ab_br").css({
	position:"absolute",
	width:"10px",
	height:"10px",
	zIndex:"1000"
	})
	$(".ab_r").css({
	height:"100%",
	zIndex:"50",
	background:"url(/_/images/actionBarCornersForIE.png) right -20px"
	})
	$(".ab_r").css({
	top:"0",
	right:"0"
	})
	$(".actionBarSimple .ab_b").css({
	bottom:"0",
	left:"0",
	width:"100%",
	zIndex:"50",
	background:"url(/_/images/actionBarCornersForIE_simple.png) center bottom"
	})
	$(".ab_tl").css({
	top:"0",
	left:"0"
	})
	$(".ab_tr").css({
	top:"0",
	right:"0"
	})
	$(".ab_bl").css({
	bottom:"0",
	left:"0"
	})
	$(".ab_br").css({
	bottom:"0",
	right:"0"
	})
	$("body.ie6 .ieOddPixelHeight .ab_bl, body.ie6 .ieOddPixelHeight .ab_br").css({
	bottom:"-1px"
	})
	$("body.ie6 #page #mainContent div.actionBarImageBased").css("width","100%");
	$("body.ie6 .ab_r").css({
	height:"80px"
	})
	}
curvyCornersForIEactionBars();

//on page:/publicaffairs/diary.htm
	(function rotateImage_PublicAffairsAndPolicy(){
		//only bother if the id exists on the page
		if($("#publicaffairs-img-rotate").length>0){
			var NUMBER_OF_IMAGES=20;
			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/NationwideVolunteers1.JPG";img_alt="Justin Tomlinson MP, Rob Buckland MP and CEO Graham Beale launching Nationwide Volunteers ";img_anchor="/publicaffairs/sized/NationwideVolunteers1.JPG";break;
				case 17:img_src="/publicaffairs/210/NationwideVolunteers2.JPG";img_alt="Rob Buckland MP and Justin Tomlinson MP launching Nationwide Volunteers ";img_anchor="/publicaffairs/sized/NationwideVolunteers2.JPG";break;
				case 18:img_src="/publicaffairs/210/NationwideVolunteers3.JPG";img_alt="Justin Tomlinson MP and Swindon employees at Nationwide Volunteers roundtable";img_anchor="/publicaffairs/sized/NationwideVolunteers3.JPG";break;
				case 19:img_src="/publicaffairs/210/NationwideVolunteers4.JPG";img_alt="Conor Burns MP launching Nationwide Volunteers with Louise Barton";img_anchor="/publicaffairs/sized/NationwideVolunteers4.JPG";break;
				case 20:img_src="/publicaffairs/210/NationwideVolunteers5.JPG";img_alt="Conor Burns MP and Bournemouth employees at Nationwide Volunteers roundtable";img_anchor="/publicaffairs/sized/NationwideVolunteers5.JPG";break;
				default:break;
			}
			if(img_src!=""&&img_alt!=""&&img_anchor!=""){
				$("#publicaffairs-img-rotate")
				.show()
				.attr("src",img_src)
				.attr("alt",img_alt)
				.wrap("<a href=\""+img_anchor+"\" target=\"_blank\"></a>");
			}
		}
	})();
	(function applyProductNavHoverWithTab(){
		/* Top level tabs - apply hover behaviour for tabbing/keyboard users */
		$("#productnav>ul>li>a:not(a.active)")
			.focus(function(){$(this).addClass("productNavhover");})
			.blur(function(){$(this).removeClass("productNavhover");});
	})();
	(function applyProductSubNavHoverWithTab(){
		/* tab subnavigation - apply hover behaviour for tabbing/keyboard users */
		$("#headernav-subnav ul li a")
			.focus(function(){$(this).addClass("productSubNavhover");})
			.blur(function(){$(this).removeClass("productSubNavhover");});
	})();
	(function applyLeftNavHoverWithTab(){
		/* left nav - apply hover behaviour for tabbing/keyboard users */
		$("#leftnav li a")
			.focus(function(){$(this).addClass("leftNavHover");})
			.blur(function(){$(this).removeClass("leftNavHover");});
	})();
	(function applyLeftNavHoverWithTab_mtg(){
		/* left nav - apply hover behaviour for tabbing/keyboard users */
		$("#mtge-links a")
			.focus(function(){$(this).addClass("mtgeHover");})
			.blur(function(){$(this).removeClass("mtgeHover");});
	})();
	(function breadcrumbtext(){
		$(".breadcrumbtext").click(function(){
			$("#cc-tabs-wrapper").slideToggle("medium");
		});
	})();
	/* footer show/hide stuff */
	(function applyButtonStyles(){
		//start button behaviour
		if($(".button,.apply,.info").length>0){
			$(".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(){
				var $b = $(this);
				var btLength=($b.html())?$b.html().length:$b.attr("value").length+3;
				if(btLength<5){$b.addClass("smallbutton");}
				if((btLength>10)&&(btLength<21)){$b.addClass("bigbutton");}
				if((btLength>20)&&(btLength<24)){$b.addClass("hugebutton");}
				if(btLength>=24){$b.addClass("megabutton");}
			});
			$("a.button:not(\"#exitAnd404PagewrapperInner #primaryCampaign a\"),input.button").each(function(){
				var buttonType="";
				var $b = $(this);
				if($b.hasClass("apply")){buttonType="Apply";}
				if($b.hasClass("info")){buttonType="Info";}
				var clickStyle=["button",buttonType,"Click"].join('');
				var hoverStyle=["button",buttonType,"Hover"].join('');
				$b
					.mousedown(function(){
						$(this).removeClass(clickStyle).addClass(clickStyle);
					})
					.mouseup(function(){
						$(this).removeClass(clickStyle);
					})
					.mouseover(function(){
						$("a.apply,input.apply").removeClass(clickStyle);
						$(this).addClass(hoverStyle);
					})
					.mouseout(function(){
						$(this).removeClass(hoverStyle);
					})
					.focus(function(){
						$(this).addClass(hoverStyle);
					})
					.blur(function(){
						$(this).removeClass(hoverStyle);
					});
			});
			//end button behaviour
		}
	})();
	var thisActBarBgPos;
	var thisActBarPosX;
	var thisActBarPosY;
	(function actionBarButtonBehaviour(){
		//for mousers
		if($("div.actionBar").length>0){
			$("div.actionBar div b")
				.hover(function(){
					var $t = $(this);
					thisActBarBgPos=$t.css("background-position");
					if(thisActBarBgPos=='undefined'||thisActBarBgPos==null){
						thisActBarBgPos=$t.css('background-position-x')+" "+$t.css('background-position-y');
					}
					thisActBarBgPos=thisActBarBgPos.replace(/px/g,"").split(" ");
					thisActBarPosX=thisActBarBgPos[0];
					thisActBarPosY=thisActBarBgPos[1];
					$t.css("background-position","-130px "+thisActBarPosY+"px");
					},function(){
						$(this).css("background-position","-5px "+thisActBarPosY+"px");
				})
				.mousedown(function(){
					var $t = $(this);
					thisActBarBgPos=$t.css("background-position");
					if(thisActBarBgPos=='undefined'||thisActBarBgPos==null){
						thisActBarBgPos=$t.css('background-position-x')+" "+$t.css('background-position-y');
					}
					thisActBarBgPos=thisActBarBgPos.replace(/px/g,"").split(" ");
					thisActBarPosX=thisActBarBgPos[0];
					thisActBarPosY=thisActBarBgPos[1];
					$t.css("background-position","-255px "+thisActBarPosY+"px");
				})
				.mouseup(function(){
					var $t = $(this);
					thisActBarBgPos=$t.css("background-position");
					if(thisActBarBgPos=='undefined'||thisActBarBgPos==null){
						thisActBarBgPos=$t.css('background-position-x')+" "+$t.css('background-position-y');
					}
					thisActBarBgPos=thisActBarBgPos.replace(/px/g,"").split(" ");
					thisActBarPosX=thisActBarBgPos[0];
					thisActBarPosY=thisActBarBgPos[1];
					$t.css("background-position","-130px "+thisActBarPosY+"px");
				});
			//for kbd peeps
			$("div.actionBar div a").focus(function(){
				var $t = $(this);
				thisActBarBgPos=$t.next().css("background-position");
				if(thisActBarBgPos=='undefined'||thisActBarBgPos==null){
					thisActBarBgPos=$t.next().css('background-position-x')+" "+$t.next().css('background-position-y');
				}
				thisActBarBgPos=thisActBarBgPos.replace(/px/g,"").split(" ");
				thisActBarPosX=thisActBarBgPos[0];
				thisActBarPosY=thisActBarBgPos[1];
				$t.next().css("background-position",(thisActBarPosX-125)+"px "+thisActBarPosY+"px");
				}).blur(function(){
					$(this).next().css("background-position",thisActBarPosX+"px "+thisActBarPosY+"px");
				});
		}
	})();
	(function tidyUpHeaderSublinks(){
		//remove the right-most 'pipe' on the links in blue header section
		$("#headernav-subnav li:last a").addClass("headernavLastLink");
	})();
	function doFlashReplace(){
		if($(".doFlashReplace").length>0){
			var requiredFlashMajorVersion=8;
			var requiredFlashMinorVersion=0;
			var requiredFlashRevision=0;
			flashCapable=DetectFlashVer(requiredFlashMajorVersion,requiredFlashMinorVersion,requiredFlashRevision);
			if(flashCapable){
				$(".doFlashReplace").each(function(){
					var $doFlashReplace = $(this);
					//build up embed code
					var flashObjectEmbedCode;
					//find attributes for flash movie
					var $thisImage=$doFlashReplace.find("img:not(.clickInd)");
					//get the URL from the href and pass it on to the Flash movie
					var flashButtonLink;
					if($("a.hpMoreLink",this).length > 0){
						flashButtonLink=$doFlashReplace.find("a.hpMoreLink").attr("href");
						//convert the qrystring format to the format that Flash understands
						//change & to %26
						if(flashButtonLink != null)flashButtonLink=flashButtonLink.replace(/\&/g,"%26");
					}
					var flashButtonLink2;
					if($("a.hpMoreLink2",this).length > 0){
						flashButtonLink2=$doFlashReplace.find("a.hpMoreLink2").attr("href");
						//convert the qrystring format to the format that Flash understands
						//change & to %26
						if(flashButtonLink2 != null)flashButtonLink2=flashButtonLink2.replace(/\&/g,"%26");
					}
					var swfSrc=$thisImage.attr("src").replace(".gif","").replace(".jpg","").replace(".png","") + ".swf";
					var swfFlashVars=$thisImage.attr("flashvars")||"";
					var swfWidth=$thisImage.attr("flashwidth")||$thisImage.width();
					var swfHeight=$thisImage.attr("flashheight")||$thisImage.height();
					$thisImage.width(swfWidth);
					$thisImage.height(swfHeight);
					//check for overridden flash attributes
					if(typeof($thisImage.attr("flashsrc"))!="undefined"){
						if($thisImage.attr("flashsrc").length>0){
							swfSrc=$thisImage.attr("flashsrc");
						}
					}
					if(flashButtonLink != null){
						swfSrc = swfSrc + "?flashButtonLink="+flashButtonLink;
					}
					if(flashButtonLink2 != null){
						swfSrc = swfSrc +"&flashButtonLink2="+flashButtonLink2;
					}
					$("a[name*=bugfixLeaveMeHere]").remove();
					flashObjectEmbedCode=["<div class=\"objectWrapper\" style=\"background:white;\">",
					"\n<object",
					" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"",
					" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\"",
					" width=\"",swfWidth,"\"",
					" height=\"",swfHeight,"\"",
					">",
					"\n<param name=\"wmode\" value=\"transparent\" \/>",
					"\n<param name=\"movie\" value=\"",swfSrc,"\" \/>",
					"\n<param name=\"width\" value=\"",swfWidth,"\" \/>",
					"\n<param name=\"height\" value=\"",swfHeight,"\" \/>",
					"\n<param name=\"FlashVars\" value=\"",swfFlashVars,"\" \/>",
					"\n<param name=\"AllowScriptAccess\" value=\"always\" \/>",
					"\n<param name=\"quality\" value=\"high\">",
					"\n<embed",
					"\n src=\"",
					swfSrc,
					"\"",
					"\n width=\"",swfWidth,"\"",
					"\n height=\"",swfHeight,"\"",
					"\n FlashVars=\"",swfFlashVars,"\"",
					"\n AllowScriptAccess=\"always\"",
					"\n quality=\"high\"",
					"\n wmode=\"transparent\"",
					"\n type=\"application/x-shockwave-flash\"",
					"\n pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\"",
					">",
					"\n<\/embed>",
					"\n<\/object>",
					"\n<\/div>"].join('');
					if(isOpera){
						flashObjectEmbedCode = flashObjectEmbedCode.replace(/wmode/gi,"nowmode");
					}
					//embed flash movie, position using abs pos over existing html version
					$doFlashReplace.append(flashObjectEmbedCode).css("background","none").addClass("hasFlash");
					$doFlashReplace.height(parseInt(swfHeight));
					//make sure survey can fit over top if launched
					$("#notifications").css("z-index","3000");
					// hide the images
					$("img",this).height(1).width(1);
					// remove the tagging from links that we don't want page tagged
					// ifFlashRemoveTagging
					$("a.ifFlashRemoveTagging",this).each(function(){
						var existingLink = this.href;
						var newLink;
						if(existingLink.indexOf("?intcmp") != -1){
							newLink = existingLink.split("?intcmp")[0];
						}
						if(newLink != null){
							this.href = newLink;
						}
					});
				});
			}
			$(".doFlashReplace a,.doFlashReplace img").css("visibility","visible");
		}
	}
	if(!unsupported_safari&&!unsupported_ff4Mac){
		doFlashReplace();
	}
	function screenReaderFriendlyMoreInfoLinks(){
		$("a[title]").not("a[title]>a[title]").each(function(){
			var $t = $(this);
			$t
			.addClass("srhelpAdded")
			.append(["<span class=\"srhelp\">. ",$t.attr("title"),"</span>"].join(''));
		});
	}
	if(!is_safari){screenReaderFriendlyMoreInfoLinks();}
	$("span.srhelp").css({display:"block",position:"absolute",textIndent:"-30000px",overflow:"hidden",height:"0px",width:"0px"});

	(function clickableParents_generic(){
		if($(".clickableParent").length>0){
    		 $(".clickableParent:not(div.hasFlash)").each(function(){
				var $t = $(this);
				var $thisLink=$t.find("a:first,a.buttonPuretext");
				var $thisLinkHref=$thisLink.attr("href");
				var $thisLinkTarget=$thisLink.attr("target");
				var $thisLinkTitle=$thisLink.attr("title")||$thisLink.text();
				var $thisLinkClick=($thisLink.hasClass("flashTakeoverLink"))?" onclick=\"doSmartAd();return false;\"":"";
				if(typeof($thisLinkTarget)!="undefined")$thisLinkTarget=($thisLinkTarget.length>0)?" target=\""+$thisLinkTarget+"\"":$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
				//auto does not work for home page scenario. Need 1%.
				var nastyIEHack=(homePageClickableLink)?" style=\"height:1%;display:block;\"":" style=\"height:auto;display:block;\"";
				if ($(this).find(".representativeExample").size()>0) {$thisLinkTitle="";} //switch off help tip as it obscures the text in the rep example hover
				var wrapInnerText=["<a",nastyIEHack," href=\"",$thisLinkHref,"\"",$thisLinkTarget," class=\"addedLink noreposition\" tabindex=\"-1\" title=\"",$thisLinkTitle,"\"",$thisLinkClick,"></a>"];
				$t.wrapInner(wrapInnerText.join(''));
			});
		}
	})();
	(function setUpSearchBoxes(){
		defSrchTxt="Enter search keyword/phrase";
		$("#p_search_text")
			.val(function(index,value){
				return (this.value=="")?defSrchTxt:value
			})
			.click(function(){
				$(this).val(function(index,value){
					return (this.value==defSrchTxt)?"":value
				});
			})
			.focus(function(){
				$(this).select();
			});
	})();
	(function setUpAskBox(){
		defAskTxt="Ask a question";
		$("#txtAsk")
			.val(defAskTxt)
			.click(function(){
				$(this).val(function(index,value){
					return (this.value==defAskTxt)?"":value;
				});
			})
			.focus(function(){
				$(this).select();
			});
		$("#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;
		});
	})();
	(function leftNavHasSubSection(){
		$("li.currentSection:has(ul)").each(function(){
			if($(this).find("li.currentPage").length>0){
				$(this).addClass("hasSubSection");
			}
		});
		$("li.currentPage:has('ul')").addClass("hasSubSubSection");
	})();
	// can't locate following pages
	(function exclusiveOffersTermsLinks(){
		$("p.exclusiveOffersTerms a,a.exclusiveOffers").each(function(){
			$(this)
				.attr("title","Open terms and conditions in a new window")
				.click(function(){
					popUpWin(this.href,"standard","800","550");
					return false;
				});
		});
	})();
	(function homeExitPageEffects_Rebrand(){
		if($("#hpNov09").length>0){
			/* add red pipes to popular searches */
			$("#popular ul b").remove();
			$("#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.href,'console',790,700);
				return false;
			});
		}
		if(($("#hpNov09").length>0)||($("#exitAnd404Pagewrapper").length>0)){
			/* View rates on home/exit page */
			viewRates=function(){
				$("#frmHomeExitPageViewRates").submit(function(){
					var ratePage=$("#ddlHomeExitPageViewRates").val();
					if(ratePage!="Please select"){location.href=ratePage;}
					return false;
				});
			}();
			//home/exit page click state effect
			$("#ibSignOnLink a,#signon-link a").mouseover(function(){
				$(this).addClass("hovered");
			}).mousedown(function(){
				$(this).removeClass("hovered").addClass("clicked");
			}).mouseup(function(){
				$(this).removeClass("clicked");
			}).mouseout(function(){
				$(this).removeClass("clicked hovered");
			});
			/* Exit page colour shift on quick links top menu*/
			$("#quickLinksList li:first").css("border-top","1px solid #e8e9ea");
			//setInterval(doNewsTicker,6000);
			//go button hover effect
			$("input#btnHomeExitPageViewRatesGo").mouseover(function(){
				$(this).addClass("hovered");
			}).mouseout(function(){
				$(this).removeClass("hovered clicked");
			}).mousedown(function(){
				$(this).removeClass("hovered").addClass("clicked");
			});
		}
	})();
	(function stopIeFlicker(){
		//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");});
	})();
	/*
	END panelLinks layout 
	*/
	//on page:/mortgages/default.htm
	(function mortgageRatesButton(){
		$("#btnMortgageRates,div.mortOffersForm input[name=btnMortgageRates]").click(function(){
			var $form = $(this).closest("form");
			var buyertype=$("select[name=selectRates]",$form).val();
			var propertyvalue=$("input[name=txtValueOfProperty]",$form).val();
			var mortgagerequired=$("input[name=txtMortgageRequired]",$form).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.join('');
			return false;
		});
	})();
	(function btnGoHover(){
		if($(".btnGo").length>0){
			$(".btnGo")
			.hover(function(){this.src="/_common_images/buttons/btn_go_hover.gif";},function(){this.src="/_common_images/buttons/btn_go_normal.gif";})
			.mousedown(function(){this.src="/_common_images/buttons/btn_go_click.gif";$(this).data("isDown","true");})
			.mouseup(function(){this.src="/_common_images/buttons/btn_go_normal.gif";$(this).data("isDown","false");});
			/*imgs only*/
			$("img.btnGo").mousemove(function(){if($(this).data("isDown")=="true"){this.src="/_common_images/buttons/btn_go_hover.gif";$(this).data("isDown","false");}});
		}
	})();
	(function btnCompareHover(){
		$(".btnCompare")
		.mouseover(function(){$(this).removeClass("btnCompare").addClass("btnCompareHover");})
		.mouseout(function(){$(this).removeClass("btnCompareHover btnCompareClick").addClass("btnCompare");})
		.mousedown(function(){$(this).removeClass("btnCompareHover").addClass("btnCompareClick");});
	})();
	(function mortgageQuoteApplyButton(){
		$(".btnQuoteApply")
		.mouseover(function(){$(this).addClass("btnQuoteApplyHover");})
		.mouseout(function(){$(this).removeClass("btnQuoteApplyHover btnQuoteApplyClick").addClass("btnQuoteApply");})
		.mousedown(function(){$(this).removeClass("btnQuoteApplyHover").addClass("btnQuoteApplyClick");});
	})();
	function setButtons(){
		$(".btn")
		.mouseover(function(){$(this).addClass("btnHover");})
		.mouseout(function(){$(this).removeClass("btnHover btnClick").addClass("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(),10)+parseInt($(".applySteps .contentBox").css("padding-left"),10)+parseInt($(".applySteps .contentBox").css("padding-right"),10);
		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 $t = $(this);
			var hPos=$(this).css("backgroundPosition");
			hPos=hPos.split(" ")[0];
			var vPos="-166px";
			if($("div.applySteps>ol>li").index($t)==$("div.applySteps>ol>li").size()-1){
				vPos="-160px";
			}
			$t.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($t)+1)+"\"></div>"+$t.children("div.content").html());
			setButtons();
		});
		$("div.applySteps>ol>li:first").trigger("click");
	}
	(function createApplySteps(){
		if($("div.applySteps").length>0){
			var spriteUrl={
				"currentAccountApply":"/_common_images/current_account_apply_sprite.gif",
				"mySaveApply":"/_common_images/savings_apply_sprite.gif",
				"mortgageApply":"/_common_images/apply_big_sprite.gif",
				"isaTransferSteps":"/_common_images/isa_transfer_sprite.gif"
			};
			spriteUrl=spriteUrl[$("div.applySteps").attr("id")];
			applySteps(spriteUrl);
		}
	})();
	(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,h2.Overpayments-results,div.Overpayment-method,div.Overpayment-type,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();
		}
	})();
	/* 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");
	})();
	//can't find
	(function mortgateSwitcherAdbodge(){
		var thisId=0;
		//did you know you can use "i" in an each function....?
		$("#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(){
			var $t = $(this);
			if($t.height()<130){$t.height(140);}
		});
	})();
	(function mortgagesearchsubmit(){
		$("#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;
		});
	})();
	// applyTableStyles defined nearer top. Needed to be public.
	applyTableStyles();
	//on: http://www.nationwide.co.uk/creditcard/goldcard/managing-your-card/managing.htm
	(function expandPanelsRespLending(){
		$(".expandoPanelInner").hide();
		$(".expandoHeader a").each(function(){
			$(this).toggle(function(){
				$(this).parent().next().slideDown('fast');
			},function(){
				$(this).parent().next().slideUp('fast');
			});
		});
	})();
	//home / exit
	(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="";
		}
	})();
	//on page:/contact_us/default.htm
	(function replaceContactUsLinks(){
		if($("#contact-points").size()>0){
			var defaultText
			$("#contact-points [type=text]").click(function(){
				defaultText = $(this).val();
				$(this).val("");
			})
			.blur(function(){
				if($(this).val() == ""){
					$(this).val(defaultText);
				}
			});
			$(".contact-point").each(function(){
				if($("[type=submit]",this).size()>0){
					var text = $("[type=submit]",this).val();
					$("[type=submit]",this).replaceWith("<a href=\"\">"+text+"</a>");
					$("a", this).click(function(){
						$(this).parents("form").submit();
						return false;
					});
				}
			});
			$("#contact-branch a").unbind().click(function(){
				var values = $(this).parents("form").serialize();
				var action = $(this).parents("form").attr("action");
				popUpWin(action+"?"+values,'console',600,500);
				return false;
			});
		}
	})();
	// On page: mortgage apply page
	(function convertMortgageApplyPage(){
		var $l = $("#applySelect");
		if($l.length > 0){
			$l.hide();
			$("#apply1,#apply2,#apply3,#apply4,#apply5,#apply6" ).hide();
			var $ddl = $("<select/>");
			$("<option/>")
				.attr("value","0")
				.text("Please select")
				.appendTo($ddl);
			$("li",$l).each(function(i){
				$v = $("a", this).attr("href");
				$v = $v.slice($v.search(/\d/));
				$("<option/>")
				.attr("value",$v)
				.text($(this).text())
				.appendTo($ddl);
			});
			$ddl
				.attr("id","applySelectddl")
				.change(function(){
					$("#apply1,#apply2,#apply3,#apply4,#apply5,#apply6").hide();
					$("#apply" + $(this).val()).show();
					$("#apply1 h2:first").text($("option[selected]",this).text());
					if(typeof lpSendData == typeof Function){
						lpSendData('page','ApplicationType',$("option[selected]",this).text());
					}
				})
				.insertAfter($l);
			$("<label/>")
				.attr("for","applySelectddl")
				.text("I am:")
				.css({
					"margin-right" : "20px",
					"font-weight" : "bold"
				})
				.insertBefore($ddl);
			$("a[name*=option]").each(function(i){
				$(this).focus(function(){
					$("#apply1,#apply2,#apply3,#apply4,#apply5").hide();
					$("#apply" + (i+1)).show();
					$ddl.val(i+1);
				});
			});
		}
	})();
}
//});//end ready()
}//end fn();

function doJQueryPluginFunctions(){
	if(jQueryPluginUsed==true){
		//relies on plugin
		(function newsline_cycler(){
			if($("#newsline_cycler").length>0){
				$("#newsline_cycler").cycle({
					fx:'scrollLeft',
					speed:800,
					timeout:5000,
					pause:1
				});
			}
		})();
		//on page:/investments/financial_planning/people.htm
		//relies on plugin
		(function invPplLikeMeFader(){
			if($("#invPplLikeMeFader").length>0){
				$("#invPplLikeMeFader").cycle("fade");
			}
		})();
	}
	
}

/* END jQuery functions*/
/* All addEvent function calls below here please :-) */
addEvent(window,'load',initConcertina,false);
addEvent(window,'load',doJQueryFunctions,false);
addEvent(window,'load',doJQueryPluginFunctions,false);

