if(!window.Node){
	var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}
function checkNode(node, filter){
	return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}

function getChildren(node, filter){
	var result = new Array();
	var children = node.childNodes;
	for(var i = 0; i < children.length; i++){
		if(checkNode(children[i], filter)) result[result.length] = children[i];
	}
	return result;
}
function getChildrenByElement(node){
	return getChildren(node, "ELEMENT_NODE");
}
function getFirstChild(node, filter){
	var child;
	var children = node.childNodes;
	for(var i = 0; i < children.length; i++){
		child = children[i];
		if(checkNode(child, filter)) return child;
	}
	return null;
}
function getFirstChildByText(node){
	return getFirstChild(node, "TEXT_NODE");
}
function getNextSibling(node, filter){
	for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
		if(checkNode(sibling, filter)) return sibling;
	}
	return null;
}
function getNextSiblingByElement(node){
	return getNextSibling(node, "ELEMENT_NODE");
}

function getAncestors(node,filter){
	var collection = new Array();
	while(node.parentNode){
		node = node.parentNode;
		if(checkNode(node,filter))
			collection[collection.length] = node;
	}
	return collection;
}


// ||||||||||||||||||||||||||||||||||||||||||||||||||
// Menu Functions & Properties

var activeMenu = null;

function showMenu(){
	return true;
}

function initMenu(){
	var menus, menu, text, a, i;
	menus = getChildrenByElement(document.getElementById("menu"));
	var sis = getChildren(document.getElementById("menu"),"li");
	for(var j = 0; j < sis.length; j++){
		var lnk = getFirstChild(sis[j],"a");
//		alert(lnk.href +" ?? "+document.location.href);
		if(lnk.href == document.location.href){
			getNextSiblingByElement(lnk).style.display="block";	
		}
	}
	
	for(i = 0; i < menus.length; i++){
		menu = menus[i];
		text = getFirstChildByText(menu);
 		a = document.createElement("a");
		menu.replaceChild(a, text);
		a.appendChild(text);
		a.href = "#";
		a.onclick = showMenu;
		a.onfocus = function(){this.blur()};
		var sms = getChildren(menu,"ol");
		initSubMenu(sms);
	}
}
function initSubMenu(menus){
//	menus = getChildrenByElement(document.getElementById(mid));
	for(i = 0; i < menus.length; i++){	
		var sis = getChildren(menus[i],"li");
		for(var j = 0; j < sis.length; j++){
			var sms = getChildren(sis[j],"ol");
			initSubMenu(sms);
			var lnk = getFirstChild(sis[j],"a");

			if(lnk.href == document.location.href){
				if(getNextSiblingByElement(lnk))
					getNextSiblingByElement(lnk).style.display="block";	
				parents = getAncestors(lnk,"ol");
				for(var k = 0; k < parents.length; k++){
					parents[k].style.display="block";	
				}
			}
		}
		
	}	
}
// ||||||||||||||||||||||||||||||||||||||||||||||||||
if(document.createElement) window.onload = initMenu;