var MenuSupport = false;
var W = window.screen.width;
var H = window.screen.height;
if(navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.appVersion.substring(0,1) > 3)
	MenuSupport = true;

if(MenuSupport){
	var newLine = String.fromCharCode(10);
	var quotChar = String.fromCharCode(34);
	var HtmlItemStr
	var HtmlStr
	var ToolBarStr;
	var RootStr;
	var RootItemsStr;
	var RootItemsColorStr;
	var doitems = false;
	HtmlStr = "";
	RootItemsStr = "";
	RootItemsColorStr = "";
	
	
	var _5 = (navigator.appVersion.indexOf("MSIE 5") > 0)? 1 : 0;
	var stas = (_5)? "left" : "right";
	var sdvig = (_5)? 766 : 0;
	var sdvig1 = (_5)? -4 : 0;
	
	//create root menu
	RootStr = "<div id=" + quotChar + "emptyMenu" + quotChar + "></div>" + newLine + "<div id=" + quotChar + "root" + quotChar + " onmouseout=" + quotChar + "hideAllMenus()" + quotChar + " class=" + quotChar + "mRoot" + quotChar + " style=" + quotChar + "width:100%; background-Color:#ffffff;" + quotChar + ">" + "<table cellspacing=0 cellpadding=0 border=0 align=right>" + newLine + "<tr bgcolor=" + quotChar + "#666666" + quotChar + " align=" + quotChar + "middle" + quotChar + " valign=" + quotChar + "center" + quotChar + ">" + newLine + " <!--rootmenuitems--> </tr><tr><td colspan=17 height=2></td></tr><tr> <!--rootcoloritems--> </tr></table><img src=\"/images/transparent.gif\" border=0 width=1 height=2></div>" + newLine;

	ToolBarStr = "<div width=" +  quotChar + "100%" + quotChar + "style=" + quotChar + "position:relative;" + quotChar +  ">" + newLine;
}

function addPopUpMenu(menuID, menuColor, posNum, menuText){
if(MenuSupport){
	var leftPos;
	if(doitems){
		HtmlStr = HtmlStr.replace("<!--menuItems-->",HtmlItemStr);
		ToolBarStr = ToolBarStr  + HtmlStr + newLine;
		HtmlStr = "";
	}	
	leftPos = (posNum * -96 + 2) + sdvig;
	if(posNum < 8){
		RootItemsStr += "<td height=" + quotChar + "18" + quotChar + " width=" + quotChar + "94" + quotChar + "><div onmouseover=" + quotChar + "showMenu('" + menuID + "')" + quotChar + " style=" + quotChar + "width:100%; height:100%; padding-top:1;" + quotChar + " class=" + quotChar + "fomenu" + quotChar + ">" + menuText + "</div></td><td bgcolor=white></td>" + newLine;
		RootItemsColorStr += "<td  bgcolor=" + quotChar + menuColor + quotChar + " height=" + quotChar + "4" + quotChar + " width=" + quotChar + "94" + quotChar + "><img height=1 src=" + quotChar + "images/transparent.gif" + quotChar + " width=1></td><td width=2 bgcolor=white></td>" + newLine;
	}
	else{
		RootItemsStr += "<td height=" + quotChar+"18"+quotChar+" width="+quotChar+"94"+quotChar+"><div onmouseover="+quotChar+"showMenu('"+menuID+"')"+quotChar+" style="+quotChar+"width:100%; height:100%; padding-top:1;"+quotChar+" class="+quotChar+"fomenu"+quotChar+">" + menuText + "</div></td>" + newLine
		RootItemsColorStr += "<td  bgcolor="+quotChar+menuColor+quotChar+" height="+quotChar+"4"+quotChar+" width="+quotChar+"94"+quotChar+"><img height=1 src="+quotChar+"images/transparent.gif"+quotChar+" width=1></td>" + newLine;
	}
	
	HtmlStr += "<div style="+quotChar+"display:none; padding-left:0px; z-index:9; left:" + leftPos + "px; padding-bottom:9px; width:94px; padding-top:0px; position:absolute; top:-6px; background-color:#ffffff;"  + quotChar + " onmouseover=" + quotChar + "showMenu('" + menuID + "')" + quotChar + " onmouseout=" + quotChar + "hideAllMenus()" + quotChar + " id=" + quotChar + menuID + quotChar+">" + newLine + "<hr style=" + quotChar + " width:94px; left:0px; color:#ffffff; position:absolute; top:0px" + quotChar + " size=" + quotChar + "2" + quotChar + ">" + newLine + "<hr style=" + quotChar + " width:94px; left:0px; color:" + menuColor + "; position:absolute; top:2px" + quotChar + " size=" + quotChar + "4" + quotChar + ">" + newLine + "<div style=" + quotChar + "position:relative; left:0px; top:6px; width:100%;" + quotChar + "> <!--menuItems--> " + newLine + "</div></div>" + newLine;
	HtmlItemStr = "";
}
doitems = true;
}

function addPopUpMenuItem(menuID, mItemID, menuColor, URLStr, LinkText){
var ItemIDStr = menuID + mItemID;
if(MenuSupport)
	if(menuID != "")
		HtmlItemStr += newLine + "<a onmouseout=" + quotChar + "showOnOut(this);" + quotChar + " onmouseover=" + quotChar + "showOnOver(this,'" + menuColor + "');" + quotChar + " style=" + quotChar + "border-top:#ffffff 1px solid; font-weight:bold; font-size:11px; width:100%; cursor:hand; color:#666666; font-family:Arial, Helvetica, sans-serif; background-Color:#ebebeb; text-align:right; text-decoration:none; padding-right:2px;" + quotChar + " onclick=" + quotChar + "gotoURL('" + ItemIDStr + "','" + URLStr + "');" + quotChar + ">" + LinkText + "</a><br>"
}

function showToolBar(){
if(MenuSupport){
	HtmlStr = HtmlStr.replace("<!--menuItems-->", HtmlItemStr);
	ToolBarStr += HtmlStr + "</div>";
	RootStr = RootStr.replace("<!--rootmenuitems-->",RootItemsStr);
	RootStr = RootStr.replace("<!--rootcoloritems-->",RootItemsColorStr);
	ToolBarStr = RootStr + ToolBarStr + newLine;
	//document.write('<img height="40" src="images/transparent.gif" width=1>');
	document.write('<div style="position:relative;left:'+sdvig1+';top:0;width:100%;"><table width="766" border="0" cellpadding="0" cellspacing="0" align="center"><tr><td width="100%" align="'+stas+'">');
	document.write(ToolBarStr);
	document.write('</td></tr></table></div>');
}
}


var ToolbarMenu;
ToolbarMenu = document.all.item('emptyMenu');
emptyMenu = ToolbarMenu

function showMenu(mID){
obj = document.all.item(mID);
if(obj){
	obj.style.display = "block";
	ToolbarMenu = obj;
	window.event.cancelBubble = true;
}
}

function hideAllMenus(){
if (ToolbarMenu != null && ToolbarMenu != emptyMenu){	
	ToolbarMenu.style.display = "none";
	ToolbarMenu = emptyMenu;
	window.event.cancelBubble = true;
}
}

function showOnOver(el, bColor){
el.style.backgroundColor = bColor;
el.style.color = "#FFFFFF";
}

function showOnOut(el){
el.style.backgroundColor = "#ebebeb";
el.style.color = "#666666";
}
//document.write('<div style="position:absolute;left:'+(W-60)+';top:90; color:#ff0000;"><b>TEST</b></div>');