function InitTree(Id, sId){
    if (!document.getElementById) return;
    
    var ul = document.getElementById(Id);
    if (!ul.childNodes || ul.childNodes.length == 0 || (ul.childNodes.length == 1 && ul.childNodes[0].id == "empty"))
        return;
    else // Put border at bottom of menu
        document.getElementById("sideMenu").className = "sidemenuBackground";
    
    // Expand first menu item if none is opened yet
    var boolMenuOpen = 0;
    for(var i = 0; i < ul.childNodes.length; i++)
    {
        var li = ul.childNodes[i];
        if(li.className.indexOf("current") != -1)
        {
            boolMenuOpen = 1;
            break;
        }
        if (li.childNodes != null && li.childNodes.length >= 1) {
            var subul = li.childNodes[1];
            if (subul != null && subul.className == "open")
            {
                boolMenuOpen = 1;
                break;
            }
        }
    }
    if(boolMenuOpen == 0 && ul.childNodes.length > 0)
        if(ul.childNodes[0].childNodes.length >= 2)
            ul.childNodes[0].childNodes[1].className = "open";
    
    // Expand opened menu items
    var node = document.getElementById(sId)
    if(node != null)
    {
        if (node.childNodes != null || node.childNodes.length >= 1){
            var subul = node.childNodes[1];
            if (subul != null) subul.className = "open";
        }
        
        //show parentnodes
        while (node.parentNode && node.parentNode.id != Id){
            if (node.nodeName == 'LI') {
                node.parentNode.className = "open";
            }
        
            node = node.parentNode;
        }
        
       var a = ul.getElementsByTagName('A');
       for(var i=0;i<a.length;i++){
            a[i].onclick = expandNode;
       } 
   }
}

function expandNode(e, node){
    if(!node)node=this;
    
    // show sibling ul
    var ul = node.nextSibling;
    if (ul != null) ul.className = "open";    
}