/*HANDLE ALL STYLESHEETS*/
var opsys = navigator.platform;
var browser = navigator.appName;
var version = navigator.appVersion;

if (browser != "Netscape") { 
	writeStyles();
	if (opsys.indexOf('Mac') != -1) {
		if (browser.indexOf('Microsoft') != -1) {
			writeIEFix();
		}
	}
} else { 
	if (version >= "5.0") {
		writeStyles();
	}
}

function writeStyles() {
	var s = "";
	s += '<link rel="stylesheet" href="includes/shared.css" /> \n'
	s += '<link rel="stylesheet" title="Standard Text" href="includes/standard_text.css" /> \n'
	s += '<link rel="alternate stylesheet" title="Larger Text" href="includes/large_text.css" /> \n'
//	alert(s);
	document.write(s);
}

function writeIEFix() {
//	alert("writeIEFix");
	var s = "";
	s += '<link rel="stylesheet" href="includes/ie_mac_fix.css" />';
	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;
}

//	open an MD&A page
function openMDA (whatPage) {
	var MDApage = (whatPage != undefined) ? whatPage : "mda_index.html";
//	var URL = "downloads/bmo_ar05_mda.pdf"; 
	var URL = "mda/index.html?page=" + MDApage; 
	var name = "mda";
	var arSizes = autoSize();
	var height = arSizes[0];
	var width = arSizes[1];
	var yPos = (screen.availHeight/2) - (height/2) - 70;
	var xPos = (screen.availWidth/2) - (width/2);
	var attributes='menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,width='+width+',height='+height+',top='+yPos+',left='+xPos+',screenY='+yPos+',screenX='+xPos;
	newWin(URL,name,attributes);
}

//var arNotesPages = new Array(0,1,2,2,5,7,7,8,10,11,16,17,18,18,19,19,19,20,21,21,23,24,26,29,30,31,33,33,34,35);

//	open a specific note
function openNotes (id, anch) {
	var whatNote = (id != undefined) ? id : 1;
//	var pdfPage = arNotesPages[whatNote];
//	var URL = "downloads/bmo_ar05_cfs_notes.pdf"
	var whatAnch = (anch) ? "&anchor=" + anch : "";
	var URL = "notes/index.html?note=" + whatNote + whatAnch;
	var name = "notes";
	var arSizes = autoSize();
	var height = arSizes[0];
	var width = arSizes[1];
	var yPos = (screen.availHeight/2) - (height/2) - 50;
	var xPos = (screen.availWidth/2) - (width/2);
	var attributes='menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes,width='+width+',height='+height+',top='+yPos+',left='+xPos+',screenY='+yPos+',screenX='+xPos;
	newWin(URL,name,attributes);
}

function openSurvey() {
	var URL = '/arsurvey2005/surveyForm';
	var name = 'survey';
	var attributes = 'menubar=no,toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=700,height=350';	
	newWin(URL,name,attributes);
}

function openInParent(whatPage) {
	window.parent.opener.location=whatPage;
	window.parent.opener.focus();
//	window.parent.close();
}