   
    /*
        NodeTree CLASS
    */
    function NodeTree(path, element, label, collapsed){
      this.NAME = "MENU";
      this.items = new Array();
      this.parent=null
      this.elRef = element;
      this.collapsed = false;
      this.label = label;
      this.className = "defaultNodeTree";
      this.container = null;
      this.nodeStateImage = null;
      this.stateIconClosed = "closedNode2.gif";
      this.stateIconOpened = "openedNode2.gif";
      this.itemIconClosed = "closedNodeFolder.gif";
      this.itemIconOpened = "openedNodeFolder.gif";
      this.resourcesPath = path+"Tree/gui/imgs/"; 
      
      //methods
      this.addItem = NodeTree_addItem;
      this.setSelfInstance = NodeTree_setSelf;
      this.toString = NodeTree_toString;
      this.deploy = NodeTree_deploy;
      this.deployItems = NodeTree_deployItems;
      this.click = NodeTree_handleClick;
      this.displayByState = NodeTree_displayByState;
    }
    
    function NodeTree_setSelf(instance){
      this.selfInstance = instance;
    }
    
    function NodeTree_displayByState(){
      if(this.collapsed){
        this.container.style.display = "none";
        this.nodeStateImage.src = this.resourcesPath + this.stateIconClosed;

      }else{
        this.container.style.display = "block";
        this.nodeStateImage.src = this.resourcesPath + this.stateIconOpened;
      }
    }
    
    function NodeTree_handleClick(){
      this.collapsed = (this.collapsed)? false: true;
      this.displayByState();
    }
    
    function NodeTree_addItem(item){
      this.items.push(item);
    }
    
    function NodeTree_toString(){
      var str='NodeTree Items: \n';
      
      for(var i=0; i<this.items.length; i++){
        str += i+": " + this.items[i].toString()+"\n";
      }
      
      return str;
    }
    
    function NodeTree_deployItems(){

      for(var i=0; i<this.items.length; i++){
         this.container.appendChild(this.items[i].deploy());
      }
      
      
    }
    
    function NodeTree_deploy(){
      var item = document.createElement("div");
      this.nodeStateImage = document.createElement("img");
      var caption = document.createElement("h1");
      var txtNode;
      var attr;
      var t1 = new Date();
      
      txtNode = document.createTextNode(this.label);
      this.nodeStateImage.src = 'item.gif';
      caption.appendChild(this.nodeStateImage);
      caption.appendChild(txtNode);
      this.container = document.createElement("div"); 
      item.className = this.className;

      item.appendChild(caption);
      item.appendChild(this.container);
      
      this.nodeStateImage.self = this.selfInstance;
          
      if(document.all){
        this.nodeStateImage.attachEvent("onclick", nodeTreeClick);
      }else{
        this.nodeStateImage.addEventListener("click", nodeTreeClick, false);

      } 
      
      this.deployItems();
      this.displayByState();

      this.elRef.appendChild(item);
      this.elRef.childNodes[0].style.display = "none";
      
      //alert(new Date() - t1);
      
    }
    
    
    /*
        Node CLASS
    */
    function Node(path, parent, image, href, label, collapsed){
      this.selfInstance = null;
      this.NAME = "FOLDER";
      this.items = new Array();
      this.parent = null;
      this.href = href;
      this.collapsed = false;
      this.label = label;
      this.className = "defaultNode";
      this.container = null;
      this.nodeStateImage = null;
      this.nodeIconImage = null;
      this.stateIconClosed = "closedNode2.gif";
      this.stateIconOpened = "openedNode2.gif";
      this.itemIconClosed = "closedNodeFolder.gif";
      this.itemIconOpened = "openedNodeFolder.gif";
      this.resourcesPath = path+"Tree/gui/imgs/";       
      //methods
      this.addItem = Node_addItem;
      this.setSelfInstance = Node_setSelf;
      this.toString = Node_toString;
      this.deploy = Node_deploy;
      this.deployItems = Node_deployItems;
      this.click = Node_handleClick;
      this.displayByState = Node_displayByState;
    }
    
    function Node_setSelf(instance){
      this.selfInstance = instance;
    }
   
    function Node_addItem(item){
      this.items.push(item);
    }
    
    function Node_toString(){
      var str='';
      str+='\nLabel: '+this.label;
      str+='\nFolder Items: ';
      str+='\n--------------------\n';
      
      for(var i=0; i<this.items.length; i++){
         str += i+": " + this.items[i].toString()+"\n";
      }
      
      str+='\n--------------------\n';
      
      alert(str);
      
      return  str;
    }
    
    function Node_deployItems(){
      for(var i=0; i<this.items.length; i++){
         this.container.appendChild(this.items[i].deploy());
      }
    }
    
    function Node_displayByState(){
      if(this.collapsed){ 
        this.container.style.display = "none";
        this.nodeStateImage.src = this.resourcesPath + this.stateIconClosed;
        this.nodeIconImage.src = this.resourcesPath + this.itemIconClosed;
      }else{
        this.container.style.display = "block";
        this.nodeStateImage.src = this.resourcesPath + this.stateIconOpened;
        this.nodeIconImage.src = this.resourcesPath + this.itemIconOpened;
      }
    }
    
    function Node_handleClick(){
      this.collapsed = (this.collapsed)? false: true;
      this.displayByState();
    }
    
    function Node_deploy(){
      var item = document.createElement("div");
      var a = document.createElement("a");
      
      this.container = document.createElement("div");
      this.nodeIconImage = document.createElement("img");
      this.nodeStateImage = document.createElement("img");
      
      a.href = this.href;
      a.appendChild(document.createTextNode(this.label));
      this.nodeIconImage.align = 'absmiddle';
      this.nodeStateImage.align = 'absmiddle';

      this.nodeStateImage.self = this.selfInstance;
      this.nodeIconImage.self = this.selfInstance;
          
      if(document.all){
        this.nodeStateImage.attachEvent("onclick", nodeClick);
        this.nodeIconImage.attachEvent("onclick", nodeClick);
      }else{
        this.nodeStateImage.addEventListener("click", nodeClick, false);
        this.nodeIconImage.addEventListener("click", nodeClick, false);
      }  
      
                  
      item.className = this.className;
      item.appendChild(this.nodeStateImage);
      item.appendChild(this.nodeIconImage);
      item.appendChild(a);
      item.appendChild(this.container);
      //item.onClick = nodeClick;
      
      //this.displayByState();
      
      this.deployItems();
      this.displayByState();
      
      return item;
    }
    
    
    /*
        item CLASS
    */
    function NodeItem(path, id, parent, image, href, label){
      this.NAME = "ITEM";
      this.id = id;
      this.parent = parent;
      this.image = image;
      this.href = href;
      this.label = label;
      this.itemIcon = 'folder2.gif';
      this.className = "defaultNodeItem";
      this.resourcesPath = path+"Tree/gui/imgs/";
      
      //methods
      this.toString = NodeItem_toString;
      this.deploy = NodeItem_deploy;
    }
  
    function NodeItem_toString(){
      return   "\n" + this.label+"|"+this.href+"|"+this.NAME;
    }
    
    function NodeItem_deploy(){
      var item = document.createElement("div");
      var image = document.createElement("img");
      var a = document.createElement("a");
      var txtNode;
       
      txtNode = document.createTextNode(this.label);
      a.href = this.href;
      a.appendChild(txtNode);
      image.src = this.resourcesPath + this.itemIcon;
      image.align = 'absmiddle';
      item.className = this.className;
      item.appendChild(image);
      item.appendChild(a);
      
      return item;
    }
    
    
    /*
    * EVENTS
    */
  
    function nodeClick(e){
      if(!e){
        e = window.event;
      }
      
      var srcEl = (document.all)? e.srcElement: e.target;      
      srcEl.self.click();     
    }
    
    function nodeTreeClick(e){
      if(!e){
        e = window.event;
      }
      
      var srcEl = (document.all)? e.srcElement: e.target;      
      srcEl.self.click();     
    }
      
    
    
