
//**********************************
// Onload - Unobtrusives
//**********************************

// Onload unobtrusive handler
// Dean Edwards/Matthias Miller/John Resig

/* for Mozilla/Opera9 */
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
	document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
	var script = document.getElementById("__ie_onload");
	script.onreadystatechange = function() {
		if (this.readyState == "complete") {
			init(); // call the onload handler
		}
	};
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
	var _timer = setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
			init(); // call the onload handler
		}
	}, 10); 
}

/* for other browsers */
window.onload = init;



//**********************************
// Unobtrusive functions
//**********************************
function init() {
	if (arguments.callee.done) return;
	arguments.callee.done = true;
	if (_timer) clearInterval(_timer);
	
	// OnLoad stuff
	if (window.attachEvent && $('rollovermenu')) { sfHover(); } 
	if ($('brand_tabs')) { itabs(); }
	if ($('font_change')) { fontChanger(); }
	
	
}


//**********************************
// IE6 Menu hover events
//**********************************
sfHover = function() {
	var sfEls = document.getElementById("rollovermenu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

//**********************************
// Font Change
//**********************************




function fontChanger() {
	fonts = { 	
		parent : $('copy'), 
		 //top level obj, all fonts inside will change
		defaultSize : 12,
		maxi : 12,
		mini : 12 
	}
	$('font_change').onmousedown = font;
}


// actions
function font(e){
	var t = getTarget(e); 
	fonts.control = t.id;
	fontRecursive(fonts.parent);
}

 //recursive font sizer
function fontRecursive(pDiv) { 
	var obj = pDiv.childNodes; 
	
	for (var i=0; i < obj.length; i++) { 
		if (obj[i].nodeType == 1) {
			
			var element = obj[i].style;
			if (element.fontSize == "") element.fontSize = fonts.defaultSize+"px";
			currentSize = parseInt(element.fontSize);

			if (fonts.control=="up"){ 
					if (currentSize <= fonts.maxi)
					element.fontSize = (currentSize+1)+"px";
			} else { 
					if (currentSize > fonts.mini)
					element.fontSize = (currentSize-1)+"px";
			}

			if(obj[i].childNodes.length > 0){
       			fontRecursive(obj[i]);
         	}
		}
	}
}

//**********************************
// Tabbing 
//**********************************

function itabs(){
	tab = { 	// New tabs
		timeDelay : 250, 			// 1000 = 1 second
		tabCookie : "cookieTab",  	// cookie name
		timeToKeep : 31449600000 	// one week
	}
	// Tabs Events
	$('brand_tabs').onmouseover = tabbing;
	// Tabs Accessibility
	accessible(document, "brand_content");
	// Tabs Initiate, includes cookie lookup 
	tabInit();
}

// Initiate a tab, if no cookie, open tab1
function tabInit(){
	var tmp = get_cookie(tab.tabCookie);
	if (tmp) { 	// if cookie
		swapTab($(tmp));	
	} else { 	
		swapTab($('tab1'));	
	}
}

// actions
function tabbing(e){
	var t = getTarget(e); 
	if (t.className=="brand_tab") {
		t.onmouseout = clearTime;
		t.onmousedown = downTab;
		tab.time = setTimeout(function () { swapTab(t); }, tab.timeDelay);
	}
}

// On a mouse down
function downTab(e){
	clearTime();
	var t = getTarget(e);
	swapTab(t);
}

// If user has moused over for time period
function swapTab(obj) {
	objCon = $(obj.id + "_con");
	obj.className = "brand_tab_on";
	dsp(objCon,'block'); 	
	if (tab.prev) {
		tab.prev.className = "brand_tab";
		dsp(tab.conPrev,'none'); 
	}
	var expires = new Date();
	expires.setTime(expires.getTime() + tab.timeToKeep);
	set_cookie(tab.tabCookie, obj.id, expires);
	tab.prev=obj;
	tab.conPrev=objCon;
	obj.onmousedown = null;
}

function clearTime(){
	clearTimeout(tab.time);
}

// end tabs

if(window.attachEvent)
    window.attachEvent("onload",setListeners);

  function setListeners(){
    inputList = document.getElementsByTagName("INPUT");
    for(i=0;i<inputList.length;i++){
      inputList[i].attachEvent("onpropertychange",restoreStyles);
      inputList[i].style.backgroundColor = "";
    }
    selectList = document.getElementsByTagName("SELECT");
    for(i=0;i<selectList.length;i++){
      selectList[i].attachEvent("onpropertychange",restoreStyles);
      selectList[i].style.backgroundColor = "";
    }
  }

  function restoreStyles(){
    if(event.srcElement.style.backgroundColor != "")
      event.srcElement.style.backgroundColor = "";
  }


// IE 6 + Firefox compliant

function parentControl(symbol) {
  if (window.opener && !window.opener.closed) {
    window.opener.document.location.href = symbol;
	window.opener.focus();
    }
    else if (!window.opener || window.opener.closed) {
    	document.getElementById('mainContent').style.display = "none";
    	document.getElementById('closeIt').style.display = "block";
    	countClose();
    }
}


function parentControlWithClose(symbol) {
  if (window.opener && !window.opener.closed) {
    window.opener.document.location.href = symbol;
	window.close();
    }
    else if (!window.opener || window.opener.closed) {
    	document.getElementById('mainContent').style.display = "none";
    	document.getElementById('closeIt').style.display = "block";
    	countClose();
    }
}

function countClose() {
	timerCount = timerCount-1;
	if (timerCount==-1) {
  	nowClose();
  } else {
  	window.setTimeout('pause()',1000);
  }
}

function pause() {
	document.getElementById('timerDown').innerHTML=timerCount + " seconds.";
  	countClose();
}

function nowClose() {
  	window.close();
}

//-->

function NewWindowPositioned(url)
{
	NewWin = window.open(url,'Bpay','height=450,width=570,toolbar=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no');
	NewWin.moveTo(10,10); 
}
//Open new window width size and other options passed.
function openWin(url, inW, inH, inS){
	if(inW == "") inW = 600; //default width of the window
	if(inH == "") inH = 400; //default height of the window
	if(inS == "") inS = 0; //default scrollbars 0 = no scrollbar; 1 = yes
	
	geneva = window.open(url,"poppup","menubar=no,resizable=yes,Width=" + inW + ",Height=" + inH + ",titlebar=no,alwaysRaised=yes,status=yes,resizable=no,scrollbars=" + inS + "");
}

function goPage()
{
  pageNo = document.pager.goWhere.selectedIndex
  if (pageNo == 0 || pageNo == 5 || pageNo == 6) {
    top.location.href = document.pager.goWhere.options[pageNo].value } else {
    parent.location.href = document.pager.goWhere.options[pageNo].value
  }
}

function IBWindow(filename)
{
  window.open(filename,'IBank','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=800,height=600');
}

function selectorWindow(filename)
{
window.open(filename,'selector','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=790,height=610');
}
function Window987(filename)
{
  window.open(filename,'987','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=987,height=720');
}
function Window1000(filename)
{
  window.open(filename,'1000','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=1000,height=720');
}
function Window950(filename)
{
  window.open(filename,'950','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=950,height=720');
}
function Window900(filename)
{
  window.open(filename,'900','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=900,height=720');
}
function Window850(filename)
{
  window.open(filename,'850','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=850,height=550');
}
function Window800(filename)
{
  window.open(filename,'800','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=800,height=550');
}
function Window750(filename)
{
  window.open(filename,'750','menubar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=740,height=640');
}
function Window700(filename)
{
  window.open(filename,'700','menubar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=700,height=540');
}
function Window640(filename)
{
window.open(filename,'640','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=640,height=560');
}
function Window500(filename)
{
  window.open(filename,'sec','menubar=no,location=no,menus=no,scrollbars=yes,resizable=1,status=yes,top=5,width=500,height=450');
}
function Widow450(filename)
{
  window.open(filename,'450','menubar=no,location=no,menus=no,scrollbars=yes,resizable=1,status=yes,top=5,width=450,height=400');
}

function fsra(filename)
{
  window.open(filename,'fsra','menubar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=500,height=450');
}

 
function BBOWindow(filename) {
 
// defaults
winWidth = 800; 
winheight = 600;
 
// some old browsers don't support screen
if (screen){ 
   winWidth = screen.width;    // maximise width
   winHeight = screen.height; // maximise height
   winWidth=winWidth-10;
   winHeight=winHeight-50;
}
 
 window.open(filename,'bbonline', 'menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,width='+winWidth+',height='+winHeight+',status=yes,top=0,left=0');
}
 
function controlWindow(filename, swidth, sheight) {
 
// defaults
winWidth = swidth; 
winHeight = sheight;
 
 window.open(filename,'window', 'menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,width='+winWidth+',height='+winHeight+',status=yes,top=0,left=0');
}

function NewWindow(filename)
{
  window.open(filename,'800','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=800,height=690');
}
function DemoWindow(filename)
{
  window.open(filename,'demo','menubar=no,toolbar=no,location=no,menus=no,scrollbars=no,resizable=no,status=yes,top=5,width=790,height=500');
}

function AGMWindow(filename)
{
  window.open(filename,'Plain','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=0,status=yes,top=5,width=773,height=449');
}
function acrhiveWebcastWindow(filename)
{
  window.open(filename,'Plain','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=0,status=yes,top=5,width=773,height=449');
}

function closeMe()
{
	window.close();
}

function Login(s) {
	for (var i = 0; i < document.login_form.selectlog.length; i++) {
		if (document.login_form.selectlog[i].checked) {
			var str = document.login_form.selectlog[i].value;
			break;
		}
	}
	var arrayOfURL = str.split(",");
	var URL1 = arrayOfURL[0];
	var URL2 = arrayOfURL[1];
	if (s == 1)
	{
		if (URL1 != "") window.location.href = URL1;
	}
  else
	{
		if (URL2 != "") window.location.href = URL2;
	}
}

//This script will fix the print screen problem on IE 4

var da = (document.all) ? 1 : 0;
var pr = (window.print) ? 1 : 0;
var mac = (navigator.userAgent.indexOf("Mac") != -1);

function printPage() {
  if (pr) // NS4, IE5
    window.print()
  else if (da && !mac) // IE4 (Windows)
    vbPrintPage()
  else // other browsers
    alert("Sorry, your browser doesn't support this feature.");
  return false;
}

if (da && !pr && !mac) with (document) {
  writeln('<OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>');
  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');
  writeln('Sub window_onunload');
  writeln('  On Error Resume Next');
  writeln('  Set WB = nothing');
  writeln('End Sub');
  writeln('Sub vbPrintPage');
  writeln('  OLECMDID_PRINT = 6');
  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');
  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');
  writeln('  On Error Resume Next');
  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');
  writeln('End Sub');
  writeln('<' + '/SCRIPT>');
}

//pops up the pdf for economic commentary etc.
function formHandler(form)
{
  var URL = document.form.site.options[document.form.site.selectedIndex].value;
  window.open(URL);
}


//Popup function for the onload browser detection script
function popup(Site)
{
window.open(Site,'PopupName','toolbar=no,statusbar=no,location=no,scrollbars=yes,resizable=yes,width=435,height=450')
}

// end -->
/* 
** This function updates the parent window, and closes the child
** window.
*/
function updateParentWindow(aLoc) {
  top.opener.parent.document.location.href = aLoc;
  window.close();
}




function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}
  

// Div controls


function show_it(active){
	document.getElementById(active).style.display = "block";
}

function hide_it(active){
  	document.getElementById(active).style.display = "none";
}

var llun = null;


// This function will open a div and close all other open divs

function divCall(activeDiv) {
	var docLoc = document.getElementById(activeDiv);

	if (docLoc) {
		if ((docLoc.style.display == "none" || docLoc.style.display == "")) {
			docLoc.style.display = "block";
		} else {
			if (docLoc.style.display = "block") { docLoc.style.display = "none"; }
		}
		if (llun && docLoc != llun) { llun.style.display = "none"; }
		llun = docLoc;
	} else { llun = null; }
}


// This function will leave open the current div if clicked again

function divCall2(activeDiv) {
	var docLoc = document.getElementById(activeDiv);

	if (docLoc) {
		if ((docLoc.style.display == "none" || docLoc.style.display == "")) {
			docLoc.style.display = "block";
		} else {
			if (docLoc.style.display = "block") { docLoc.style.display = "block"; }
		}
		if (llun && docLoc != llun) { llun.style.display = "none"; }
		llun = docLoc;
	} else { llun = null; }
}

function divCalltwo(id) {
	var docLoc2 = document.getElementById(id);

	if (docLoc2) {
		if ((docLoc2.style.display == "none" || docLoc2.style.display == "")) {
			docLoc2.style.display = "block";
		} else {
			if (docLoc2.style.display = "block") { docLoc2.style.display = "none"; }
		}
		if (llun2 && docLoc2 != llun2) { llun2.style.display = "none"; }
		llun2 = docLoc2;
	} else { llun2 = null; }
}


// New and improved: Will open/close divs, but you need to specify behaviour of the same div clicked twice ie.. close="none" or open="block"

var divObj = new Object();
divObj.prev = null;

function divCall3(activeDiv, action) {
	var docLoc = document.getElementById(activeDiv);
	var divAction="none";
	if (action=="open") {divAction="block"}
	
	if (docLoc) {
		if ((docLoc.style.display == "none" || docLoc.style.display == "")) {
			docLoc.style.display = "block";
		} else {
			if (docLoc.style.display = "block") { docLoc.style.display = divAction; }
		}
		if (divObj.prev && docLoc != divObj.prev) { divObj.prev.style.display = "none"; }
		divObj.prev = docLoc;
	} else { divObj.prev = null; }
}


//**********************************
// Generic Framework || Unless you really know what your doing I'd say leave these as they are
//**********************************


// Object Accessibility || parent Object, objects to hide
function accessible(pObj, tObj){
	var tmp = getElementsByClassName(pObj, "*", tObj); 
	for(var i=0;i<tmp.length;i++){
		dsp(tmp[i],'none');
	}
}

// Event Delegations
function getTarget(x){ 
	x = x || window.event;
	return x.target || x.srcElement;
}
// Prototype Method to get the element based on ID
function $(d){
	return document.getElementById(d);
}

// set or get the current display style of the div
function dsp(d,v){
	if(v==undefined){
		return d.style.display;
	}else{
		d.style.display=v;
	}
}

// set or get the height of a div.
function sh(d,v){
	// if you are getting the height then display must be block to return the absolute height
	if(v==undefined){
		//if style = block
		if(dsp(d)!='none'&& dsp(d)!=''){
			return d.offsetHeight;
		}
		// else
		viz = d.style.visibility;
		d.style.visibility = 'hidden';
		o = dsp(d);
		dsp(d,'block');
		r = parseInt(d.offsetHeight);
		dsp(d,o);
		d.style.visibility = viz;
		return r;
	}else{
		d.style.height=v;
	}
}

// get elements by class name
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}




// Cookie Toolbox Javascript
// copyright 4th September 2002, by Stephen Chapman, Felgall Pty Ltd

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.
// For instructions on how to use these functions see "A Cookie Toolbox"
// in the Javascript section of our site at http://www.felgall.com/

var dbug = 0; function d_a(ary) {var beg = next_entry(ary) - 1; for (var i = beg ; i > -1; i--) {ary[i] = null;}} function init_array() {if (dbug) alert('init_cookie');  var ary = new Array(null); return ary;} function set_cookie(name,value,expires) {if (dbug) alert('set_cookie'); if (!expires) expires = new Date();
document.cookie = name + '=' + escape(value) + '; expires=' + expires.toGMTString() + '; path=/';} function get_cookie(name) {if (dbug) alert('get_cookie'); var dcookie = document.cookie; var cname = name + "="; var clen = dcookie.length; var cbegin = 0; while (cbegin < clen) {var vbegin = cbegin + cname.length;
if (dcookie.substring(cbegin, vbegin) == cname) {var vend = dcookie.indexOf (";", vbegin); if (vend == -1) vend = clen; return unescape(dcookie.substring(vbegin, vend));} cbegin = dcookie.indexOf(" ", cbegin) + 1; if (cbegin == 0) break;} return null;} function del_cookie(name) {if (dbug) alert('del_cookie');
document.cookie = name + '=' + '; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/';} function get_array(name, ary) {if (dbug) alert('get_array'); d_a(ary); var ent = get_cookie(name); if (ent) {i = 1; while (ent.indexOf('^') != '-1') {ary[i] = ent.substring(0,ent.indexOf('^')); i++;
ent = ent.substring(ent.indexOf('^')+1, ent.length);}}} function set_array(name, ary, expires) {if (dbug) alert('set_array'); var value = ''; for (var i = 1; ary[i]; i++) {value += ary[i] + '^';} set_cookie(name, value, expires);} function del_entry(name, ary, pos, expires) {if (dbug) alert('del_entry');
var value = ''; get_array(name, ary); for (var i = 1; i < pos; i++) {value += ary[i] + '^';} for (var j = pos + 1; ary[j]; j++) {value += ary[j] + '^';} set_cookie(name, value, expires);} function next_entry(ary) {if (dbug) alert('next_entry'); var j = 0; for (var i = 1; ary[i]; i++) {j = i} return j + 1;}
function debug_on() {dbug = 1;} function debug_off() {dbug = 0;} function dump_cookies() {if (document.cookie == '') document.write('No Cookies Found'); else {thisCookie = document.cookie.split('; '); for (i=0; i<thisCookie.length; i++) {document.write(thisCookie[i] + '<br \/>');}}}

// End Copyright




/* Do Not put function below this */
-->