var divMenu;

window.attachEvent("onload", InitMenu);

function InitMenu()
{
	divMenu = document.getElementById("divMenu");
	mnpMenuAttach(divMenu);
}

function mnpMenuAttach(el)
{
	var divs = el.getElementsByTagName("DIV");
	for (var i=0; i < divs.length; i++)
	{
		var div = divs.item(i);
		if (div.className == "divMenuRow")
		{
			div.attachEvent("onmouseenter", mnpMenuMouseover);
			div.attachEvent("onmouseleave", mnpMenuMouseout);
			div.attachEvent("onmousedown", mnpMenuMousedown);
			div.attachEvent("onmouseup", mnpMenuMouseup);
			div.setAttribute("save-background", div.style.background);
			div.setAttribute("save-border", div.style.borderColor);
			var a = div.getElementsByTagName("A");
			if (a.length > 0)
			{
				var a0 = a[0];
				if (a0.getAttribute("aoff"))
					a0.outerHTML = a0.innerHTML;
				else
				{
					div.setAttribute("status", a0.href);
					div.attachEvent("onclick", mnpMenuClick);
				}
			}
		}
	}
}

function mnpMenuClick()
{
	var div = window.event.srcElement;
	var a = div.getElementsByTagName("A");
	if (a.length == 0) return;
	if (window.event.shiftKey)
	{
		var target = a[0].target;
		a[0].target = "_new";
		a[0].click();
		a[0].target = target;
	}
	else
		a[0].click();
}

function mnpMenuMouseover()
{
	var div = window.event.srcElement;
	div.style.background = "#C0C0C0";
//	div.style.borderColor = "#A0A0A0";
	div.style.borderColor = "red";
}

function mnpMenuMouseout()
{
	var div = window.event.srcElement;
	div.style.background = div.getAttribute("save-background");
	div.style.borderColor = div.getAttribute("save-border");
}

function mnpMenuMousedown()
{
	var div = window.event.srcElement;
	if (div.tagName != "DIV") div = div.parentElement;
	div.style.background = "#999999";
}

function mnpMenuMouseup()
{
	var div = window.event.srcElement;
	if (div.tagName != "DIV") div = div.parentElement;
	div.style.background = div.getAttribute("save-background");
}
