// Menu 1.0
FW_DOM 					= (document.getElementById) ? true : false;
FW_NS4 					= (document.layers) ? true : false;
FW_IE 					= (document.all) ? true : false;
FW_IE4 					= FW_IE && !FW_DOM;
FW_Mac 					= (navigator.appVersion.indexOf("Mac") != -1);
FW_IE4M 				= FW_IE4 && FW_Mac;

FW_Opera				= (navigator.userAgent.indexOf("Opera")!=-1);
FW_Konqueror 			= (navigator.userAgent.indexOf("Konqueror")!=-1);

FW_IsMenu 				= FW_DOM;

var menuPrefix = "menu_";
var menuOver = false;
var menuCount = 0;
var curItem = -1;

function swOn(elm, fontcolor, backgroundcolor)
{
	elm.style.color = fontcolor;
	elm.style.backgroundColor = backgroundcolor;
	if (FW_IE)
		elm.style.cursor = "hand";
	else
		elm.style.cursor = "pointer";
}

function swOff(elm, fontcolor, backgroundcolor)
{
	elm.style.color = fontcolor;
	elm.style.backgroundColor = backgroundcolor;
	elm.style.cursor = "default";
}

function linkItem(item)
{
	var elm = eval(item);
	var url = elm[1];
	if (url.indexOf("javascript:") > -1)
		eval(url);
    else
		location.href = url;
}

function show(item)
{
	curItem = item;
	hideAll(item);
	setItemVisible(item, true);
}

function hide(item)
{
	curItem = -1;
	setTimeout("hideItem("+item+")", 700);
}

function hideItem(item)
{
	if (menuOver || curItem == item)
	{	return;
	}
	setItemVisible(item, false);
}

function hideAll()
{
	tempitem = arguments[0];
	for (i = 1; i <= menuCount; i++)
	{
		if (i == tempitem)
			continue;
		setItemVisible(i, false);
	}
}

function setItemVisible(item, bOn)
{
	elm = document.getElementById(menuPrefix+item);
	if (elm)
	{
		if (bOn)
		{
			elm.style.visibility = "visible";
			elm.style.display = "block";
		}
		else
		{
			elm.style.visibility = "hidden";
			elm.style.display = "none";
		}
	}
}

function buildIt()
{
	for (i = 0; i < 15; i++)
	{	var sName = "window.FW_Array"+i;
		elm = eval(sName);

		if (elm != null)
		{	var params = elm[0];
			var leftpos = params[0];
			var toppos = params[1];
			var fontcolor = params[2];
			var mouseovercolor = params[3];
			var backgroundcolor = params[4];
			var mouseoverbackgroundcolor = params[5];
			var bordercolor = params[6];
			var separatorcolor = params[7];

			var style = "<style>";
			style += ".menu"+i+"style { font-family: Verdana,Arial,sans-serif; font-size: 11px; font-style: normal; color: "+fontcolor+"; text-decoration: none; width: 100%; position: relative; padding: 3px 0px 3px 0px; }";
			style += "</style>";
			document.writeln(style);

			var str = "<div id='"+menuPrefix+i+"' style='visibility: hidden; display: none; left: "+leftpos+"; top: "+toppos+"; position: absolute; z-index: 100; border: 1px solid "+bordercolor+"; background-color: "+backgroundcolor+"' onmouseover='menuOver = true;' onmouseout='menuOver = false;hide("+i+")'>";
			if (FW_IE)
				str += "<table border='0' cellpadding='0' cellspacing='0'>";
			for (j = 1; j < elm.length; j++)
			{	var menuitem = elm[j];
				var menuname = menuitem[0];
				var menuurl = menuitem[1];
				if (FW_IE)
				{
					str += "<tr>";
					str += "<td nowrap='nowrap'>";
				}
				str += "<div class='menu"+i+"style' onmouseover='swOn(this, \""+mouseovercolor+"\", \""+mouseoverbackgroundcolor+"\")' onmouseout='swOff(this, \""+fontcolor+"\", \""+backgroundcolor+"\");' onclick='linkItem(\""+sName+"["+j+"]\")'>&nbsp;&nbsp;"+menuname+"&nbsp;&nbsp;</div>";
				if (FW_IE)
				{
					str += "</td>";
					str += "</tr>";
				}
			}
			if (FW_IE)
				str += "</table>";
			str += "</div>";

			document.writeln(str);
			menuCount++;
		}
	}
}
