var MenuHTML = "";
var MenuID = 1;
var LiID = 1;

function MenuClear()
{
    document.getElementById('ContentMenu').innerHTML = "";
}




function MenuHead(Title, display)
{
    MenuID++;
    var divPanel_title = document.createElement("div");
    divPanel_title.className = "divPanel_title";
    document.getElementById("ContentMenu").appendChild(divPanel_title);

    var titleDiv1 = document.createElement("div");
    titleDiv1.className = "titleDiv1";
    titleDiv1.innerHTML = "&nbsp;";
    titleDiv1.style.cursor = "pointer";


    var titleDiv2 = document.createElement("div");
    titleDiv2.className = "titleDiv2";
    titleDiv2.innerHTML = "&nbsp;";
    titleDiv2.style.cursor = "pointer";


    var titleDiv3 = document.createElement("div");
    titleDiv3.className = "titleDiv3";
    titleDiv3.innerHTML = Title;
    titleDiv3.style.cursor = "pointer";



    divPanel_title.appendChild(titleDiv1);
    divPanel_title.appendChild(titleDiv3);
    divPanel_title.appendChild(titleDiv2);


    var divPanel_Content = document.createElement("div");
    divPanel_Content.className = "divPanel_Content";
    document.getElementById("ContentMenu").appendChild(divPanel_Content);
    var MenuItem = document.createElement("ul");
    MenuItem.id = "MenuItem" + MenuID;
    if (display == false)
        MenuItem.style.display = "none";
    else
        MenuItem.style.display = "";

    divPanel_Content.appendChild(MenuItem);

    titleDiv1.onclick = function() { MenuItemHiedAndShow(MenuItem.id); }
    titleDiv2.onclick = function() { MenuItemHiedAndShow(MenuItem.id); }
    titleDiv3.onclick = function() { MenuItemHiedAndShow(MenuItem.id); }

    return MenuItem.id;
}

function itemCommand(id, Command, title, link, canScoll)
{
    var li = document.createElement("li");
    li.id = "li" + LiID;
    li.innerHTML = title;

    li.onclick = function() { return AddTabPage(Command, title, link, canScoll) };
    li.onmouseover = function() { this.className = "over" };
    li.onmouseout = function() { this.className = "out" };

    if (document.getElementById(id) != null)
    {
        document.getElementById(id).appendChild(li);
    }

    LiID++;
}




function MenuItemHiedAndShow(MenuItemId)
{
    if (document.getElementById(MenuItemId).style.display == "")
        document.getElementById(MenuItemId).style.display = "none";
    else
        document.getElementById(MenuItemId).style.display = "";
}

