//expects thisPageID to hold the id of the menu entry corresponding to this page

<!--Open News
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->End News


function setupMenu(menuRoot){
	var index;
	var nodes = menuRoot.childNodes;
	if(thisPageID != undefined){
		var target = document.getElementById(thisPageID);
		
		for(index=0; index < nodes.length; index++){
			var node = nodes[index];
			if(node.nodeType == 1){//An element node
				if(node.nodeName == 'LI'){
					setupSubmenu(node, target);
					node.style.visibility = 'visible';
				}
			}
		}
	}
}

function setupSubmenu(root, target){
	var index;
	var nodes = root.childNodes;
	
	if(root == target || hasChildNode(root, target, true)){
		//The node should be selected
		root.className = 'menuentry_selected';
	}else{
		//The node should not be selected
		root.className = 'menuentry_normal';
		if(root.nodeName == 'UL'){
			root.style.visibility = 'hidden';
			root.style.display = 'none';
		}

	}
	
	for(index=0; index < nodes.length; index++){
		var node = nodes[index];
		if(node.nodeType == 1){//An element node
			if(node.nodeName == 'LI' || node.nodeName == 'UL'){
				setupSubmenu(node, target);
			}
		}
	}
}

function hasChildNode(parent, child, deep){
	if(deep == undefined){
		deep = false;
	}
	var index;
	var nodes = parent.childNodes;
	for(index=0; index < nodes.length; index++){
		if(nodes[index] == child){
			return true;
		}
	}
	
	if(deep){
		for(index=0; index < nodes.length; index++){
			if(hasChildNode(nodes[index], child, true)){
				return true;
			}
		}
	}
	
	
	return false;
}


