var _active = null;
var _current = null;
var _nodes = []; 

var _timer = null;
var _timeout = 50;

function initMenu()
{
	var _menu = document.getElementById("menu");
	if (_menu) {
	nodes = document.getElementById("menu").getElementsByTagName("li");
	for (var i=0; i<nodes.length; i++)
	{
		if (nodes[i].className.indexOf("active") != -1)
		{
			_active = nodes[i];
		}
		nodes[i].onmouseover = function()
		{
			clearTimeout(_timer);
			_show = this;
			_timer = setTimeout('showItem()',_timeout);
		}
	}
		_menu.onmouseout = function() {
			clearTimeout(_timer);
			_timer = setTimeout('showActive()',_timeout);
		};
	}
}

function showItem() {
	if (_show)
	{
		_node = _show;
	}
	if (_node)
	{
		for (i = 0; i < nodes.length; i++)
		{
			nodes[i].className = nodes[i].className.replace("active", "");
		}
		if (_node.className.indexOf("active") == -1)
		{
			_node.className += " active";
		}
	}
}

function showActive() {
	var _node = null;
	if (_active)
	{
		_node = _active;
	}
	if (_node)
	{
		for (i = 0; i < nodes.length; i++)
		{
			nodes[i].className = nodes[i].className.replace("active", "");
		}
		if (_node.className.indexOf("active") == -1)
		{
			_node.className += " active";
		}
	}
}


if (window.addEventListener) {
	//window.addEventListener("load", initAccordion, false);
	window.addEventListener("load", initMenu, false);
}
else if (window.attachEvent) {
	//window.attachEvent("onload", initAccordion);
	window.attachEvent("onload", initMenu)
}

