if (document.createElement) {
// add style rules during document load for backward compatability
	if (!document.all) {
		var ss = document.createElement("STYLE");
		ss.innerHTML = "#navlist UL { display:none; } #navlist UL.alwaysShow { display:block; }";
		var hd = document.getElementsByTagName("HEAD");
		if (hd.length>0) hd[0].appendChild(ss);
	} else {
		if (document.styleSheets.length > 0) {
			document.styleSheets[0].addRule("#navlist UL","display:none");
			document.styleSheets[0].addRule("#navlist UL.alwaysShow","display:block;");
		}
	}
}
function QuickLinksOver(evnt)
{
	var src = document.getElementById("quicklinks");
	src.className = "hover";
}

function QuickLinksOut(evnt)
{
	var src = document.getElementById("quicklinks");
	src.className = "";
}

function createPortal() 
{
//empty stub; define function in document body where needed
}
function startup()
{
    // script dependent on W3C DOM model; do not execute on older browsers
	if (!document.getElementById) return;
	createPortal();
	var nav = document.getElementById("navlist");
	if (!nav) return;
	var ultags = nav.getElementsByTagName("UL");
	for (var n=0; n < ultags.length; n++)  {
		if (ultags[n].className != "alwaysShow") {
			ultags[n].style.display = "none";
		}
	}
	var divtags = nav.getElementsByTagName("DIV");
	for (var n=0; n < divtags.length; n++)  {
		var p = divtags[n].parentNode;
		if (p && p.tagName == "LI") {
			if (p.id.length == 3) {
				divtags[n].innerHTML = '<img src="images/'+window.nav1closed+'" width="20" height="25" alt="" align="right" />' + divtags[n].innerHTML;
			} else {
				divtags[n].innerHTML = '<img src="images/'+window.nav2closed+'" width="11" height="9" alt="" align="left" style="margin-top:2px" />' + divtags[n].innerHTML;
			}
		}
		divtags[n].onmouseover = swapImage;
		divtags[n].onmouseout = swapImage;
		if (window.isHomePage) continue;
		divtags[n].onclick = toggleListDisplay;
	}
	document.onclick = openPage;   // trap all click events and pass to openPage function
	if (window.isHomePage) return; // Home page is not to allow opening menu
	var target = location.search;
	if (target) {
		if (target.substr(1,2) == "cn") {
			var n = target.indexOf("=&");
			if (n > 0) target = target.substr(0,n);
			top.navNode = target.substr(1);
		}
	}
	if (!top.navNode && window.opener) {
	    // make menu function in RedDot
	    if (window.opener.top.navNode) {
			top.navNode = window.opener.top.navNode;
		}
	    else if (window.opener.top.opener) {
			if (window.opener.top.opener.top.navNode) {
				top.navNode = window.opener.top.opener.top.navNode;
			}
		}
	}
	if (top.navNode) {
		openNavToId(top.navNode);
	}
}

function openNavToId(id)
{
	var LI = document.getElementById(id);
	var UL;
	while (LI && LI.tagName == "LI") {
		if (LI.hasChildNodes()) {
			for (var n = 0; n < LI.childNodes.length; n++) {
				if (LI.childNodes[n].tagName == "DIV") {
					var evnt = new Object();
					evnt.currentTarget = LI.childNodes[n];
					swapImage(evnt);
				}
			}
		}
		openNode(LI);
		UL = LI.parentNode; 
		if (!UL || UL.tagName != "UL" || UL.id == "navlist") break;
		LI = UL.parentNode;
	}
}

function openPage(evnt)
{
	var A;
	if (evnt) {
		A = evnt.target;
	} else  if (window.event) {
		A = window.event.srcElement;
	}
	while (A && A.tagName != "A") A = A.parentNode;
	if (A == null) return;
	if (A.tagName == "A") {
		if (A.attributes["onclick"] && A.attributes["onclick"].value.substr(0,2) == "//") {
			top.navNode = "cn" + A.attributes["onclick"].value.substr(2);
		} else if (A.name && A.name.substr(0,2) == "an") {
		    top.navNode = "cn" + A.name.substr(2);
		} else {
		    if (A.hostname != location.hostname || !(A.protocol == "http:" || A.protocol == "file:")) {
			    return;
		    }
		}
		if (!top.navNode) return;
		if (top != window) return;
		if (A.href.indexOf("?") >= 0) {
			A.href = A.href.replace("?", "?"+top.navNode+"=&");
		} else if (A.href.indexOf("#") >= 0) {
			A.href = A.href.replace("#", "?"+top.navNode+"#");
		} else {
			A.href += "?"+top.navNode;
		}
	}
	return;
}

function closeNode(LI)
{
	var ultags = LI.getElementsByTagName("UL");
	for (var n = 0; n < ultags.length; n++) {
		if (ultags[n].className != "alwaysShow") {
			ultags[n].style.display = "none";
		}
	}
	var imgtags = LI.getElementsByTagName("IMG");
	for (var n = 0; n < imgtags.length; n++) {
		temp = imgtags[n].src;
		if (temp.indexOf("open") >= 0) {
			imgtags[n].src = temp.replace("open","closed");
		}
	}
	var divtags = LI.getElementsByTagName("DIV");
	for (var n = 0; n < divtags.length; n++) {
		if (divtags[n].className == "showList") {
			divtags[n].className = "";
			divtags[n].onmouseover = swapImage;
			divtags[n].onmouseout = swapImage;
		}
	}
}

function openNode(LI)
{
	if (LI.hasChildNodes()) {
		for (var n = 0; n < LI.childNodes.length; n++) {
			if (LI.childNodes[n].tagName == "DIV") {
				if (LI.childNodes[n].className == "") {
					LI.childNodes[n].onmouseover = null;
					LI.childNodes[n].onmouseout = null;
					LI.childNodes[n].className = "showList";
				}
			}
			if (LI.childNodes[n].tagName == "UL") {
				if (LI.childNodes[n].className != "alwaysShow") {
					LI.childNodes[n].style.display = "block";
				}
			}
		}
	}
}


// this function will expand or collapse a hierarchical navigation list
// div is a DIV tag within a LI that has a sublist (UL)
function toggleListDisplay(evnt)
{
	var DIV;
	if (evnt) {
		DIV = evnt.currentTarget;
	} else  if (window.event) {
		DIV = this;
	}
	if (!DIV) return;

	// div.parentNode should be a LI
	if (!DIV.parentNode) return;

	// div would have className == showList if already open
	if (DIV.className == "") {
		// expand all UL tags that are children of the LI
		openNode(DIV.parentNode);


		// collapse all UL tags that are children of LI siblings
		if (!DIV.parentNode.parentNode) return;
		children = DIV.parentNode.parentNode.childNodes;
		for (var index = 0; index < children.length; index++) {
			if (children[index].tagName == "LI" && children[index] != DIV.parentNode) {
				closeNode(children[index]);
			}
		}
	} else {
		// collapse all UL tags that are children of the LI
		closeNode(DIV.parentNode);
		// because the cursor is still over the DIV tag toggle IMG open
		var evnt = new Object();
		evnt.currentTarget = DIV;
		swapImage(evnt);
	}

}

function swapImage(evnt)
{
	var DIV = null;
	if (evnt) {
		DIV = evnt.currentTarget;
	} else  if (window.event) {
		DIV = this;
	}
	if (DIV == null) return;
	if (DIV.className == "" && DIV.hasChildNodes()) {
		for (var n = 0; n < DIV.childNodes.length; n++) {
			if (DIV.childNodes[n].tagName == "IMG") {
				temp = DIV.childNodes[n].src;
				if (temp.indexOf("open") >= 0)
					DIV.childNodes[n].src = temp.replace("open","closed");
				else if (temp.indexOf("closed") >= 0)
					DIV.childNodes[n].src = temp.replace("closed","open");
			}
		}
	}
}

function RD_form_submit(anc,query)
{
	var f = document.getElementById("myForm1");
	if (f) {
		var pairs = query.split("&");
		for ( var i=0; i < pairs.length; i++ ) {
			var keyval = pairs[i].split("=");
			if (keyval.length == 2) {
				var elm = document.createElement("INPUT");
				if (elm) {
					elm.type = "hidden";
					elm.name = keyval[0];
					elm.value = keyval[1];
					f.appendChild(elm);
				}
			}
		}
		f.action = anc.href;
		f.submit();
	}
	return false;
}
