﻿function Node(_id, _text,_url,_parent, _public, _visible,_firstpage,_order, _template ) {
    this.id = _id  
    this.text = _text;  
    this.url=_url
    this.template=_template;
    this.item=null
    this.css=null
    this.access=_public
    this.visible=_visible
    this.childs=null
    this.order=_order;
    this.firstpage=_firstpage
    this.selected=false;
    this.parent=_parent
}
Node.prototype.Create = function  (_elem, _left,_css){
    this.item=htmlAddElement(_elem, "div", null, _css+"Normal");
    this.css=_css
    var thisObj=this
    this.item.style.left=_left
    htmlAddElement(this.item, "div", this.text, "topmenuText");
     this.item.onmouseover=function(){
     if (current ==null || current.id != thisObj.id){ 
        this.className=thisObj.css+"Over"
        }
    };
     this.item.onmouseout=function(){
     if (current ==null || current.id != thisObj.id){
        this.className=thisObj.css+"Normal"
        }
    };
     this.item.onclick=function(){
      uiShow(thisObj.id,"0", thisObj.text)
    };
}
/**
 * Callback function when a node is clicked in the tree.
 */
Node.prototype.ParentNodeClicked = function  (){
    var thisObj=this
    if (current !=null) current.item.className=current.css+"Normal"
    current=this;
    subTop.innerHTML=""
    top.className="topmenu"
    thisObj.item.className=thisObj.css+"Selected"
}

Node.prototype.CreateChilds = function (){
    if (this.childs==null || this.childs.length <1) {
    return;
    }else{
    top.className="topmenusub"
    }
    var table =htmlCreateElement("table", null, null)
    var tbody=htmlCreateElement("tbody", null, null);
    var tr=htmlCreateElement("tr", null, null)
    var td=null
    var img=null
    table.cellspacing=2;
    table.cellpadding=2;
    table.border=0 
    table.height=30
    for (var i = 0; i < this.childs.length; i++) {
 
        td=htmlCreateElement("td", this.childs[i].text, "topmenuSubMenuTextNormal")
        //td.style.paddingLeft=20
        td.id=this.childs[i].id
        td.name=this.childs[i].text
        td.onmouseover=function(){
            this.className="topmenuSubMenuTextOver"
        };
        td.onmouseout=function(){
            this.className="topmenuSubMenuTextNormal"
        };
        td.onclick=function(){
        
            uiShow(this.id ,"0", this.name)
        };
        
    
        tr.appendChild(td)
        td=htmlCreateElement("td", null, null)
        td.className="separator";
        tr.appendChild(td)
        
    }
    
    tbody.appendChild(tr)
    table.appendChild(tbody)
    subTop.appendChild(table);
}
