function generateSIFR(id, txt, w, h, swf, link, offsetTop, textColour, textAlign, popwinWidth, popwinHeight) {
	if(/Firefox\/2/.test(navigator.userAgent)) {swf = swf + "?" + id;}
	if (textAlign == null) textAlign = "left";
	var so = new SWFObject(swf, id, w, h, "6", "transparent");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addVariable("txt", escape(txt.replace("&amp;", "&")));
	so.addVariable("textalign", "left");
	so.addVariable("offsetTop", offsetTop);
	so.addVariable("textcolor", textColour);
	if(link != "") so.addVariable("link", link);
	so.addVariable("w", w);
	so.addVariable("h", h);
	if(popwinWidth != null && popwinHeight != null) {
		so.addVariable("popwin", true);
		so.addVariable("popwin_width", popwinWidth);
		so.addVariable("popwin_height", popwinHeight);
	}
	so.write("flashcontent_" + id);
}

function pendAndRetrieve(product, target) {
	if(product.indexOf('PER-CA') == 0 ) {
		if(!(product.indexOf('PER-CA-ADAPT') == 0)){
		target.location = '/personal/current-accounts/open-account-branch.ashx';
		}
	}
	else if(product.indexOf('PER-LO') == 0 ) {
		if((product.indexOf('PER-LO-LOAN') == 0)){
		target.location = '/personal/loans/loan-application-info.ashx';
		}
	}
}

window.tracking = {
	trackEvent : function(data) {
		_hbPageView(data.pageName, hbx.mlc);
	}
}			

window.tabControl = {

	hideAll : function() {
		var aElem = document.getElementById("infopods");
		var aDivs = aElem.getElementsByTagName("div");
		var bmk = stateManager.getCurrentBookmark();
		var s = (/^tabs=section[0-9]$/.test(bmk)) ? 0 : 1;
		for (i = s; i < aDivs.length; i++){
			if ((s == 1 || (s == 0 && ("tabs=" + aDivs[i].id) != bmk)) && (aDivs[i].className == "infopod" || aDivs[i].className == "infopod jsshow")){	
				aDivs[i].className = "infopod jshide";
			}
		}
		
		if(s == 0){
			var tab;
			var tabId = bmk.substring(5) + "link";
			tab = document.getElementById("section1link");
			tab.className = "off";
			tab = document.getElementById(tabId); 
			tab.className = "on";
			//this.trackEvent(bmk);	
		}
	},
	
	show : function(sId) {
		var aElem = document.getElementById("infopods");
		var aDivs = aElem.getElementsByTagName("div");
		for (i=0; i<aDivs.length; i++){
			if (aDivs[i].className == "infopod" || aDivs[i].className == "infopod jsshow"){
				aDivs[i].className = "infopod jshide";
			}
			if (aDivs[i].id == sId){
				aDivs[i].className = "infopod jsshow";
			}
		}
		var aElem = document.getElementById("infopods_nav");
		var tabs = aElem.getElementsByTagName("a");
		for (i=0; i < tabs.length; i++){
			var sLink = tabs[i].id;
			if(sLink == sId + "link"){
				tabs[i].className = "on";
			}
			else {
				tabs[i].className = "off";
			}
		}
		window.scroll(0, 0); //back to top
		this.trackEvent(sId);
	},
	
	trackEvent : function(id) {
		try {
			var pn = (productType != "") ? id + "/" + productType : id;
			_hbPageView(pn, hbx.mlc);
			if(typeof(scSetUpPageVars) == "function") {
				scSetUpPageVars("","",id);
			   }
		}
		catch(e){}
	},
	
	currentTab : "section1"
}

function showInfopod(id) {YAHOO.util.History.navigate("tabs", id);}

function showTab() {
	var id = YAHOO.util.History.getCurrentState("tabs");
	tabControl.show(id);
}

var currentUser = new UserProfile();

function createAjaxOverride() {
	document.write("<label style=\"position:absolute;left:-999px;top:0;\">Disable dynamic updates to the page:<input type=\"checkbox\" onclick=\"ajaxOverride(this)\"/></label>");
};

function ajaxOverride(chk) {
	if(chk.checked) {currentUser.disableAjax();}
	else {currentUser.enableAjax();}
}

function initialise() {
	DOMHelper.findBookmarks(document.body, attachBookmarkEvent);
}

var foundBmk = true;

function attachBookmarkEvent(anc) {
	if(anc.onclick == null) {
		anc.onclick = function (e) {
			if (window.event) e = window.event;  
			var src = e.srcElement? e.srcElement : e.target;
			dynamicUI.activateBookmark(src);
			return false;
		}
	}
}

window.onload = initialise;
