
//**********************************
// 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 */




//**********************************
// 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(); }
	
	
	
}


//**********************************
// 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"), "");
		}
	}
}


//**********************************
// 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 thisDate() {
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write( day + "/" + month + "/" +year)	 
 }
//-->

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 launch(filename)
{
  window.open(filename,'1024','location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=1024,height=768');
}


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=yes,toolbar=yes,location=yes,menus=yes,scrollbars,resizable=1,status=yes,top=5,width=1000,height=720');
}
function Window1050(filename)
{ 
  window.open(filename,'1050','menubar=yes,toolbar=yes,location=yes,menus=yes,scrollbars,resizable=1,status=yes,top=5,width=1050,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 Window450(filename)
{
  window.open(filename,'450','menubar=no,location=no,menus=no,scrollbars=yes,resizable=1,status=yes,top=5,width=450,height=400');
}
function WindowDirectShares(filename)
{
  window.open(filename,'DirectShares','menubar=no,toolbar=no,location=no,menus=no,scrollbars,resizable=1,status=yes,top=5,width=800,height=550');
}

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 SameWindow(filename)
{
  window.location.href= filename;
}

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();
}


//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();
}


// 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)
}


//Logon scripts

function loginRegister() {
	var newvalue = document.IntBankLogin.LoginTo.value;
		
	if (newvalue == 'Internet Banking') {
		location = "/accounts/ways-you-can-bank/internet-banking/get-started";	
	} else if (newvalue == 'Business Banking Online') {
		location = "/corporate-business/transaction-banking-solutions/electronic-solutions/business-banking-online/apply-for-bbo";
	} else if (newvalue == 'Margin Lending') {
		location = "/wealth-creation/margin-lending/forms";
	} else if (newvalue == 'Directshares') {
		location = "/wealth-creation/directshares-online-broking/";
	} else if (newvalue == 'connections online') {
		location = "/corporate-business/transaction-banking-solutions/electronic-solutions/corporate-mastercard/";
	} else if (newvalue == 'Global Dealer') {
		Window700('https://www.globaldealer.com.au/');
	}
}

function loginLearnMore() {
	var newvalue = document.IntBankLogin.LoginTo.value;
	if (newvalue == 'Internet Banking') {
		location = "/accounts/ways-you-can-bank/internet-banking/";
	} else if (newvalue == 'Business Banking Online') {
		location = "/corporate-business/transaction-banking-solutions/electronic-solutions/business-banking-online/";
	} else if (newvalue == 'Margin Lending') {
		location = "/loans/margin-lending/learning-centre/";
	} else if (newvalue == 'Directshares') {
		location = "/wealth-creation/directshares-online-broking/";
	} else if (newvalue == 'connections online') {
		location = "/corporate-business/transaction-banking-solutions/electronic-solutions/corporate-mastercard/";
	} else if (newvalue == 'Global Dealer') {
		Window700('https://www.globaldealer.com.au/');	
	}
}

function loginMain() {
	var newvalue = document.IntBankLogin.LoginTo.value;
	if (newvalue == 'Internet Banking') {
		IBWindow('/IbankRedirect');
	} else if (newvalue == 'Business Banking Online') {
		BBOWindow('https://bbonline.stgeorge.com.au/html/cbank.asp');
	} else if (newvalue == 'Margin Lending') {
		Window800('https://marginlending.stgeorge.com.au/');
	} else if (newvalue == 'Directshares') {
		WindowDirectShares('https://www.directshares.com.au');
	} else if (newvalue == 'connections online') {
		Window700('http://www.connectionsstgeorge.com.au/');
	} else if (newvalue == 'Global Dealer') {
		Window700('https://www.globaldealer.com.au/web/userfrmset.html');
	}
}


function MainApplyNow() {
	var newvalue = document.ApplyNow.Product.value;
	if (newvalue == 'Personal Accounts') {
		location = "/accounts/making-the-most/apply-for-account";
	} else if (newvalue == 'Business Accounts') {
		location = "/small-business/everyday-business-banking/transaction-accounts/how-to-apply";
	} else if (newvalue == 'Personal Loans') {
		Window700('http://webapps.stgeorge.com.au/apply-now/?apptype=PLA&origin=SIC&Source=STG');
	} else if (newvalue == 'Car Finance') {
		location = "/corporate-business/business-finance-solutions/automotive-finance";
	} else if (newvalue == 'Credit Cards') {
		Window700('http://webapps.stgeorge.com.au/apply-now/?apptype=CCA&origin=SIC&Source=STG');
	} else if (newvalue == 'Home Loans') {
		location = "/loans/home-loans/how-to-apply/";
	} else if (newvalue == 'Get Set Loan') {
		Window700('http://webapps.stgeorge.com.au/apply-now/?apptype=GSL&origin=SIC&Source=STG');
	} else if (newvalue == 'Personal Overdraft') {
		Window700('http://webapps.stgeorge.com.au/apply-now/?apptype=OVD&origin=SIC&Source=STG');
	} else if (newvalue == 'Online Broking') {
		Window800('https://www.directshares.com.au?WT.ac=firstpage_sharetrading');
	} else if (newvalue == 'Insurance') {
		location = "/wealth-creation/insurance/";
	} else if (newvalue == 'Investor Online') {
		Window700('https://olaex.stgeorge.com.au/MLWebstart.asp?origin=SIC');
	} else if (newvalue == 'Business Loan') {
		Window700('https://olaex.stgeorge.com.au/bcwebstart.asp?origin=STG');
	} else if (newvalue == 'Margin Lending') {
		Window700('https://olaex.stgeorge.com.au/MLWebstart.asp?origin=SIC');	
	}
}
		
function MainProductSelector() {
	var newvalue = document.ProductSelector.Product.value;
	if (newvalue == 'Home loans') {
		Window700('http://webapps.stgeorge.com.au/selectors/home_loans/');
	} else if (newvalue == 'Business accounts') {
		Window700('http://webapps.stgeorge.com.au/selectors/enterprise/');
	} else if (newvalue == 'Personal accounts') {
		Window700('http://webapps.stgeorge.com.au/selectors/retail/');
	} else if (newvalue == 'Payment solutions') {
		Window700('http://webapps.stgeorge.com.au/selectors/payment/');
	} else if (newvalue == 'Credit cards') {
		Window700('http://webapps.stgeorge.com.au/selectors/credit-card/');
	}
	
}

			
function MainCalculators() {
	var newvalue = document.Calculators.Product.value;
	if (newvalue == 'Maximizing your Portfolio') {
		Window700('http://www1.infochoice.com.au/modules/kiosk/58/portfolio.asp');
	} else if (newvalue == 'Savings Simulator') {
		Window700('/calculators/savings_simulator.asp');
	} else if (newvalue == 'Home Loan Repayments') {
		Window700('/calculators/homeloan/loanrepayjava.asp');
	} else if (newvalue == 'How much I can borrow') {
		Window700('https://homeloan.stgeorge.com.au/bpc_appdtls.asp');
	} else if (newvalue == 'Loan Comparison Calculator') {
		Window700('/calculators/homeloan/loancomparison.asp');
	} else if (newvalue == 'Stamp Duty') {
		Window700('/calculators/stamp_duty.asp');
	} else if (newvalue == 'Extra Payments') {
		Window700('/calculators/homeloan/extrarepayjava.asp');
	} else if (newvalue == 'Foreign Currency Converter') {
		Window700('http://webapps.stgeorge.com.au/foreign-exchange-converter/');
	} else if (newvalue == 'Regular Savings') {
		Window700('http://webapps.stgeorge.com.au/calculators-net/regular-savings.aspx');
	} else if (newvalue == 'Budget Planner') {
		Window700('/calculators/budget_planner.asp');
	} else if (newvalue == 'Balance Transfer') {
		Window700('http://webapps.stgeorge.com.au/calculators/balance-transfer.asp');
	} else if (newvalue == 'Personal loan Repayment') {
		Window900('https://olaex.stgeorge.com.au/PLA/ACECreateApp.asp?AppType=PLA&Subtype=PCC&Secured=NO&origin=SIC&Source=STG');
	} else if (newvalue == 'Car Loan Calculator') {
		Window700('http://webapps.stgeorge.com.au/calculators/auto-loan.asp');
	} else if (newvalue == 'More calculators') {
		location = "/calculators/";
	}
}



//End logon scripts



// 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

window.onload = init;


//**********************************
// Scripts added by TCS-Vignette Migration Team to support DSM rendered HTML
//**********************************


//Home-Page Main Banner and Slogan image rotation.

function getRandomImage()
{
	var imageCount = document.getElementById("imagecount");
	var totalImages = imageCount.value;	
	var imgsrc = new Array();
	var slimgsrc = new Array();
	var slimgurl = new Array();
	var slimgalt = new Array();	
	var slgnimgclass = new Array();
	
				
	for(var i=0; i<totalImages; i++)
	{
		imgsrc[i] = document.getElementById("mainimage"+i).value;
		slimgsrc[i] = document.getElementById("sloganimage"+i).value;
		slimgurl[i] = document.getElementById("sloganimageurl"+i).value;
		slimgalt[i] = document.getElementById("sloganimagealt"+i).value;		
		var newImg = new Image();		
		newImg.src = slimgsrc[i];		
		var height = newImg.height;
		if(height < 56){
		slgnimgclass[i]="brand_head_text_single_line";		
		}else{
		slgnimgclass[i]="brand_head_text_double_line";

		}		
	}

	var ranNum= Math.floor(Math.random()* totalImages);
		
	var div1 = document.getElementById("randomimage");
	var div2 = document.getElementById("randomsloganimage");
	var slgndivvar = document.getElementById("slgndiv");
	var sloganimg = div2.firstChild;
		
	if(img == null)
	{
	 img = imgsrc[ranNum];
	 var imgsrctemp = slimgsrc[ranNum];	
	 div1.src = imgsrc[ranNum];
	
	 if(imgsrctemp == "")
	{
		imgsrctemp = "/resources/sgb/images/1x1.gif";
	} 
	
	 
	sloganimg.src = imgsrctemp;
	sloganimg.alt = slimgalt[ranNum];
	div2.href= slimgurl[ranNum];	 
	slgndivvar.className = slgnimgclass[ranNum];
	}
		
}

// Sets target URL for Help Me Panel links.

function helpmelogin(str)
{
	
	var dropdown = document.getElementById("select"+str);
	var url = dropdown.value;
	var atag = document.getElementById("a"+str);
	atag.href=url;	
}


// Sets target URL for Online Services Panel links.

function onlineservicelogin()
{
	var url = document.IntBankLogin.LoginTo.value;
	var atag = document.getElementById("onlineservicelink");
	atag.href=url;	
}


// Sets target URL for Register link.

function registerlogin()
{
	
	var dropdown = document.IntBankLogin.LoginTo.selectedIndex;
	var selected_text = document.IntBankLogin.LoginTo.options[dropdown].text;
	var registerurl = document.getElementById(selected_text+"register").value;
	var registerlink = document.getElementById("registerlink");
	registerlink.href = registerurl;
}


// Sets target URL for LearnMore link.

function learnmorelogin()
{
	
	var dropdown = document.IntBankLogin.LoginTo.selectedIndex;
	var selected_text = document.IntBankLogin.LoginTo.options[dropdown].text;
	var registerurl = document.getElementById(selected_text+"learnmore").value;
	var registerlink = document.getElementById("learnmorelink");
	registerlink.href = registerurl;
}


//Promotion text rotation for Home Page

function getRandomPromotion()
{
	
	var promocount = document.getElementById("promocount").value;	
	var titleArr = new Array();
	var titleUrlArr = new Array();
	var textArr = new Array();
	for(var i=0;i<promocount;i++)
	{
		titleArr[i] = document.getElementById("promotitle"+i).value;
		titleUrlArr[i] = document.getElementById("promotitleurl"+i).value;
		textArr[i] = document.getElementById("promotext"+i).value;
	}
	var ranNum= Math.floor(Math.random()* titleArr.length);		
	var promohref = document.getElementById("promohref");	
	promohref.firstChild.nodeValue = titleArr[ranNum];	
	promohref.href = titleUrlArr[ranNum];	
	var promotext = document.getElementById("promotext");
	promotext.innerHTML = textArr[ranNum];
}


//Functions for Phone Banking page

isNS4 = (document.layers) ? true : false;
  isIE4 = (document.all && !document.getElementById) ? true : false;
  isIE5 = (document.all && document.getElementById) ? true : false;
  isNS6 = (!document.all && document.getElementById) ? true : false;

  function ShowHideDiv(){
  //Take unlimited number of Div names and show or hide layer according to the last argument (boolean)
  //Parameters: In format 'div1','div2',.....,boolean
    var NumVar = ShowHideDiv.arguments.length;
    var NumDivs = NumVar - 1
    var BolVisible = ShowHideDiv.arguments[NumVar];

    for(i=0;i<NumDivs;i++)
      switchDiv(ShowHideDiv.arguments[i],BolVisible);
  }

  function ChangeVisibility(strDivName){
  //Check the visibility of the div passsed and change to the opposit
  //Parameter: Div name

    var objElement = document.getElementById(strDivName);

    if(objElement.style.visibility == "visible"){
      objElement.style.visibility = "hidden"
      objElement.style.display = "none";
    }else
      switchDiv(strDivName,true)
  }


  function switchDiv(strDivName,bolVisible){
  //identify the element based on browser type
  if (isNS4) {
    objElement = document.layers[strDivName];
  } else if (isIE4) {
    objElement = document.all[strDivName];
  } else if (isIE5 || isNS6) {
    objElement = document.getElementById(strDivName);
  }

  if (isNS4) {
    if (!bolVisible) {
      //objElement.style.visibility = "hidden";
      objElement.visibility ="hidden"
      objElement.style.display = "none";
    } else {
      //objElement.style.visibility = "visible";
      objElement.visibility ="visible";
      objElement.style.display = "";
    }
  } else {
    if (!bolVisible) {
      objElement.style.visibility = "hidden";
      objElement.style.display = "none";
      //document.layers[strDivName].visibility ="hidden"
    } else {
      objElement.style.visibility = "visible";
      objElement.style.display = "";
      //document.layers[strDivName].visibility ="visible"
    }
  }
}






/* Do Not put function below this */
-->