/* GENERIC COOKIE HANDLING */
function createCookie(name,value,days) {
	//alert (name + ", " + days);
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') { c = c.substring(1,c.length); }
		if (c.indexOf(nameEQ) == 0) { return c.substring(nameEQ.length,c.length); }
	}
	return null;
}

/*HANDLE ALL STYLESHEETS*/
var opsys = navigator.platform;
var browser = navigator.appName;
var version = navigator.appVersion;

if (browser != "Netscape") { 
	writeStyles();
} else { 
	if (version >= "5.0") {
		writeStyles();
	}
}

function writeStyles() {
	var s = "";
	s += '<link rel="stylesheet" href="includes/shared.css" media="screen, print" /> \n'
	s += '<link rel="stylesheet" title="Standard Text" href="includes/standard_text.css" media="screen, print" /> \n'
	s += '<link rel="alternate stylesheet" title="Larger Text" href="includes/large_text.css" media="screen, print" /> \n'
	document.write(s);
}

/*END STYLESHEET SCRIPTS*/

//	open a new window
function newWin(pageToLoad,name,attributes) {
	var	newWindow = window.open(pageToLoad,name,attributes);
	newWindow.focus();
	newWindow.location.reload();
	newWindow.location = pageToLoad;
}

//	automatically size the new window
function autoSize() {
//	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var screenHeight = screen.availHeight;
	var screenWidth = screen.availWidth;
	var arSizes = new Array();
	arSizes[0] = screenHeight - 250;
	arSizes[1] = screenWidth - 100;
	return arSizes;
}

function openInParent(whatPage) {
	window.opener.location=whatPage;
	window.opener.focus();
}

// change the window status message
function showStatus(sMsg) {
    window.status = sMsg ;
    return true ;
}

function openSurvey() {
	var URL = 'http://www2.bmo.com/arsurvey2008/surveyForm';
	var name = 'survey';
	var attributes = 'menubar=no,toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=700,height=420';	
	newWin(URL,name,attributes);
}

function openPAS() {
	// change this function to open the PAS when available
	//newWin('pas.html','PAS','menubar=no,toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=340,height=200');
	var URL = "http://www2.bmo.com/content/0,1089,divId-7_langId-1_navCode-3680,00.html"
	newWin = window.open(URL,'newWin','menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,width=750,height=480');
}

function openProxy() {
	// change this function to open the Proxy when available
	var URL = "http://www2.bmo.com/bmo/files/annual%20reports/3/1/bmo_proxy2008en.pdf"
	newWin = window.open(URL,'newWin','menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,width=750,height=480');
}

function captureFlashEvent(action) {
//	alert (action);
//	alert (window.location);
	captureLinkAlt(window.location,"Annual Report 2008","","action=" + action);
}