﻿// JScript File

function cTree() {
    this.openclass = 'open';
    this.closedclass = 'closed';
    this.toggleOnLi = true;
    this.init = function(objid)
    {
        var obj = document.getElementById(objid);
        this.root = obj;
        var objs = obj.getElementsByTagName('li');
        for(var i=0;i<objs.length;i++)
        {
            var o = objs[i];
            o.tree = this;
            if (this.toggleOnLi)
                o.onmousedown = this.clickToggle;   
        }
    }
    this.toggleLeaf = function(target)
    {
        if (target.getElementsByTagName('ul').length>0)
            target.className = (target.className.indexOf(this.openclass)==-1)?this.openclass:this.closedclass;
        else if (typeof(this.load)=='function')
            this.load(target);
    }
    this.clickToggle = function(e)
    {
        if (!e) var e = window.event;
        var target = (e.target)?e.target:e.srcElement;
        e.cancelBubble = true;
        e.returnValue = false;
        target.tree.toggleLeaf(target);
        return false;
    }
}



