//PROPERTIES---------------

//-------------------------

//globals------------
var arrTopMenuItem = new Array();
var timer = null;
var TopMenuWidth;
var _IFLAG = false;  //if menu already created
//-------------------

function openTopMenu(left,width,strMenuItems) 
{
	if (!document.all)
	    return;
	
	//already loaded
	/*
	if (_IFLAG) {
    	divTopMenu.style.visibility = "visible";		
		return;	
	}*/
	
	//init
	arrTopMenuItem = new Array();
	arrTopMenuItem = strMenuItems.split(",");
	TopMenuWidth = width;
	disposeTopMenu();
	createTopMenu();
	_IFLAG = true;   
    
    //position menu and open it
    document.getElementById("divTopMenu").style.top = "25px";
    document.getElementById("divTopMenu").style.left = left;
    document.getElementById("divTopMenu").style.visibility = "visible";
}

function closeTopMenu()
{
	if (!_IFLAG || !document.getElementById("divTopMenu")) return;  //menu does not exist yet
	clearTimeout(timer);
	document.getElementById("divTopMenu").style.visibility = "hidden";
}

function createTopMenu()
{
    if (!document.all)
	    return;

    var strHtml;
    var menu = document.createElement("DIV");
    menu.id = "divTopMenu";    
    menu.style.width = TopMenuWidth;
    menu.style.height = "10px";
    menu.style.border = "solid 1px #176FB2";
    menu.style.color = "#000000";
    menu.style.backgroundColor = "#FFFFFF"//"#95BDE8";#CC9949
    menu.style.backgroundImage = "url(images/bgTopMenu.gif)";
    menu.style.position = "absolute";
    menu.style.top = "150px";
    menu.style.left = "0px";
    menu.style.visibility = "hidden";
    
    var rolloverColor = "#CCCCCC"//"#C8E0F6";#CC8900
    //var strMouseEvents = " onmouseover='this.style.backgroundColor=\""+rolloverColor+"\"; this.style.border=\"solid 1px #176FB2\"' onmouseout='this.style.backgroundColor=\"transparent\"; this.style.borderWidth=\"0px\"'";
    var strMouseEvents = " onmouseover='this.style.backgroundColor=\""+rolloverColor+"\"; this.style.border=\"solid 1px #176FB2\"' onmouseout='this.style.backgroundColor=\"gold\"; this.style.borderWidth=\"0px\"'";
    var strRows = "";
    //create table rows based on menu array    
    for (var i=0; i<arrTopMenuItem.length; i=i+2) 
    {
        strRows += "<tr><td align='center'><img src='images/icoCommon.gif'></td>" +
                "<td style='padding-left:4px;cursor:hand;'" + strMouseEvents + " onclick='location.href=\""+arrTopMenuItem[i+1]+"\"'>"+arrTopMenuItem[i]+"</td></tr>"     
    }
        
    strHtml = "<table border='0' cellpadding='0' cellspacing='0' style='line-height:16pt;'>" +
              "<tr><td align='center' style='width:23px;height:1px;font-size:1px;line-height:5px;'>&nbsp;</td>" +
              "<td style='width:120px;padding-left:4px;height:1px;font-size:1px;line-height:5px'>&nbsp;</td></tr>" + strRows + "</table>";
              //strHtml = "<table border='0' cellpadding='0' cellspacing='0' style='line-height:16pt;'>" + strRows + "</table>";
                  
    menu.innerHTML = strHtml;        
    menu.onmouseout = function () { clearTimeout(timer); timer = setTimeout('closeTopMenu()', 1700); }
    document.body.appendChild(menu);    
}

function disposeTopMenu()
{
    var oMenu = document.getElementById("divTopMenu");
    
    if (oMenu) {
        document.body.removeChild(oMenu);
        oMenu = null;
    }    
}
