/************************************************************************** Copyright (c) 2001-2003 Geir Landrö (drop@destroydrop.com) JavaScript Tree - www.destroydrop.com/hjavascripts/tree/ Version 0.96 This script can be used freely as long as all copyright messages are intact. **************************************************************************/ // Arrays for nodes and icons var nodes = new Array();; var openNodes = new Array(); var icons = new Array(6); // Loads all icons that are used in the tree function preloadIcons() { icons[0] = new Image(); icons[0].src = "images/tree/plus.gif"; icons[1] = new Image(); icons[1].src = "images/tree/plusbottom.gif"; icons[2] = new Image(); icons[2].src = "images/tree/minus.gif"; icons[3] = new Image(); icons[3].src = "images/tree/minusbottom.gif"; icons[4] = new Image(); icons[4].src = "images/tree/folder.gif"; icons[5] = new Image(); icons[5].src = "images/tree/folderopen.gif"; } // Create the tree function createTree(arrName, startNode, openNode) { nodes = arrName; if (nodes.length > 0) { preloadIcons(); if (startNode == null) startNode = 0; if (openNode != 0 || openNode != null) setOpenNodes(openNode); if (startNode !=0) { var nodeValues = nodes[getArrayId(startNode)].split("|"); document.write("\"\"" + nodeValues[2] + "
"); } else document.write("
"); var recursedNodes = new Array(); addNode(startNode, recursedNodes); } } // Returns the position of a node in the array function getArrayId(node) { for (i=0; i"); else document.write("\"\""); } // put in array line & empty icons if (ls) recursedNodes.push(0); else recursedNodes.push(1); // Write out join icons if (hcn) { if (ls) { document.write("\"Open/Close"); } else { document.write("\"Open/Close"); } } else { if (ls) document.write("\"\""); else document.write("\"\""); } // Start link document.write(""); // Write out folder & page icons if (hcn) { document.write("\"Folder\""); } else document.write("\"Page\""); // Write out node name document.write(nodeValues[2]); // End link document.write("
"); // If node has children write out divs and go deeper if (hcn) { document.write("
"); addNode(nodeValues[0], recursedNodes); document.write("
"); } // remove last line or empty icon recursedNodes.pop(); } } } // Opens or closes a node function oc(node, bottom) { var theDiv = document.getElementById("div" + node); var theJoin = document.getElementById("join" + node); var theIcon = document.getElementById("icon" + node); if (theDiv.style.display == 'none') { if (bottom==1) theJoin.src = icons[3].src; else theJoin.src = icons[2].src; theIcon.src = icons[5].src; theDiv.style.display = ''; } else { if (bottom==1) theJoin.src = icons[1].src; else theJoin.src = icons[0].src; theIcon.src = icons[4].src; theDiv.style.display = 'none'; } } // Push and pop not implemented in IE if(!Array.prototype.push) { function array_push() { for(var i=0;i