
function menuToggle() {

	var node = this.nextSibling;
						
	while (1) {
		if (node != null) {
			if (node.tagName == "UL") {
				node.style.display = (node.style.display == "none") ? "block" : "none";
				this.style.backgroundImage = (node.style.display == "none") ?
					"url(/_structure/images/closedmenu.gif)" : "url(/_structure/images/openmenu.gif)";
//				alert (node.id);
				setCookie (node.id, (node.style.display == "none") ? "closed" : "open", true);
				return false;
			}
			node = node.nextSibling;
		} else {
			return false;
		}
	}
	
	return false;
}

function initMenus() {
	if (!document.getElementsByTagName) return;
	
	var aMenus = document.getElementsByTagName("li");
	for (var i = 0; i < aMenus.length; i++) {
		var mclass = aMenus[i].className;
		if (mclass.indexOf("treenode") > -1) {
			var submenu = aMenus[i].childNodes;
			for (var j = 0; j < submenu.length; j++) {
				if (submenu[j].tagName == "A") {
					submenu[j].onclick = menuToggle;
					if (mclass.indexOf("open") > -1) submenu[j].style.backgroundImage = "url(/_structure/images/openmenu.gif)";
				}
				
				if (submenu[j].tagName == "UL")
					submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
			}
		}
	}
}

function setCookie(name, value, bolSession) {
	var expdate = new Date();
	expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
	
	var strCookie = name + "=" + value + "; "
	if (bolSession == false)
		strCookie += "expires=" + expdate.toGMTString();
	document.cookie = strCookie;
}

function getCookie(name) {
	var strCookies = String(document.cookie);	
	var intCookieStart = strCookies.indexOf(name);
	if(intCookieStart != -1) {
		intCookieStart = intCookieStart + name.length + 1;
		var intCookieEnd = strCookies.indexOf(";", intCookieStart);
		if(intCookieEnd = -1) intCookieEnd = strCookies.length
			return strCookies.substring(intCookieStart, intCookieEnd);
	} else {
		return false;
	}
}

function printarticle(lngId)
{
	strWin = window.open ("/printarticle.php?id=" + lngId , "_blank", "toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,width=800,height=500");
}
