// Node object
function Node(id, pid, name, status, url, title, target, icon, iconOpen, open) {
    this.id = id;
    this.pid = pid;
    this.name = name;
    this.status = status;
    this.url = url;
    this.title = title;
    this.target = target;
    this.icon = icon;
    this.iconOpen = iconOpen;
    this._io = open || false;
    this._is = false;
    this._ls = false;
    this._hc = false;
    this._ai = 0;
    this._p;
};

// Tree object
function dTreeCmsPageMainMenu(objName) {
    this.obj = objName;
    this.aNodes = [];
    this.aIndent = [];
    this.root = new Node(-1);
    this.selectedNode = null;
    this.selectedFound = false;
    this.completed = false;
};

// Adds a new node to the node array
dTreeCmsPageMainMenu.prototype.add = function(id, pid, name, status, url, title, target, icon, iconOpen, open) {
    this.aNodes[this.aNodes.length] = new Node(id, pid, name, status, url, title, target, icon, iconOpen, open);
};

// Outputs the tree 
dTreeCmsPageMainMenu.prototype.toString = function() {
    var str = '<div class="dtree">\n';
    str += '<tr>';
    str += '  <td><img src="/images/spacer.gif" width="20" height="20"></td>';
    str += '  <td width="100%" align="right">';
    str += '  <a href="' + this.aNodes[0].url + '" class="navi_title"><font color="#FF6600">' + this.aNodes[0].name + '</font></a></td>';
    str += '  <td><img src="/images/spacer.gif" width="8" height="20"></td>';
    str += '</tr>'; 
    for (n = 1; n<this.aNodes.length; n++) {
    	str += '<tr>';
        str += '  <td><img src="/images/spacer.gif" width="20" height="20"></td>';
        str += '  <td align="right" nowrap><a href="' + this.aNodes[n].url  + '" class="cmsPageMainMenu">' + this.aNodes[n].name + '</a></td>';
        str += '  <td><img src="/images/spacer.gif" width="8" height="20"></td>';
        str += '</tr>';
    }
    str += '</div>';
    return str;
};
