
var DIR_IMAGES = "icoontjes/"; // hier het juiste pad naar de afbeeldingen aangeven
var IMG_PLUS = DIR_IMAGES + "plusteken.gif"; // de naam van het plusteken
var IMG_MINUS = DIR_IMAGES + "minteken.gif"; // de naam van het minteken

// hieronder niets meer wijzigen

var imgPlus = new Image();
imgPlus.src = IMG_PLUS;
var imgMinus = new Image();
imgMinus.src = IMG_MINUS;

var objLocalTree = null;
var INDENT_WIDTH = 18;

function UitklapMenu() {
this.root = null;           
this.nodes = new Array;     
objLocalTree = this;}

UitklapMenu.prototype.maakRoot = function(strIcon, strText, strURL, strTarget) {
this.root = new UitklapMenuNode(strIcon, strText, strURL, strTarget);
this.root.id = "root";
this.nodes["root"] = this.root;
this.root.expanded = true;
return this.root;}

UitklapMenu.prototype.buildDOM = function() {
this.root.addToDOM(document.body);}

UitklapMenu.prototype.toggleExpand = function(strNodeID) {
var objNode = this.nodes[strNodeID];
if (objNode.expanded)objNode.collapse();
else (objNode.expand());}

function UitklapMenuNode(strIcon, strText, strURL, strTarget) {
this.icon = strIcon;           
this.text = strText;           
this.url = strURL;              
this.target = strTarget;        
this.indent = 0;                
this.expanded = false;         
this.childNodes = new Array;    }

UitklapMenuNode.prototype.addChild = function (strIcon, strText, strURL, strTarget) {
var objNode = new UitklapMenuNode(strIcon, strText, strURL, strTarget);
objNode.id = this.id + "_" + this.childNodes.length;
objNode.indent = this.indent + 1;
this.childNodes[this.childNodes.length] = objNode;
objLocalTree.nodes[objNode.id] = objNode;
return objNode;}

UitklapMenuNode.prototype.addToDOM = function (objDOMParent) {
var strHTMLLink = "<a href=\"" + this.url + "\"";
if (this.target)strHTMLLink += " target=\"" + this.target + "\"";strHTMLLink += ">";
var objNodeDiv = document.createElement("div");
objDOMParent.appendChild(objNodeDiv);
var d = new MenuVersnellen;
d.writeln("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>");
if (this.indent > 1) {
d.write("<td width=\"");
d.write(this.indent * INDENT_WIDTH);
d.write("\">&nbsp;</td>");}
if (this.indent > 0) {
d.write("<td width=\"18\" align=\"center\">");
if (this.childNodes.length > 0) {
d.write("<a href=\"javascript:objLocalTree.toggleExpand('");
d.write(this.id);
d.write("')\"><img src=\"");
d.write(this.expanded ? imgMinus.src : imgPlus.src);
d.write("\" border=\"0\" hspace=\"1\" id=\"");
d.write("imgPM_" + this.id);
d.write("\" /></a>");}
d.write("</td>");}
d.write("<td width=\"22\">" +strHTMLLink + "<img hspace=\"1\" src=\"" + this.icon + "\" border=\"0\" align=\"absmiddle\" /></a></td>");
d.write("<td nowrap=\"nowrap\">" + strHTMLLink + this.text + "</a></td>");
d.writeln("</tr></table>");
        
objNodeDiv.innerHTML = d;
var objChildNodesLayer = document.createElement("div");
objChildNodesLayer.setAttribute("id", "divChildren_" + this.id);
objChildNodesLayer.style.position = "relative";
objChildNodesLayer.style.display = (this.expanded ? "block" : "none");
objNodeDiv.appendChild(objChildNodesLayer);
for (var i=0; i < this.childNodes.length; i++)
this.childNodes[i].addToDOM(objChildNodesLayer);}

UitklapMenuNode.prototype.collapse = function () {
if (!this.expanded) {throw "Fout: reeds samengevouwen"} 
else {this.expanded = false;
document.images["imgPM_" + this.id].src = imgPlus.src;
document.getElementById("divChildren_" + this.id).style.display = "none";}}

UitklapMenuNode.prototype.expand = function () {
if (this.expanded) {throw "Fout: reeds uitgevouwen"} 
else {this.expanded = true;
document.images["imgPM_" + this.id].src = imgMinus.src;
document.getElementById("divChildren_" + this.id).style.display = "block";}}
