function initMenu()
{
	var _menu = document.getElementById("menu");
	if (_menu) {
		var nodes = _menu.getElementsByTagName("li");
		_menu.left = getAbsoluteLeft(_menu);
		
		_menu.width = _menu.offsetWidth;
		for (var i=0; i<nodes.length; i++)
		{
			nodes[i].index = i; 
			nodes[i].onmouseover = function()
			{
				if (window.attachEvent)
					this.className += " hover";
					
				this._drop = this.getElementsByTagName('div')[0];
				if (this._drop) {
					this._drop.left = getAbsoluteLeft(this._drop)+145;

				if(this.parentNode.parentNode.className == "level1" && window.attachEvent && getAbsoluteLeft(this.parentNode.parentNode.parentNode)>600)
				{
					this._drop.style.left = -(157)+'px';
				}
				
				if (this._drop.left > _menu.left + _menu.width) {
						this._drop.style.left = -(157)+'px';
					}
				}
			};
			nodes[i].onmouseout = function()
			{
				if (window.attachEvent) this.className = this.className.replace(" hover", "");
			}
		}
	}
}
if (window.addEventListener)
	window.addEventListener("load", initMenu, false);
else if (window.attachEvent)
	window.attachEvent("onload", initMenu);


function getAbsoluteLeft(obj) {
	var posLeft = 0;
	while (obj.offsetParent) {posLeft += obj.offsetLeft; obj = obj.offsetParent;}
	return posLeft;
}
