function initNlMenuRoot() {
	var effects_a = new Array();
	var nlMenuRoot = document.getElementById('nlMenuRoot');
	var lis = nlMenuRoot.getElementsByTagName('li');

	for ( var i = 0; i < lis.length; i++) {
		lis[i].onmouseover = nlMenuOver;
		lis[i].onmouseout = nlMenuSetTimeout;
	}
}

function nlMenuSetTimeout(e) {
	if (!e) {
		var the_e = window.event;
	} else {
		var the_e = e;
	}
	var reltg = (the_e.relatedTarget) ? the_e.relatedTarget : the_e.toElement;
	if (reltg) {
		var under = ancestor(reltg, this);
		if (under === false && reltg != this) {
			window.mlLast = this;

			window.mlTimeout = setTimeout(function() {
				nlMenuOut()
			}, 500);
		}
	}
}

function nlMenuOut() {
	if (window.mlLast == null)
		return false;
	var uls = window.mlLast.getElementsByTagName('ul');
	for ( var i = 0; i < uls.length; i++) {
		mlEffectOut(uls[i]);
		uls[i].parentNode.className = 'nlMenuParent';
	}
	window.lastover = null;
}

function nlMenuOver(e) {
	if (!e) {
		var the_e = window.event;
	} else {
		var the_e = e;
	}
	the_e.cancelBubble = true;
	if (the_e.stopPropagation) {
		the_e.stopPropagation();
	}
	clearTimeout(window.mlTimeout);
	clearTimeout(window.menuRootTimeOut);
	if (window.mlLast && window.mlLast != this
			&& ancestor(this, window.mlLast) == false) {
		nlMenuOut();
	} else {
		window.mlLast = null;
	}
	var reltg = (the_e.relatedTarget) ? the_e.relatedTarget : the_e.fromElement;
	var ob = this.getElementsByTagName('ul');
	var under = ancestor(reltg, this);
	if (ob[0] && under == false) {
		if (window.lastover != ob[0]) {
			this.className = 'nlMenuParent over';
			mlEffectOver(ob[0], this);
			window.lastover = ob[0];
		}
	}
}

function mlEffectOver(ob, parent) {
	ob.style.display = 'block';
	ob.style.visibility = '';
	ob.style.zIndex = 9000;
}

function mlEffectOut(ob) {
	ob.style.display = 'none';
	ob.style.visibility = 'hidden';
}

function ancestor(child, parent) {
	if (child == null)
		return false;

	if (navigator.userAgent.indexOf('Gecko') != -1
			&& navigator.userAgent.indexOf('Opera') == -1) {
		var allc = parent.getElementsByTagName('*');
		for ( var i = 0; i < allc.length; i++) {
			if (allc[i] == child) {
				return true;
			}
		}
	} else {
		for (; child.parentNode; child = child.parentNode) {
			if (child.parentNode === parent)
				return true;
		}
	}
	return false;
}
