/* -------------------------------------------------------------------------------------------------------------
   HEADER.JS <SCRIPT>
   -------------------------------------------------------------------------------------------------------------
   Creates the
   a) Step Description
   b) Step Numbers with Previous & Next
   listed at the top of every BMO Tour page.
   
   Notes:
   1. MUST be called from subfolder, otherwise the relative paths to the images and the anchors will break.
   2. Paths for images relative to where the include file is
      Hence, use ../../images/ to get to the images
*/

function pad(plength) {
	var s = "";
	var return_value = "";
	
	s = this.valueOf().toString();
	return_value = s;
	if (s.length < plength) {return_value = "000000000".substring(0, plength - s.length) + return_value;}
	return return_value;  	
}
String.prototype.pad = pad;

function Title(pimage, ptitle, ptext) {
	// class used to hold onto the image, title and text of each bmo tour section
	this.image = pimage; this.title = ptitle; this.text = ptext;
}

// variables used throughout this page
var mfilename = "", mfilenamefirst = "", mfilenamesecond = "";
var manchors = null;
var mtitles = null;
var mstep = -1, msub = -1;
var mname = "";

function initialize() {
	var hold = "";
	var lastslash = -1;
	var underscore = -1;
	var counter = -1;
	
	// step 1: get the name of the file, and break it into 2 parts
	hold = window.location.pathname;
	if (hold == "") { alert("Error: Javascript_Include.js: window.location.pathname is blank."); }
	if (hold.substring(0,1) != "/") { hold = "/" + hold; }
	
	lastslash = hold.lastIndexOf("/");
	mfilename = hold.substring(lastslash+1, hold.length);

	underscore = mfilename.indexOf("_");
	if (underscore != -1) {
		mfilenamefirst = mfilename.substring(0, underscore);
		mfilenamesecond = mfilename.substring(underscore+1, mfilename.length);
	}

	// step 2: Create the steps
	// ROBIN -> this is where you change the HRef for the anchors in the steps 1-10
	manchors = new Array();
	manchors[1] = "../finsum/finsum_mysum.html";
	manchors[2] = "../finsum/finsum_viewacc.jsp";
	manchors[3] = "../billpay/billpay_pay.jsp";
	manchors[4] = "../transfers/transfers_account.jsp";
	manchors[5] = "../transfers/transfers_email_send.html";
	manchors[6] = "../messcent/messcent_contactus.html";
	manchors[7] = "../persinfo/persinfo_change.html";
	manchors[8] = "../accnts/accnts_order.html";
	manchors[9] = "../invest/invest_myinvest.html";
	manchors[10] = "../mortlons/mortlons_myholdings.html";
	manchors[11] = "../thankyou/thankyou.html";
	// the final next is coded in header_topnav() 2.3
		
	// step 3: map the name of the file to the step we are on
	// ROBIN -> add your new filenames here -
	//          make sure the numbers below are in sync with the above filenames i.e. billpay MUST match 2 in manchors[2]
	var pages = new Object();	
	pages.finsum = 1;	// mtitles[1][1]
	pages.finsum_mysum = 1;	// mtitles[1][1]
	pages.finsum_viewacc = 2;	// mtitles[2][1]
	pages.finsum_download = 2;	// kludge: finsum_download should really be titled finsum_viewacc_download, since it's not, it needs to be included here to indicate it's part of step 2
	pages.billpay = 3;	// mtitles[3][1]
	pages.transfers = 4;	// mtitles[4][1]
	pages.transfers_email = 5;	// mtitles[5][1]
	pages.messcent_contactus = 6;	// mtitles[6][1]
	pages.persinfo_change = 7;	// mtitles[7][1]
	pages.accnts = 8;	// mtitles[8][1]
	pages.invest_myinvest = 9;	// mtitles[9][1]
	pages.mortlons_myholdings = 10;	// mtitles[10][1]
	pages.thankyou = 11;

	var subpages = new Object()
	subpages.finsum_download = 2;		// kludge: finsum_download is also specifies a main section, but we want the text to be different than finsum_viewacc
	subpages.finsum_tracker = 5;	// mtitles[from above][5]
	subpages.billpay_modify_add = 2;	// mtitles[from above][2]
	subpages.transfers_advance = 2;	// mtitles[from above][2]
	subpages.transfers_email_receive = 2;	// mtitles[from above][2]
	subpages.transfers_email_cancel = 3;	// mtitles[from above][3]
	subpages.transfers_email_reminder = 4;	// mtitles[from above][4]
	subpages.accnts_stop = 2;	// mtitles[from above][2]

	// initialize form level variables
	for (var i in pages) {
		if (mfilename.match(i)) { mstep = pages[i]; }
	}
	if (mstep == -1) { alert("ERROR:Header.JS:Initialize: Could not match the filename to a page in Pages."); }
	
	msub = 1;	// default to 1
	for (var i in subpages) {
		if (mfilename.match(i)) { msub = subpages[i]; }
	}	

	// get the name cookie : user's name is store in a cookie created by takeatour.html, grab it if it exists...
	var cookie_array = null; cookie_element = null; i =0;

	// Load the last time popup was displayed from cookie (if it exists)
	cookie_array = document.cookie.split("; ");
	for (i=0; i<cookie_array.length; i++) {
		cookie_element = cookie_array[i].split("=");
		if (cookie_element[0]=="BMOTourName") {
			mname = cookie_element[1];	// reads in the date (in milliseconds) the last popup was displayed
		}
	}
	if ((!mname) || (mname.replace(" ", "") == "")) { mname = "Your Name"; }

	title_initialize();
}
initialize();

function title_initialize() {
	var counter = -1;
	
	// step 1: create an array to hold the titles
	mtitles = new Array(manchors.length);
	for (counter=1; counter < manchors.length; counter++) {
		mtitles[counter] = new Array(5);	// max 4 different titles per section
	}
	
	// ROBIN - add your new titles & sub-titles here
	// step 2: populate the titles ( image width=153 height=202 )

	// 1.1 Financial Summary
	mtitles[1][1] = new Title(
		  "tour_image_01.jpg"
		, "My Summary"
		, "Once you've signed in with your Bank Card number and password, your Online Banking session starts with the My Summary page. This screen provides a complete listing of all your bank accounts, investments, loans, and credit cards with BMO Bank of Montreal. It offers the convenience of seeing your entire financial picture at a glance, including the date of your last sign in. If you've asked customer service a question, this is where you'll find a flashing 'Customer Service Response' signal. (Don't forget to roll your mouse over the screen tabs to find the red pop-up boxes.)"
	);

	// 1.5 Download Account Details
	mtitles[1][5] = new Title(
		  "tour_image_03.jpg"
		, "BMO Account Tracker"
		, "BMO Account Tracker is a complimentary service that is available to clients with a minimum balance of $25,000 in BMO Term Investments and/or BMO Mutual Funds."
	);

	// 2.1 Account Details
	mtitles[2][1] = new Title(
		  "tour_image_03.jpg"
		, "Account Details"
		, "Under the Financial Summary tab, you can choose View Account Details and take a complete and detailed look at the bank accounts linked to your Bank Card. Or view a transaction history of the account by selecting a date range. You can even download your account details to your money management software. Try it now to see how it works."
	);

	// 2.2 Download Account Details
	mtitles[2][2] = new Title(
		  "tour_image_03.jpg"
		, "Download Account Details"
		, "If you're using money management software programs you'll be able to download your account details from Online Banking. Just select the account you wish to download (only accounts linked to your FirstBank CardŽ can be downloaded), select the software you're using, and press Download Now. You'll even be able to download from multiple accounts at once to save time."
	);	

	// 3.1 Pay Bills
	mtitles[3][1] = new Title(
		  "tour_image_02.jpg"
		, "Pay Bills"
		, "One of the most convenient ways to use Online Banking is to pay bills quickly and easily. No more writing cheques, buying stamps, or mailing envelopes. Online Banking lets you add and delete billers, and pay virtually all your bills - up to 3 at once - in just seconds. You can even set up future-dated bill payments in advance to be sure you don't miss a payment date, and can sign up to have your bills delivered online through <i>epost</i> *.<p>Try paying a bill now by using the interactive screen below.<p><span class=smallerText>*The following are trademarks of Canada Post Corporation: <i>epost</i>, <i>epost box</i>, Electronic Postmark, the 'wedge' design and the 'e' page.</span>"

	);

	// 3.2 Add Billers
	mtitles[3][2] = new Title(
		  "tour_image_02.jpg"
		, "Add Billers"
		, "One of the most convenient ways to use Online Banking is to pay bills quickly and easily. No more writing cheques, buying stamps, or mailing envelopes. Online Banking lets you add and delete billers, and pay virtually all your bills - up to 3 at once - in just seconds. You can even set up future-dated bill payments in advance to be sure you don't miss a payment date, and can sign up to have your bills delivered online through <i>epost</i> *.<p>Try paying a bill now by using the interactive screen below.<p><span class=smallerText>*The following are trademarks of Canada Post Corporation: <i>epost</i>, <i>epost box</i>, Electronic Postmark, the 'wedge' design and the 'e' page.</span>"

	);

	// 4.1 Account Transfer
	mtitles[4][1] = new Title(
		  "tour_image_03.jpg"
		, "Account Transfer"
		, "Online Banking also makes it easy to move your money around. A click on the Transfers tab allows you to do Account Transfers where you can move your money between your Canadian and US dollar bank accounts, MasterCard and Line of Credit, complete Email Money Transfers and more. Simply choose where you want the money to come from, where you need it to go, and the amount. Online Banking does the rest, and provides a complete record and history of your transfers.<p>Try transferring funds now by using the interactive screen below."
	);

	// 4.2 Cash Advance 
	mtitles[4][2] = new Title(
		  "tour_image_03.jpg"
		, "Cash Advance "
		, "Online Banking also makes it easy to move your money around. A click on the Transfers tab allows you to do Account Transfers, Cash Advances, Email Money Transfers and more. Simply choose where you want the money to come from, where you need it to go, and the amount. Online Banking does the rest, and provides a complete record and history of your transfers.<p>Try transferring funds now by using the interactive screen below."
	);

	// 5.1 Send Money 
	mtitles[5][1] = new Title(
		  "tour_image_01.jpg"
		, "Send Money "
		, "The innovative Email Money Transfer function, found under the Transfers tab, lets you send and receive money quickly and securely to and from anyone with an email address and a Canadian bank account. It's a great way to send and receive money - person to person - without the hassle and expense of money orders and cheques. You can send email reminders to the recipient, and can even check the status of the money transfer. Plus, with many Everyday Banking Plans, you get 2 free Email Money Transfers each month.<p>Try an Email Money Transfer right now using the interactive screen below."
	);

	// 5.2 Receive Money 
	mtitles[5][2] = new Title(
		  "tour_image_01.jpg"
		, "Receive Money "
		, "To receive money through Email Money Transfer, you'll receive an email alerting you that your funds are waiting. Just click on the link provided in the email to go to the CertaPay site (our Email Money Transfer partner) and select BMO Bank of Montreal from the options provided. You'll then be taken to the BMO Bank of Montreal Online Banking site. Once you've signed in, you'll be asked a security question to ensure that you're the intended recipient. Finally, just indicate to which account you'd like the money deposited, and you're done. It really is quick, easy and convenient."
	);

	// 5.3 Cancel Money Transfer 
	mtitles[5][3] = new Title(
		  "tour_image_01.jpg"
		, "Cancel Money Transfer "
		, "If you need to cancel an Email Money Transfer or if a transaction expires or is declined due to the recipient failing to correctly answer the security question, just click Cancel Money Transfer. Once the transaction is cancelled by you, the Email Money Transfer funds are re-deposited to your account."
	);

	// 5.4 Send Reminder Email 
	mtitles[5][4] = new Title(
		  "tour_image_01.jpg"
		, "Send Reminder Email "
		, "If your recipient deletes the email notification or if you need to revise a recipient's email address for an Email Money Transfer that has already been sent, simply select Send Reminder Email and your recipient will once again receive all the information necessary to collect their funds."
	);

	// 6.1 Write Us
	mtitles[6][1] = new Title(
		  "tour_image_03.jpg"
		, "Write Us"
		, "While using Online Banking, if you need advice or assistance and can't locate the information on the site, you can head for the Message Centre. Under the Contact Us tab, you'll find the handy and secure Write Us page. Simply type your request and you'll receive a response, usually within 24 hours. A flashing envelope on the My Summary page will indicate that you have a new message. Responses, as well as previous Messages, can be found in the Message Centre. You'll also find a 1 800 number you can use to speak with a Direct Banking Manager."
	);

	// 7.1 Change Address
	mtitles[7][1] = new Title(
		  "tour_image_04.jpg"
		, "Change Address"
		, "Use this handy page to change your information online - simply and accurately - in just minutes. Simply review your existing information and then make changes in the boxes found below. For addresses outside of Canada, use the Write Us form found under the Message Centre tab and we'll handle the rest."
	);

	// 8.1 Order Cheques
	mtitles[8][1] = new Title(
		  "tour_image_02.jpg"
		, "Order Cheques"
		, "Under the Accounts & Plans tab you'll find everything you need to open a new account, order new cheques, put a stop payment on a cheque, order travellers cheques and more - online, quickly and easily. You'll save time and hassles, and wonder how you ever lived without it."
	);

	// 8.2 Stop Payment on One Cheque 
	mtitles[8][2] = new Title(
		  "tour_image_02.jpg"
		, "Stop Payment on One Cheque "
		, "Under the Accounts & Plans tab you'll find everything you need to open a new account, order new cheques, put a stop payment on a cheque, order travellers cheques and more - online, quickly and easily. You'll save time and hassles, and wonder how you ever lived without it."
	);

	// 9.1 My Investments 
	mtitles[9][1] = new Title(
		  "tour_image_02.jpg"
		, "My Investments"
		, "To make it easy to track your investments - as well as learn more about other investing opportunities - the My Investments page is indispensable. You'll find all your account details in one place, with one-click links to full account and transaction details.<p>Plus, you'll enjoy access to investing tools, information and more to help you learn more about investing at BMO Bank of Montreal."
	);

	// 10.1 My Holdings 
	mtitles[10][1] = new Title(
		  "tour_image_04.jpg"
		, "My Holdings "
		, "Use the My Holdings page under the Mortgages & Loans tab. It's an at-a-glance page that summarizes your loans, mortgages, and credit cards to make it easier to manage your finances. You're also just a page-click away from Lump Sum Mortgage Payment, which lets you pay down your mortgage faster; Increase Mortgage Payment, which lets you increase the amount of your regular mortgage payments by up to 20% per year; Skip Mortgage Payment, which lets you take a break should you need it; as well as Mortgage & Loan Applications.<p>There's also helpful links to make it easy to find more information about BMO Bank of Montreal's full range of financial products and services."
	);

	// 11. Final Thankyou (should not show up as a clicable step)
	mtitles[11][1] = new Title(
		  "tour_image_01.jpg"
		, "Thank You"
		, "That concludes your BMO Bank of Montreal Online Banking Tour. We hope you found it interesting and informative.<p>Online Banking truly is an easy and convenient way to manage your everyday banking and all your finances. Once you've signed up and used Online Banking, you'll wonder why you've done without it for so long."
	);

	if (!(mtitles[mstep][msub])) {alert("ERROR:Header.JS:title_initialize: Section " + mstep + "." + msub + " does not have a mtitle defined."); }
}

function header_topnav() {
	var counter = 0;
	var image_name = "";
	var image_mouseover = ""; image_mouseout = "";

	// step 1: show the title specific to this page
	document.write(
		"<map name='topnav'><area shape='rect' coords='720,7,759,27' href='javascript:close();' alt='close'></map>"
		+ "<table width='775' cellspacing='0' cellpadding='0' border='0'>"
		+ "<tr>"
		+ "    <td colspan='5'><img src='../../images/en/tour_topnav.gif' width=775 height=90 border=0 alt='' usemap='#topnav'></td>"
		+ "</tr>"
		+ "<tr valign='TOP'>"
		+ "    <td><img src='../../images/en/spacer.gif' width=28 height=10 border=0 alt=''></td>"
		+ "    <td><img src='../../images/en/" + mtitles[mstep][msub].image + "' width=153 height=202 border=0 alt=''></td>"
		+ "    <td><img src='../../images/en/spacer.gif' width=35 height=10 border=0 alt=''></td>"
		+ "    <td><img src='../../images/en/tour_title.gif' width=422 height=37 border=0 alt='BMO Bank of Montreal Online Banking Tour'><br>"
		+ "	<span class=title>" + mtitles[mstep][msub].title + "</span><br>"
		+ "	<img src='../../images/en/spacer.gif' width=10 height=10 border=0 alt=''><br>"
		+ "	<span class=bodytext>" + mtitles[mstep][msub].text + "</span></td>"
		+ "    <td><img src='../../images/en/spacer.gif' width=137 height=10 border=0 alt=''></td>"
		+ "</tr>"
		+ "<tr>"
		+ "    <td colspan='5'><img src='../../images/en/spacer.gif' width=775 height=10 border=0 alt=''></td>"
		+ "</tr>"
		+ "</table>"
	);	
	
	if (mstep != 11) {
		// step 2.1 : show the previous (if applicable) and main button
		document.write(	
			  "<table width='775' cellspacing='0' cellpadding='0' border='0'>"
			+ "<tr>"
			+ "    <td><img src='../../images/en/spacer.gif' width=110 height=10 border=0 alt=''></td>"
			+ "    <td><img src='../../images/en/spacer.gif' width=38 height=21 border=0 alt=''></td>"
			+ "    <td><img src='../../images/en/spacer.gif' width=7 height=10 border=0 alt=''></td>"
		);

		if (mstep > 1) {
			image_name = "<a href='" + manchors[mstep-1] + "'><img src='../../images/en/tour_but_prev.gif' width=60 height=18 border=0 alt='Previous'></a>";
		} else {
			image_name = "<img src='../../images/en/spacer.gif' width=49 height=21 border=0 alt=''>";
		}	
		document.write("<td>" + image_name + "</td>");
	
		// step 2.2 : show steps 1-10 - turn the proper number on and off
		for (counter=1; counter < manchors.length-1; counter++) {
			if (mstep != 11) {
				image_name = "tour_" + counter.toString().pad(2);	// tour_02
				if (counter == mstep) { image_name += "_on" } else { image_name += "_off" }
				image_name += ".gif"
		
				if (counter == mstep) {
					image_mouseover = "";
					image_mouseout = "";
				} else {								
					image_mouseover = " onmouseover=\"document.step" + counter + ".src='../../images/en/" + "tour_" + counter.toString().pad(2) + "_on.gif';\"";
					image_mouseout = " onmouseout=\"document.step" + counter + ".src='../../images/en/" + "tour_" + counter.toString().pad(2) + "_off.gif';\"";
				}
				document.write(
					  "    <td><img src='../../images/en/spacer.gif' width=9 height=10 border=0 alt=''></td>"
					+ "    <td><a href='" + manchors[counter] + "'><img " + image_mouseover + image_mouseout + " src='../../images/en/" + image_name + "' width=20 height=21 border=0 alt='" + counter + "' name='step" + counter + "'></a></td>"
				);
			} else {
				document.write(
					  "    <td><img src='../../images/en/spacer.gif' width=9 height=10 border=0 alt=''></td>"
					+ "    <td><img src='../../images/en/spacer.gif' width=20 height=21 border=0 alt=''></td>"
				);
			}
		}
	
	
		// step 2.3 : show the next button (if applicable)
		if (mstep == 11) {
			image_name = "<img src='../../images/en/spacer.gif' width=10 height=21 border=0 alt=''><a href='../finsum/finsum_mysum.html'><img src='../../images/en/tour_but_main.gif' width=38 height=21 border=0 alt='Main'></a>";
		} else {
			image_name = "<a href='";
			if (mstep < (manchors.length-1)) { image_name += manchors[mstep+1]; } else { image_name += "../thankyou/thankyou.html"; }
			image_name += "'><img src='../../images/en/tour_but_next.gif' width=48 height=18 border=0 alt='Next'></a>";
		}
	
		if (mstep == 11) { mname = ""; }	
	
		document.write(
			  "    <td><img src='../../images/en/spacer.gif' width=9 height=10 border=0 alt=''></td>"
			+ "    <td>" + image_name + "</td>"
			+ "    <td><img src='../../images/en/spacer.gif' width=20 height=10 border=0 alt=''></td>"
			+ "    <td><a href='javascript:window.close();'><img src='../../images/en/tour_but_reg.gif' width=146 height=18 border=0 alt='Register Now For Online Banking'></a></td>"
			+ "    <td><img src='../../images/en/spacer.gif' width=17 height=10 border=0 alt=''></td>"
			+ "</tr>"
			+ "<tr>"
			+ "    <td colspan='29'><img src='../../images/en/spacer.gif' width=10 height=10 border=0 alt=''></td>"
			+ "</tr>"
			+ "<tr>"
			+ "    <td colspan='29'><img src='../../images/en/spacer.gif' width=19 height=10 border=0 alt=''><span class=helplinks><b>" + mname + "</b></span></td>"
			+ "</tr>"
			+ "<tr>"
			+ "    <td colspan='29'><img src='../../images/en/spacer.gif' width=10 height=10 border=0 alt=''></td>"
			+ "</tr>"
			+ "</table>"
		);
	}
}
