﻿function InitTree(Id, sId){
    if (!document.getElementById) return;
    
    var ul = document.getElementById(Id);
    if (!ul.childNodes || ul.childNodes.length == 0) return;
    
    var node = document.getElementById(sId)
    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";    
}
