// ---------------------------------------------------- //
// Preload Images										//
// ---------------------------------------------------- //

var img1 = new Image();
var img2 = new Image();
var img3 = new Image();
var img4 = new Image();
var img5 = new Image();
var img6 = new Image();
var img7 = new Image();
var img8 = new Image();
var img9 = new Image();
var img10 = new Image();
var img11 = new Image();
var img12 = new Image();

img1.src = "images/nav_branches_off.gif";
img2.src = "images/nav_business_off.gif";
img3.src = "images/nav_commitment_off.gif";
img4.src = "images/nav_employment_off.gif";
img5.src = "images/nav_housing_off.gif";
img6.src = "images/nav_scholar_off.gif";
img7.src = "images/nav_branches_on.gif";
img8.src = "images/nav_business_on.gif";
img9.src = "images/nav_commitment_on.gif";
img10.src = "images/nav_employment_on.gif";
img11.src = "images/nav_housing_on.gif";
img12.src = "images/nav_scholar_on.gif";


// ---------------------------------------------------- //
// Create English Menu									//
// ---------------------------------------------------- //

function generateTopMenu(activeItem) 
{
	document.write('<ul id="topMenu">');
	document.write('	<li><a href="commitment.html" title="Our Commitment"><img src="images/nav_commitment_off.gif" id="menu1" ></a></li>');
	document.write('	<li><a href="branches.html" title="Aboriginal Branches"><img src="images/nav_branches_off.gif" id="menu2" ></a></li>');
	document.write('	<li><a href="loan.html" title="On-Reserve Housing Loan Programs"><img src="images/nav_housing_off.gif" id="menu3" ></a></li>');
	document.write('	<li><a href="business.html" title="Business Banking"><img src="images/nav_business_off.gif" id="menu4" ></a></li>');
	document.write('	<li><a href="employment.html" title="Employment Opportunities"><img src="images/nav_employment_off.gif" id="menu5" ></a></li>');
	document.write('	<li class="last"><a href="scholar.html" title="Scholarships and Bursaries for Aboriginal Youth"><img src="images/nav_scholar_off.gif" id="menu6" ></a></li>');
	document.write('</ul>');
	
	// Mouse Event Handlers
	for (x=1; x<=6; x++) {
		if (x != activeItem) { // remove roll over effect on currently selected menu item
			document.getElementById("menu"+x).onmouseover = setOnState;
			document.getElementById("menu"+x).onmouseout = setOffState;
		}
	}
	
	// Set Active Menu Item
	if (activeItem != null) {
		activeMenuObj = document.getElementById("menu"+activeItem);
		activeMenuObj.src = activeMenuObj.src.replace(/_off/, "_on");		
	}
	
	
}


// ---------------------------------------------------- //
// Create Top Header Links								//
// ---------------------------------------------------- //

function generateHeaderLinks() 
{
	document.write('<ul id="topLinks">');
	document.write('	<li><a href="javascript:;" onclick="window.open(\'http://findit.bmo.com/search?q=&filter=0&entqr=0&output=xml_no_dtd&sort=date%3AD%3AL%3Ad1&entsp=0&lr=lang_en&client=bmo_en&filter=0&ud=1&oe=UTF-8&ie=UTF-8&proxystylesheet=bmo_en&site=bmo_en&btnG.x=29&btnG.y=14\', \'searchWindow\', \'scrollbars=1,resizable=1,width=790,height=590,left=125,top=-25\');">search</a>&nbsp;|&nbsp;</li>');
	document.write('	<li><a href="branches.html">contact us</a>&nbsp;|&nbsp;</li>');
	document.write('	<li><a href="http://www.bmo.com">bmo.com</a>&nbsp;|&nbsp;</li>');
	document.write('	<li class="last"><a href="../fr/">fran&ccedil;ais</a></li>');
	document.write('</ul>');
}


// ---------------------------------------------------- //
// Create English Footer								//
// ---------------------------------------------------- //

function generateFooter() 
{
	document.write('<div class="clear"></div>');
	document.write('<div id="footer">');
	document.write('  <ul id="footerLinks">');
	document.write('	  <li><a href="javascript:;" onclick="window.open(\'http://www4.bmo.com/popup/0,4442,35649_49258,00.html?pChannelId=74876\', \'popup\', \'scrollbars=1,resizable=1,width=700,height=550,left=125,top=-25,\');">privacy</a>&nbsp;|&nbsp;</li>');
	document.write('	  <li><a href="javascript:;" onclick="window.open(\'http://www4.bmo.com/popup/0,4442,35649_51991,00.html?pChannelId=74876\', \'popup\', \'scrollbars=1,resizable=1,width=700,height=550,left=125,top=-25,\');">legal</a>&nbsp;|&nbsp;</li>');
	document.write('	  <li><a href="javascript:;" onclick="window.open(\'http://www4.bmo.com/popup/0,4442,35649_49250,00.html?pChannelId=74876\', \'popup\', \'scrollbars=1,resizable=1,width=700,height=550,left=125,top=-25,\');">security</a></li>');
	document.write('  </ul>');
	document.write('</div>');
	
	// Tracking
	var v = {};
	function mapFilePath()
	{
		if (document.location.href.indexOf('https') == 0) {
			document.write("<script language='javascript' type='text/javascript' src='https://csvtr.bmo.com/bmo/zig.js'><\/script>");
		}
		else{
			document.write("<script language='javascript' type='text/javascript' src='http://csvtr.bmo.com/bmo/zig.js'><\/script>");
		}
	}
	mapFilePath();	
}
	



// ---------------------------------------------------- //
// Toggle menu image to on state						//
// ---------------------------------------------------- //

function setOnState() {
	if (this.src.search("_off") != 1) {
		this.src = this.src.replace(/_off/, "_on");
	}
}

// ---------------------------------------------------- //
// Toggle menu image to off state						//
// ---------------------------------------------------- //

function setOffState() {
	if (this.src.search("_on") != 1) {
		this.src = this.src.replace(/_on/, "_off");
	}
}


// ---------------------------------------------------- //
// Adjust height left of column to match right col		//
// ---------------------------------------------------- //

function setRightColHeight() {

	var leftColHeight = document.getElementById("leftCol").clientHeight;
	var rightColHeight = document.getElementById("rightCol").clientHeight;
	
	// Check if left col is longer than right and adjust size to match
	if (leftColHeight > rightColHeight) {
		document.getElementById("rightCol").style.height = leftColHeight + "px";
		
	}


}


function setDivHeight(targetDiv, copyDiv) {

	var targetDivHeight = document.getElementById(targetDiv).clientHeight;
	var copyDivHeight = document.getElementById(copyDiv).clientHeight;
	
	// Check if left col is longer than right and adjust size to match
	if (copyDivHeight > targetDivHeight) {
		document.getElementById(targetDiv).style.height = copyDivHeight + "px";
		
	}


}