
function treeClick(node)
    {
    if(typeof(node)!='object') node=document.getElementById(node);
    if (node.rows.length<2) return;
    var img=node.rows[0].cells[0].childNodes[0].childNodes[0];
    if (node.rows[1].style.display=="none")
    {
    node.rows[1].style.display="";
    img.src='/i/chkbox/open.gif';
    }
    else
    {
    node.rows[1].style.display="none";
    img.src='/i/chkbox/closed.gif';
    }
    }

function treeBtnHTML(btype, bid)
    {
    if (btype=='opened') btype='open'; 
    if (btype=='empty')
    return "<img src='/i/chkbox/"+btype+".gif' width=16 height=16 border=0>";
    else
    return "<a style='cursor: pointer;' onclick='treeClick("+bid+"); return false;' isTreeBtn='1'><img src='/i/chkbox/"+btype+".gif' width=16 height=16 border=0></a>";
    }
    
function treeNodeHTML(nid,nname,is_checkbox)
    {
    return "<table width=100% cellspacing=1 cellpadding=0 id='tag_"+nid+"'><tr><td width=0 nowrap>"+treeBtnHTML('empty','tag_'+nid)+
        "</td><td width=100% valign=top>"+
        (is_checkbox?
        "<span class='checkbox' tag_id='"+nid+"'><a class='checkbox_lnk' href='//# "+nname+"'><img src='/i/chkbox/checked.gif' class='checkbox_img' width='13' height='13' alt=''> <span class='checkbox_txt'>"+nname+"</span></a><img src='/i/1px.gif' width=1 height=19></span>"
        :"<span class='treenode' tag_id='"+nid+"'><a style='cursor:default' class='treenode_lnk' onclick='treeClick(tag_"+nid+"); return false;'><span class='treenode_txt'>"+nname+"</span></a></span>")+
        "</td></tr></table>";
    }
    
function treeXQNodeHTML(nid,nname,ntype)
    {
    return "<table width=100% cellspacing=1 cellpadding=0 id='"+ntype+"_"+nid+"'><tr><td width=0 nowrap>"+treeBtnHTML('empty',nid)+
        "</td><td width=100%><span class='"+ntype+"' "+ntype+"_id='"+nid+"'><a style='cursor:default' class='"+ntype+"_lnk' onclick='treeClick("+ntype+"_"+nid+"); return false;'><span class='"+ntype+"_txt'>"+nname+"</span></a></span>"+
        "</td></tr></table>";
    }
