// Autorem skryptu jest: SŁAWOMIR KOKŁOWSKI
// www.kurshtml.boo.pl
// Modyfikacje i rozbudowa HELP-KOMP ANDRZEJ PYTLIŃSKI

function tree(id)
  {
    this.id = id;
    this.click = function() //wykonuje funkcje po kliknieciu na link
     {
       for (var i = 0, el_node; i < this.parentNode.childNodes.length; i++)
         {
           el_node = this.parentNode.childNodes.item(i)
           if (el_node.nodeName.toLowerCase() == 'ul')
             {
               if (el_node.style.display == 'none')
                 {
                   this.parentNode.firstChild.firstChild.src="../images/tree/tree_folder_open.gif";
                   el_node.style.display = 'block';

                 }
               else
                 {
                   this.parentNode.firstChild.firstChild.src="../images/tree/tree_folder_closed.gif";
                   el_node.style.display = 'none';
                 }
               return false;
             }
         }
     }

    this.start = function (el)
     {

    for (var i = 0, el_node; i < el.childNodes.length; i++)
    {
      el_node = el.childNodes.item(i);
      if (el_node.nodeName.toLowerCase() == 'a')
      {
        el_node.onclick = this.click;
        for (var j = 0; j < el_node.parentNode.childNodes.length; j++)
        {
          if (el_node.parentNode.childNodes.item(j).nodeName.toLowerCase() == 'ul')
          {
            //el_node.parentNode.style.backgroundImage = 'url("closed.gif")';
            el_node.className = (el_node.className ? el_node.className + ' ' : '') + 'folder';
            break;
          }
          if (el_node.parentNode.childNodes.item(j).nodeName.toLowerCase() == 'li') break;
        }

        if (el_node.href && unescape(el_node.href) == unescape(window.location.href))
        {
          el_node.className = 'active';
          var el_parentNode = el_node;
          do
          {
            el_parentNode = el_parentNode.parentNode;
            if (el_parentNode.nodeName.toLowerCase() == 'ul')
            {
              el_parentNode.style.display = 'block';
              if (document.getElementById(this.id) != el_parentNode)
               {
                  // document.write (el_parentNode.parentNode.firstChild.firstChild.nodeName)
                  el_parentNode.parentNode.firstChild.firstChild.src="../images/tree/tree_folder_open.gif";
               }
              
            }
          }
          while (document.getElementById(this.id) != el_parentNode)
        }
      }
      else if (el_node.nodeName.toLowerCase() == 'ul') el_node.style.display = 'none';
      this.start(el_node);
    }
  }

  if (document.getElementById && document.childNodes)
  {
   // if (document.images)
   // {
   //   new Image().src = 'opened.gif';
   //   new Image().src = 'document.gif';
   // }
    this.start(document.getElementById(this.id));
  }
}


