/*	this routine is called on all page loads. The first thing it does is to	determine if cookies are working and if JavaScript is enabled(!)	If "JS_Enable" cookie is unset, cookies aren't enabled, but the menu	has been sent fully expanded. just return.	If "JS_Enable" cookie contains "Test", cookies are enabled, but the menu	has been sent fully expanded. Set the cookie to "OK" to signal the server	that cookies and JavaScript are working, and collapse the menu.*/var openImg = new Image();openImg.src = "/icons/open.gif";	/* icon for open folder */var closedImg = new Image();closedImg.src = "/icons/closed.gif";	/* icon for closed folder */function checkCookies(){	var js_cookie;		/* multi-function cookie. test cookie and JS for server */	js_cookie = getCookie('JS_Enable');	/* see if the server set the cookie *///	alert("check cookies: JS_cookie = " + js_cookie);	if (js_cookie === null) return;		/* no cookies. don't bother with setup */	if (js_cookie == "Test") {			/* first cookie. All menu items are expanded */		setCookie('JS_Enable', "OK", 0, '/'); //, ".cdamp.ca");	/* set the cookie to show JS working */	}}/*	the following appropriated from "Crispy Javascript Cookies" at:	http://www.webreference.com/js/column8/   name - name of the cookie   value - value of the cookie   [expires] - expiration date of the cookie     (defaults to end of current session)   [path] - path for which the cookie is valid     (defaults to path of calling document)   [domain] - domain for which the cookie is valid     (defaults to domain of calling document)   [secure] - Boolean value indicating if the cookie transmission requires     a secure transmission   * an argument defaults when it is assigned null as a placeholder   * a null placeholder is not required for trailing omitted arguments*/function setCookie(name, value, expires, path, domain, secure){  var curCookie = name + "=" + escape(value) +      ((expires) ? "; expires=" + expires.toGMTString() : "") +      ((path) ? "; path=" + path : "") +      ((domain) ? "; domain=" + domain : "") +      ((secure) ? "; secure" : "");  document.cookie = curCookie;}/*  name - name of the desired cookie  return string containing value of specified cookie or null  if cookie does not exist*/function getCookie(name) {  var dc = document.cookie;  var prefix = name + "=";  var begin = dc.indexOf("; " + prefix);  if (begin == -1) {    begin = dc.indexOf(prefix);    if (begin != 0) return null;  } else    begin += 2;  var end = document.cookie.indexOf(";", begin);  if (end == -1)    end = dc.length;  return unescape(dc.substring(begin + prefix.length, end));}/*   name - name of the cookie   [path] - path of the cookie (must be same as path used to create cookie)   [domain] - domain of the cookie (must be same as domain used to     create cookie)   path and domain default if assigned null or omitted if no explicit     argument proceeds*/function deleteCookie(name, path, domain){  if (getCookie(name)) {    document.cookie = name + "=" +    ((path) ? "; path=" + path : "") +    ((domain) ? "; domain=" + domain : "") +    "; expires=Thu, 01-Jan-70 00:00:01 GMT";  }}/*	this routine is called on all page loads. The first thing it does is to	determine if cookies are working and if JavaScript is enabled(!)	If "JS_Enable" cookie is unset, cookies aren't enabled, but the menu	has been sent fully expanded. just return.	If "JS_Enable" cookie contains "Test", cookies are enabled, but the menu	has been sent fully expanded. Set the cookie to "OK" to signal the server	that cookies and JavaScript are working, and collapse the menu. The "tag"	cookie contains the flags for the various menu folders.	reset the menu. If how is 0, cookie is cleared and basic menu set up.	if how is 1, the cookie is used to open the requisite sub-folders	The first folder is always opened.*/function resetMenu(how){	var tag_cookie;	var nchars, y;	var objBranch, menu, page;	var js_cookie;		/* multi-function cookie. test cookie and JS for server */	var tag_chars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";//	alert("resetMenu: how = " + how);	js_cookie = getCookie('JS_Enable');	/* see if the server set the cookie */	if (js_cookie === null) return;		/* no cookies. don't bother with setup *///	alert("resetMenu: JS_cookie = " + js_cookie);	menu = document.getElementById("qnmenuitems");	menu.style.display = "none";	/* turn off the whole menu while fiddling */	if (js_cookie == "Test") {			/* first cookie. All menu items are expanded */		setCookie('JS_Enable', "OK", 0, '/'); //, ".hazards.ca");	/* set the cookie to show JS working */		for (i=0; i<tag_chars.length; i++) {	/* for all the items including the first: */			br = "branch" + tag_chars.charAt(i);//	alert("checking branch" + br);			objBranch = document.getElementById(br);//	if (objBranch) alert("not Null " + br);//	else alert("Null " + br);			if (objBranch) objBranch.style.display = "none";	/* turn them off */		}		tag_cookie = "";	/* initial cookie shows nothing */		setCookie('tag', tag_cookie, 0, '/'); //, ".hazards.ca");	/* save the cookie */	}	showBranch("branch0");	swapFolder("folder0");	if (how == 0) {			/* just do the first branch */		setCookie('tag', "0", 0, '/'); //, ".hazards.ca");	}	else {					/* read up the cookie and setup the tree */		tag_cookie = getCookie('tag');//	alert("tag_cookie a = " + tag_cookie);		if (tag_cookie === null ||			tag_cookie == "" ) tag_cookie = "0";	/* first level *///	alert("tag_cookie b = " + tag_cookie);		nchars = tag_cookie.length;		for (i=0; i<nchars; i++) {	/* for all levels in the tree */			tag = tag_cookie.charAt(i);		/* get the next tag */			if (tag < "0") break;			/* didn't get a character */			if (tag == "0") continue;		/* already did branch0 */			showBranch("branch" + tag);		/* make branch visible */			swapFolder("folder" + tag);		/* open folder */		}	}//	alert("turning Menu back on");	menu.style.display = "block";	/* turn the menu back on */	resize();}function resize(){	var left_height = getComputedHeight("qnleft");	var content_height = getComputedHeight("qncontent")	var menu_height = getComputedHeight("qnmenuitems")	var new_height = content_height;	if (menu_height > new_height) new_height = menu_height;//alert("menu=" + menu_height + ", content=" + content_height + ", new_height=" + new_height);	var page = document.getElementById("qnleft");	page.style.height = new_height + 25 +"px";//	page.style.setProperty('height', 'new_height + 25 +"px"', '')	page = document.getElementById("qncenter");	page.style.height = new_height + 25 + "px";//	page.style.setProperty('height', 'new_height + 25 +"px"', '')}/*	get the computed height of an item*/function getComputedHeight(theElt){var docObj;	docObj = document.getElementById(theElt);//alert("typeof=" + typeof docObj.offsetHeight);	if (docObj && 		typeof docObj.offsetHeight != "undefined") {		tmphght = document.getElementById(theElt).offsetHeight;//alert(theElt + " offsetheight=" + tmphght);	}	else{		var tmphght1 =document.defaultView.getComputedStyle(docObj,"").getPropertyValue("height");		tmphght = tmphght1.split('px');		tmphght = tmphght[0];//alert(theElt + " getpropertyvalue(height)=" + tmphght);	}	return tmphght;}/*	functions for controlling the tree control.	appropriated from	"http://gethelp.devx.com/techtips/dhtml_pro/10min/10Min0702/td072602-2.asp"	and modified to preserve state in cookie*/function showBranch(branch){	var tag_cookie = "";	/* initially empty cookie */	var tag, page;	cookie_parts = new Array(2);	tag = branch.substring(6);	/* get the last character of the input ID or Class */	var objBranch = document.getElementById(branch).style;	if(objBranch.display=="block") {		/* if currently visible */		tag_cookie = getCookie('tag');		/* get the current cookie */		if (tag_cookie) {			cookie_parts = tag_cookie.split(tag);	/* split at the ID character (losing it) */			tag_cookie = cookie_parts.join('');		/* recombine without the ID character */		}		objBranch.display="none";			/* turn off display of the item */// alert(branch + " = off");	}	else {									/* curently invisible */		tag_cookie = getCookie('tag');		/* get current cookie */		if (tag_cookie) {					/* already a cookie */			cookie_parts = tag_cookie.split(tag);	/* split at id (in case it's already in there) */			tag_cookie = cookie_parts.join('') + tag;	/* then add it on to the end */		}		else tag_cookie = tag;		/* no cookie. start one */		objBranch.display="block";	/* show this branch */// alert(branch + " = on");	}	setCookie('tag', tag_cookie, 0, '/'); //, ".hazards.ca");	/* save the cookie */	resize();}function forceshowBranch(branch){	var tag_cookie = "";	/* initially empty cookie */	var tag;	cookie_parts = new Array(2);// alert(branch + " = forced on");	tag = branch.substring(6);	/* get the last character of the input ID or Class */	var objBranch = document.getElementById(branch).style;	if(objBranch.display=="block") {		/* if currently visible */	}	else {									/* curently invisible */		tag_cookie = getCookie('tag');		/* get current cookie */		if (tag_cookie) {					/* already a cookie */			cookie_parts = tag_cookie.split(tag);	/* split at id (in case it's already in there) */			tag_cookie = cookie_parts.join('') + tag;	/* then add it on to the end */		}		else tag_cookie = tag;		/* no cookie. start one */		objBranch.display="block";	/* show this branch */	}	setCookie('tag', tag_cookie, 0, '/'); //, ".hazards.ca");	/* save the cookie */}function forceBranch(branch){	var tag_cookie = "";	/* initially empty cookie */	var tag, page;	cookie_parts = new Array(2);	tag = branch.substring(6);	/* get the last character of the input ID or Class */// alert(branch + " = forced on");	tag_cookie = getCookie('tag');		/* get current cookie */// alert(branch + " = forcing on, initial cookie:" + tag_cookie);	if (tag_cookie) {					/* already a cookie */		cookie_parts = tag_cookie.split(tag);	/* split at id (in case it's already in there) */		tag_cookie = cookie_parts.join('') + tag;	/* then add it on to the end */	}	else tag_cookie = tag;		/* no cookie. start one */	setCookie('tag', tag_cookie, 0, '/');	/* save the cookie */// alert(branch + " = forced on, cookie set:" + tag_cookie);	resize();}function swapFolder(img){	objImg = document.getElementById(img);	if(objImg.src.indexOf('closed.gif')>-1) {		objImg.src = openImg.src;	}	else {		objImg.src = closedImg.src;	}}function forceshowFolder(img){	objImg = document.getElementById(img);	if(objImg.src.indexOf('closed.gif')>-1) {// alert(img + " = forced open");		objImg.src = openImg.src;	}}