// KH. This is the version of the OBB Logout page that is currently in production. When setting the OBB Logout Page Don't Show
// cookie, this version number is used to work out if the logout page to be displayed has had the Don't Show cookie set or if it is the
// previous version.
var BPayLogoutPageVersion = "1.0";

function documentLinkPopup_Old(dlURl, dlName, dlOptions){
	window.open(dlURl, dlName, dlOptions);
}

function documentLinkPopup_old2(newlocation, dlName, dlOptions){

	var destination = newlocation;
	try
	{
		var qs = "&";
		//does current new location NOT have a query string defined
		if (newlocation.lastIndexOf("?")<0)
		{
			qs = "?";
		}
		//does the current URL have a Query String defined
		if (location.href.lastIndexOf("?")>0)
		{
			//if so get it from after the ? mark
			qs+=location.href.substring(location.href.lastIndexOf("?")+1);
			//add new query string to new location.
			destination = newlocation + qs;
		}
	}
	catch(e)
	{
		destination = newlocation;
	}
	window.open(destination, dlName, dlOptions);
}

function documentLink(newlocation){
	var destination = newlocation;

	try
	{
		lURLArr = new Array;
		lURLArr = newlocation.split("?");
		
		var qs = "";
		var lNewQS = "";
		//does current new location NOT have a query string defined
		//if (newlocation.lastIndexOf("?")<0)
		//{
		//	qs = "?";
		//}
		
		//does the current URL have a Query String defined
		if (location.href.lastIndexOf("?")>0)
		{
			lQSArr = new Array;
			var lHasPC = false;
			lQSArr = location.href.substring(location.href.lastIndexOf("?")+1).split("&")
			
			for(i=0;i<lQSArr.length;i++)
			{
				if(lQSArr[i].substring(0,9).toLowerCase()=="promocode" && lHasPC == false)
				{
					lHasPC = true;
					qs =  "promoCode" + lQSArr[i].substring(9);
				}
			}
			
			//if so get it from after the ? mark
			//qs+=location.href.substring(location.href.lastIndexOf("?")+1);
			//add new query string to new location.
			if(lHasPC == true)
			{
				// KH 8/02/2007. We may need to remove promocode information from 
				// the destination querystring.
				if(destination.lastIndexOf("?") > 0)
				{
					lQSArr = lURLArr[1].split("&");
					for(i=0;i<lQSArr.length;i++)
					{
						if (lQSArr[i].substring(0,9).toLowerCase()!="promocode")
						{								
							lNewQS += "promoCode" + lQSArr[i].substring(9) + "&";
						}
					}
				}
			
				destination = lURLArr[0] + "?" + lNewQS + qs;
			}
		}
	}
	catch(e)
	{
		destination = newlocation;
	}
	document.location.href=destination;
}

function documentLinkPopup(newlocation, dlName, dlOptions){

	var destination = newlocation;
		
	try
	{
		lURLArr = new Array;
		lURLArr = newlocation.split("?");
		
		var qs = "";
		var lNewQS = "";
		//does current new location NOT have a query string defined
		//if (newlocation.lastIndexOf("?")<0)
		//{
		//	qs = "?";
		//}
		
		//does the current URL have a Query String defined
		if (location.href.lastIndexOf("?")>0)
		{
			lQSArr = new Array;
			var lHasPC = false;
			lQSArr = location.href.substring(location.href.lastIndexOf("?")+1).split("&")
			
			for(i=0;i<lQSArr.length;i++)
			{
				if(lQSArr[i].substring(0,9).toLowerCase()=="promocode" && lHasPC == false)
				{
					lHasPC = true;
					qs =  "promoCode" + lQSArr[i].substring(9);
				}
			}
			
			//if so get it from after the ? mark
			//qs+=location.href.substring(location.href.lastIndexOf("?")+1);
			//add new query string to new location.
			if(lHasPC == true)
			{
				// KH 8/02/2007. We may need to remove promocode information from 
				// the destination querystring.
				if(destination.lastIndexOf("?") > 0)
				{
					lQSArr = lURLArr[1].split("&");
					for(i=0;i<lQSArr.length;i++)
					{
						if (lQSArr[i].substring(0,9).toLowerCase()!="promocode")
						{								
							lNewQS += "promoCode" + lQSArr[i].substring(9) + "&";
						}
					}
				}
			
				destination = lURLArr[0] + "?" + lNewQS + qs;
			}
		}
	}
	catch(e)
	{
		destination = newlocation;
	}
	window.open(destination, dlName, dlOptions);
}

function showLeaveSiteWarning(str_URL, bol_newWindow, str_message){
	alert (str_message);

	if(bol_newWindow == '' || bol_newWindow == 'false')
	{
		document.location.href=str_URL;
	}else{
		splashWin = window.open(str_URL,'newWindow', 'fullscreen=0,toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1');
	}

}

function showLeaveSiteWarning(str_URL, str_message, int_width, int_height){
	alert (str_message);
    var str_Features = 'width=' + int_width + ",height=" + int_height + ",fullscreen=0,toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1";
	
	splashWin = window.open(str_URL,'newWindow', str_Features);
}

function linkGIROPOST(){
	if(confirm("You are now leaving a BankWest site.\n\nBankWest is not responsible for the content of the site you are entering.\n\nPlease see the Website Disclaimer for further details. This disclaimer can be accessed by clicking on the link Please read our disclaimer at the bottom of any BankWest webpage.")){
		window.open("http://www.australiapost.com.au/IXP/0,1083,CH2017%257EMO19,00.html","AustraliaPost", "fullscreen=no,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
	}
}

function openGlossaryWindow(str_word, str_currentLevel){
	splashWin = window.open(str_currentLevel + 'library/scripts/glossaryEngine.asp?word=' + str_word,'glossary', 'width=200,height=200,fullscreen=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1');
}

function printViewWindow(){
	var printMessage = "This page prints better in landscape.";
//	var isMinIE4 = (document.all) ? 1 : 0;
//	var isMinIE5 = (navigator.appName.indexOf("Microsoft") && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;
//	var isMinIE6 = (navigator.appName.indexOf("Microsoft") && navigator.appVersion.indexOf("6.")) >= 0 ? 1 : 0;
//	var isMinIE7 = (navigator.appName.indexOf("Microsoft") && navigator.appVersion.indexOf("7.")) >= 0 ? 1 : 0;
//	alert("navigator.appVersion = " + navigator.appVersion + "\n" + "navigator.appName = " + navigator.appName);

	var bolPrintPageFlag = true;

	if (document.getElementById){

		if (document.getElementById("printLandscape")){
/*
			if(confirm(printMessage)){
				bolPrintPageFlag = true;
			}else{
				bolPrintPageFlag = false;
			}
*/
			alert(printMessage);
		}

		if (bolPrintPageFlag){
			var display_containerPage = document.getElementById("containerPage").style.width;
			var display_containerNavTabs = document.getElementById("containerNavTabs").style.display;
			var display_containerRight = document.getElementById("containerRight").style.display;
			var display_containerResizeAndPrint = document.getElementById("containerResizeAndPrint").style.display;
			var display_leftNavigation = document.getElementById("leftNavigation").style.display;
			var display_borderLeft = document.getElementById("borderLeft").style.display;
			var display_borderRight = document.getElementById("borderRight").style.display;
			if (document.getElementById("ProductHeaderImage")) {
				var display_ProductHeaderImage = document.getElementById("ProductHeaderImage").style.display;
			}
			if (document.getElementById("PageTitle")) {
				var display_PageTitle = document.getElementById("PageTitle").style.display;
			}
			if (document.getElementById("pageContent")) {
				var display_pageContent = document.getElementById("pageContent").style.width;
			}		
			if (document.getElementById("contentNavigation")) {
				var display_contentNavigation = document.getElementById("contentNavigation").style.width;
			}
			if (document.getElementById("dgForexRates")) {
				var display_dgForexRates = document.getElementById("dgForexRates").style.width;
			}
			if (document.getElementById("dgForexRatesFooter")) {
				var display_dgForexRatesFooter = document.getElementById("dgForexRatesFooter").style.width;
			}
			if (document.getElementById("incForeignExchangeRatesFullList")) {
				var display_incForeignExchangeRatesFullList = document.getElementById("incForeignExchangeRatesFullList").style.width;
			}
			
			document.getElementById("containerPage").style.width = "99%";
			document.getElementById("containerNavTabs").style.display = "none";
			document.getElementById("containerRight").style.display = "none";
			document.getElementById("containerResizeAndPrint").style.display = "none";
			document.getElementById("leftNavigation").style.display = "none";
			document.getElementById("borderLeft").style.display = "none";
			document.getElementById("borderRight").style.display = "none";
			if (document.getElementById("ProductHeaderImage")) {
				document.getElementById("ProductHeaderImage").style.display = "none";
			}
			if (document.getElementById("PageTitle")) {
				document.getElementById("PageTitle").style.display = "block";
			}
			if (document.getElementById("pageContent")) {
				document.getElementById("pageContent").style.width = "97%";
			}
			if (document.getElementById("contentNavigation")) {
				document.getElementById("contentNavigation").style.width = "97%";
			}
			if (document.getElementById("dgForexRates")) {
				document.getElementById("dgForexRates").style.width = "100%";
			}
			if (document.getElementById("dgForexRatesFooter")) {
				document.getElementById("dgForexRatesFooter").style.width = "100%";
			}
			if (document.getElementById("incForeignExchangeRatesFullList")) {
				document.getElementById("incForeignExchangeRatesFullList").style.width = "97%";
			}
		
			self.print();
	
			document.getElementById("containerPage").style.width = display_containerPage;
			document.getElementById("containerNavTabs").style.display = display_containerNavTabs;
			document.getElementById("containerRight").style.display = display_containerRight;
			document.getElementById("containerResizeAndPrint").style.display = display_containerResizeAndPrint;		
			document.getElementById("leftNavigation").style.display = display_leftNavigation;
			document.getElementById("borderLeft").style.display = display_borderLeft;
			document.getElementById("borderRight").style.display = display_borderRight;
			if (document.getElementById("PageTitle")) {
				document.getElementById("PageTitle").style.display = display_PageTitle;
			}
			if (document.getElementById("ProductHeaderImage")) {
				document.getElementById("ProductHeaderImage").style.display = display_ProductHeaderImage;
			}
			if (document.getElementById("pageContent")) {
				document.getElementById("pageContent").style.width = display_pageContent;
			}
			if (document.getElementById("contentNavigation")) {
				document.getElementById("contentNavigation").style.width = display_contentNavigation;
			}
			if (document.getElementById("dgForexRates")) {
				document.getElementById("dgForexRates").style.width = display_dgForexRates;
			}
			if (document.getElementById("dgForexRatesFooter")) {
				document.getElementById("dgForexRatesFooter").style.width = display_dgForexRatesFooter;
			}
			if (document.getElementById("incForeignExchangeRatesFullList")) {
				document.getElementById("incForeignExchangeRatesFullList").style.width = display_incForeignExchangeRatesFullList;
			}
		}
	}else{
		self.print();
	}
}

/*---------------------------------------------------------------------
	Copyright 2006 Bank of Western Australia Ltd.  All rights reserved.
	Name: Clear Search Field
	Author: Brett Griggs
	Description: Clears the "Search" field when selected.
---------------------------------------------------------------------*/
function ClearSearchField(){
  //document.searchSite.SearchString.value = "";
	document.search.SearchString.value = "";
	document.getElementById("searchButton").disabled = false;
}

/*---------------------------------------------------------------------
	Copyright 2006 Bank of Western Australia Ltd.  All rights reserved.
	Name: New Window Opener
	Author: Brett Griggs
	Description: Opens a new popup window.
---------------------------------------------------------------------*/
function openNewWindow(sUrl, sWindowName, sOptions){
	window.open (sUrl, sWindowName, sOptions);
}

/*---------------------------------------------------------------------
	Copyright 2006 Bank of Western Australia Ltd.  All rights reserved.
	Name: New Window Opener for auto-listed PDF files
	Author: Brett Griggs
	Description: Opens a new popup window.
---------------------------------------------------------------------*/
function openWindowPDF(sUrl){
	var winWidth = getScreenWidth() - 100;
	var winHeight = getScreenHeight();
	var winTop = 0;
	var winLeft = getCenterX(winWidth);
	var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes";
	openNewWindow(sUrl, "PDF", sOptions);
}

/*---------------------------------------------------------------------
	Copyright 2006 Bank of Western Australia Ltd.  All rights reserved.
	Name: New Window Opener
	Author: Brett Griggs
	Description: Opens a new popup window.
---------------------------------------------------------------------*/
function openWindow(sUrl, sRef, iWidth, iHeight){
	var winWidth = 0;
	var winHeight = 0;
	if (iWidth == -1){
		winWidth = getScreenWidth() - 50;
	}else{
		winWidth = iWidth;
	}
	if (iHeight == -1){
		winHeight = getScreenHeight() - 120;
	}else{
		winHeight = iHeight;
	}
	var winTop = 0;
	var winLeft = getCenterX(winWidth);
	var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes";
	openNewWindow(sUrl, sRef, sOptions);
}

/*---------------------------------------------------------------------
	Copyright 2006 Bank of Western Australia Ltd.  All rights reserved.
	Name: Jump To Menu Selection
	Author: Brett Griggs
	Description: 
---------------------------------------------------------------------*/
function JumpTo(){
	var form = document.forms["HeaderActions"];
	var serviceSelectedIndex = form.JumpToMenu.options[form.JumpToMenu.selectedIndex].value;
	var winWidth = 0;
	var winHeight = 0;
	var winTop = 0;
	var winLeft = 0
	
	switch(serviceSelectedIndex){
		case "1":	//About Us
			document.location.href = "/About_Us/";
			break;
		case "2":	//Find Us
			document.location.href = "/Find_Us/";
			break;
		case "3":	//Contact Us
			document.location.href = "/Contact_Us/";
			break;
		case "4":	//Media Centre
			document.location.href = "/Media_Centre/";
			break;
		case "5":	//Personal Banking
			document.location.href = "/Personal/";
			break;
		case "6":	//Business Banking
			document.location.href = "/Business/";
			break;
		case "7":	//Legal Info
			document.location.href = "/Legal_Info/";
			break;
		case "8":	//Site Map
			document.location.href = "/Sitemap/";
			break;
		case "9":	//Lite MasterCard
			var winWidth = getScreenWidth() - 20;
			var winHeight = getScreenHeight();
			var winTop = 0;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
			openNewWindow("http://www.abetterdeal.com.au/BankWest_Lite/index.asp", "JumpTo", sOptions);
			break;
		case "10":	//Zero MasterCard
			document.location.href = "/Personal/Credit_Cards/BankWest_Zero_MasterCard/";
			break;
		case "11":	//MasterCard Debit Card
			document.location.href = "/Personal/Transaction_Accounts/MasterCard_Debit_Card/";
			break;
		case "12":	//Credit Cards
			document.location.href = "/Personal/Credit_Cards/";
			break;
		case "13":	//Personal Loans
			document.location.href = "/Personal/Personal_Loans/";
			break;
		case "14":	//Savings & Investments
			document.location.href = "/Personal/Savings_and_Investment/";
			break;
		case "15":	//Transaction Accounts
			document.location.href = "/Personal/Transaction_Accounts/";
			break;
		case "16":	//Home Loans
			document.location.href = "/Personal/Home_Loans/";
			break;
		case "17":	//Insurance
			document.location.href = "/Personal/Insurance/";
			break;
		case "18":	//Online Banking
			document.location.href = "http://help.ibs.bankwest.com.au/retail/";
			break;
		case "19":	//Online Business Banking
			document.location.href = "/Business/How_to_Bank_with_Us/Online_Business_Banking/";
			break;
		case "20":	//Business Accounts
			document.location.href = "/Business/Business_Accounts/";
			break;
		case "21":	//Business Loans
			document.location.href = "/Business/Business_Loans/";
			break;
		case "22":	//Deposit Services
			// document.location.href = "/Business/Services/";
			document.location.href="/Business/Business_Deposits/";
			break;
		case "23":	//How to Bank with Us
			document.location.href = "/Business/How_to_Bank_with_Us/";
			break;
		case "24":	//Industry Sectors
			document.location.href = "/Business/Industry_Sectors/";
			break;
		case "25":	//Our Divisions
			document.location.href = "/Business/How_to_Bank_with_Us/Our_Divisions/";
			break;
		case "26":	//International
			document.location.href = "/Business/International/";
			break;
		case "27":	//Switch Now - BankWest Account Switching
			var winWidth = 950;
			var winHeight = getScreenHeight() - 150;
			var winTop = 10;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes";
			openNewWindow("/Switching/", "JumpTo", sOptions);
			break;
		default:
			alert("No selection was made.\nPlease make a selection and try again.");
			break;
	}
}

/*---------------------------------------------------------------------
	Copyright 2006 Bank of Western Australia Ltd.  All rights reserved.
	Name: Apply For Menu Selection
	Author: Brett Griggs
	Description: 
---------------------------------------------------------------------*/
function ApplyFor(){
	var form = document.forms["HeaderActions"];
	var serviceSelectedIndex = form.ApplyForMenu.options[form.ApplyForMenu.selectedIndex].value;
	var winWidth = 0;
	var winHeight = 0;
	var winTop = 0;
	var winLeft = 0;
	
	switch(serviceSelectedIndex){
		case "1":	//Lite MasterCard
			var winWidth = getScreenWidth() - 20;
			var winHeight = getScreenHeight();
			var winTop = 0;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
			openNewWindow("http://www.abetterdeal.com.au/BankWest_Lite/index.asp", "JumpTo", sOptions);
			break;
		case "2":	//Credit Cards
			document.location.href = "/Personal/Credit_Cards/";
			break;
		case "3":	//Home Loans
			document.location.href = "/Personal/Home_Loans/";
			break;
		case "4":	//Personal Loans
			document.location.href = "/Personal/Personal_Loans/";
			break;
		case "5":	//Savings & Investments
			document.location.href = "/Personal/Savings_and_Investment/";
			break;
		case "6":	//Transaction Accounts
			document.location.href = "/Personal/Transaction_Accounts/";
			break;
		case "7":	//Business Cheque Account
			document.location.href = "/Business/Business_Accounts/Business_Cheque_Account/";
			break;
		case "8":	//Business Bonus Account
			document.location.href = "/Business/Business_Accounts/Business_Bonus_Account/";
			break;
		case "9":	//Money Market Deposit Account
			document.location.href = "/Business/Business_Accounts/Money_Market_Deposit_Account/";
			break;
		case "10":	//Business Edge Loan
			document.location.href = "/Business/Business_Loans/Business_Edge_Loan/";
			break;
		case "11":	//Business Low Doc Loan
			document.location.href = "/Business/Business_Loans/Business_Low_Doc_Loan/";
			break;
		case "12":	//Business Equity Line
			document.location.href = "/Business/Business_Loans/Business_Equity_Line/";
			break;
		case "13":	//Business Equity Line
			document.location.href = "/Personal/Credit_Cards/BankWest_Zero_MasterCard/";
			break;
		case "14":	//Business Equity Line
			document.location.href = "/Personal/Savings_and_Investment/";
			break;
		case "15":	//Business Equity Line
			document.location.href = "/Personal/Transaction_Accounts/";
			break;
		case "16":	//Business TeleNet Saver
			document.location.href = "/Business/Business_Accounts/Business_TeleNet_Saver/";
			break;
		case "17":	//BankWest Business Visa
			document.location.href = "/Business/Business_Credit_Card/";
			break;
		case "18":	//Business Overdrafts
			document.location.href = "/Business/Business_Loans/Business_Overdrafts/";
			break;
		case "19":	//Commercial Advances
			document.location.href = "/Business/Business_Loans/Commercial_Advances/";
			break;
		case "20":	//Car and Equipment Finance
			document.location.href = "/Business/Business_Loans/Car_and_Equipment_Finance/";
			break;
		case "21":	//Farm Management Deposits
			document.location.href = "/Business/Business_Accounts/Farm_Management_Deposits/";
			break;
		case "22":	//Fixed Interest Commercial Loan
			document.location.href = "/Business/Business_Loans/Fixed_Interest_Commercial_Loan/";
			break;
		case "23":	//Foreign Currency Account
			document.location.href = "/Business/Business_Accounts/Foreign_Currency_Accounts/";
			break;
		case "24":	//Harvest Line
			document.location.href = "/Business/Business_Loans/Harvest_Line/";
			break;
		case "25":	//Inventory Finance
			document.location.href = "/Business/Business_Loans/Inventory_Finance/";
			break;
		case "26":	//Invoice Discounting
			document.location.href = "/Business/Business_Loans/Invoice_Discounting/";
			break;
		case "27":	//Online Business Banking
			document.location.href = "/Business/How_to_Bank_with_Us/Online_Business_Banking/Apply_or_Amend/";
			break;
		case "28":	//AgriOne
			document.location.href = "/Business/Business_Accounts/AgriOne/";
			break;
		case "29":	//Insurance
			document.location.href = "/Personal/Insurance/";
			break;
		case "30": // Commercial loans
			document.location.href="/Business/Commercial_Loans/";
			break;
		default:
			alert("No selection was made.\nPlease make a selection and try again.");
			break;
	}
}

/*---------------------------------------------------------------------
	Copyright 2006 Bank of Western Australia Ltd.  All rights reserved.
	Name: Online Service Menu Selection
	Author: Brett Griggs
	Description: 
---------------------------------------------------------------------*/
function OnlineServicesLogon(){
	var form = document.forms["HeaderActions"];
	var serviceSelectedIndex = "";
	var serviceFixedIndex = "";
	var winWidth = 0;
	var winHeight = 0;
	var winTop = 0;
	var winLeft = 0;
	
	serviceSelectedIndex = form.OnlineServicesMenu.options[form.OnlineServicesMenu.selectedIndex].value;
	if (form.serviceFixedIndex) {
		serviceFixedIndex = form.serviceFixedIndex.value;
	}
	
	if ((serviceSelectedIndex == "") && (serviceFixedIndex > 0)){
		serviceSelectedIndex = serviceFixedIndex;
	}
	
	switch(serviceSelectedIndex){
		case "1":	//Personal Banking
			var winWidth = 1024;
			var winHeight = 768;
			var winTop = 5;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes";
			openNewWindow("/Special_Pages/IBS_Pages/Retail/index.asp", "", sOptions);
//			openNewWindow("https://ibs.bankwest.com.au/BWLogin/rib.aspx", "", sOptions);
			break;
		case "2":	//Business Banking
			var winWidth = 1024;
			var winHeight = 768;
			var winTop = 5;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes";
			
			//check cookie existance	
			var cookieValue = '';
			// KH. Changed to include a version number to allow the bpay page to redisplay if a new version of the page has been uploaded.
			var cookieName = "OBBLogoutHide_" + BPayLogoutPageVersion;;

			cookieValue = getCookie(cookieName)
			if ((cookieValue == "") || (cookieValue == "false"))
			{
				//if no cookie exists then redirect current document to OBB logout page
				//if cookie does not exist then reidrect to /Special_Pages/IBS_Pages/OBB_Logout_Page/
				//Uncomment the following line if you want to re-activate the redirection to BPAY
				// document.location = "/Special_Pages/IBS_Pages/OBB_Logout_Page/";
			}
			// Redirects to a redirection page. This page will normally redirect to the IBS login page or, between the date set in the page, will 
			// redirect the user to an IBS unavailable page.
			openNewWindow("/Special_Pages/IBS_Pages/Business/index.asp", "", sOptions);
//			openNewWindow("https://ibs.bankwest.com.au/BWLogin/bib.aspx", "", sOptions);
			break;
		case "3":	//Sharetrading
			var winWidth = getScreenWidth() - 20;
			var winHeight = getScreenHeight();
			var winTop = 0;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
			// openNewWindow("http://www.sanford.com.au/onlinesharetrading/Public/Home/Login.asp?ref=24012003", "Sharetrading", sOptions);
			openNewWindow("https://sharetrading.coretrading.com.au/", "Sharetrading", sOptions);
			break;
		case "4":	//Insurance
			var winWidth = getScreenWidth() - 20;
			var winHeight = getScreenHeight();
			var winTop = 0;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
			openNewWindow("http://www.bankwest.com.au/library/templates/scripts/redir_insurance.asp?Logon", "Insurance", sOptions);
			break;
		case "5":	//BankWest extra
			var winWidth = getScreenWidth() - 20;
			var winHeight = getScreenHeight();
			var winTop = 0;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
			openNewWindow("http://bankwestextra.rewardscard.com.au", "BankWestExtra", sOptions);
			break;
		case "6":	//BankWest More Rewards
			var winWidth = getScreenWidth() - 20;
			var winHeight = getScreenHeight();
			var winTop = 0;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
// More Rewards site hacked as of Sat 20th Mar 2010.
			//alert('Regrettably Bankwest More Rewards is temporarily unavailable.  Please try again later.');
			openNewWindow("http://www.bankwestmorerewards.com.au", "BankWestMoreRewards", sOptions);
			break;
		case "7":	//Business Rewards
			var winWidth = getScreenWidth() - 20;
			var winHeight = getScreenHeight();
			var winTop = 0;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
			openNewWindow("http://www.bankwestbusinessrewards.com.au/", "BankWestBusinessRewards", sOptions);
			break;
		case "8":	//Smart Data
			var winWidth = getScreenWidth() - 20;
			var winHeight = getScreenHeight();
			var winTop = 0;
			var winLeft = getCenterX(winWidth);
			var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,resizable=yes";
			openNewWindow("https://sdg2.mastercard.com/", "SmartData", sOptions);
			break;
		default:
			alert("No selection was made.\nPlease make a selection and try again.");
			break;
	}
	form.serviceFixedIndex.value = "";
}

function setServiceFixedIndex(iServiceNumber){
	var form = document.forms["HeaderActions"];

	form.serviceFixedIndex.value = iServiceNumber;
}

function getNewDate(value) {
	if (value) {
		var date = new Date();
		date.setTime(date.getTime()+(value*60*1000));
		var sCookieExpiry = date.toGMTString();
	} else {
		var sCookieExpiry = "";
	}
	return sCookieExpiry;
}

function DeleteCookie(name){
  setCookie(name, name, 0);	
}

function getCookie(name){
	var cookie = ' ' + document.cookie;
	var search = ' ' + name + '=';
	var setStr = '';
	var offset = 0;
	var end = 0;
	if (cookie.length > 0){
		offset = cookie.indexOf(search);
		if (offset != -1){
			offset += search.length;
			end = cookie.indexOf(';', offset)
			if (end == -1){
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function setCookie(setCookieName, setCookieValue, iMinutes){
	var setCookieExpiry = "";
	var setCookieDomain = "bankwest.com.au";
	var setCookiePath = "/";
	var setNewDate = new Date();
	var setCookieExpiry = setNewDate.setTime(setNewDate.getTime()+(iMinutes*60*1000));
	var setCookieExpiry = setNewDate.toGMTString();
//	document.cookie = setCookieName + "=" + setCookieValue + "; expires=" + setCookieExpiry + "; path=" + setCookiePath + "; domain=" + setCookieDomain;
	document.cookie = setCookieName + "=" + setCookieValue + "; expires=" + setCookieExpiry + "; path=" + setCookiePath;
}

function ResizeText(sTag, iIncrement){
	// The var sTag is ignored but left in for compatibility

	var fontSteps = new Array('70%','80%','90%','100%','110%','120%','130%');
	var defaultFontStep = 3;
	var currentFontStep = defaultFontStep * 1;
	var newFontStep = defaultFontStep * 1;

	if (getCookie("resizeText")!="") {
		currentFontStep = getCookie("resizeText") * 1;
		newFontStep = currentFontStep;
	}
	if (document.getElementById("pageContent")){
		if (((currentFontStep + iIncrement) > -1) && ((currentFontStep + iIncrement) < fontSteps.length)) {
			newFontStep = currentFontStep + iIncrement;
			document.getElementById("pageContent").style.fontSize = fontSteps[newFontStep];
		}
	}
	setCookie("resizeText", newFontStep, 30*24*60);
}

function ResetTextSize(){
	var defaultFontStep = 3;
	var newFontStep = 0;
	
	if (getCookie("resizeText")!="") {
		var currentFontStep = getCookie("resizeText")*1;
	}
//	setCookie("resizeText", (sz-3)*-1, 30*24*60);
	newFontStep = defaultFontStep + (currentFontStep * -1);

	ResizeText('body', newFontStep);
}

function openWindowHLSForm(strURL){
	var winWidth = 520;
//	var winHeight = getScreenHeight()/2;
	var winHeight = 650;
	var winTop = 5;
	var winLeft = getCenterX(winWidth);
	var sOptions = "width="+winWidth+",height="+winHeight+",top="+winTop+",left="+winLeft+",scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=no";
	openNewWindow(strURL, "MBM_Form", sOptions);
}

/* KH Sets the BPay page logout cookie using the current version of the Bpay page as part of the cookie name.
    This allows the page to be redisplayed if a new version of the page has been setup.*/
function SetHideOBBCookie(pHide){
	var cookieName, cookieValue

	cookieName = "OBBLogoutHide_" + BPayLogoutPageVersion;
	cookieValue = pHide;
	setCookie(cookieName,cookieValue,100000);
}
