
var ImgExpanded="images/expanded.gif";
var Imgcollapsed="images/collapsed.gif";
var ImgNone="images/none.gif";
var basePath="";

function LoadNode(NodePath,NodeName,NodeID)
{ 
var xmlTree=new JXXml();
Path=NodePath+"&temp="+Math.floor(Math.random()*10000);
xmlTree.LoadUrl(Path); 

var items=xmlTree.getElementsByTagName("tree");
Tree="<div id='"+NodeName+"_"+NodeID+"' class='tree'>";
if(NodeID=="0")
Tree+="<img src='"+basePath+ImgExpanded+"' width='13' height='13'/>&nbsp;&nbsp;<input type='radio' title='ROOT' name='"+NodeName+"' value='"+NodeID+"'>ROOT";
 

 for(i=1;i<items.length;i++)
 {
TreeNode="";
var currentRow=items.item(i);
strTitle = currentRow.getAttribute("text");
strID = currentRow.getAttribute("id");
strSrc = currentRow.getAttribute("src");
TreeNode="<div id='"+NodeName+strID+"' class='tree'>";
if(strSrc!=null)
{
TreeNode=TreeNode+"<img style='cursor:pointer' onclick='OpenNode(this,\""+strSrc+"\",\""+NodeName+"\","+strID+")' src='"+basePath+ImgExpanded+"' width='13' height='13'/>&nbsp;&nbsp;<input type='radio' title='"+strTitle+"' name='"+NodeName+"' value='"+strID+"'>"+strTitle.substring(0,8)+"</div>";
}else
{
TreeNode=TreeNode+"<img src='"+basePath+ImgNone+"' width='13' height='13'/>&nbsp;&nbsp;<input type='radio' title='"+strTitle+"' name='"+NodeName+"' value='"+strID+"'>"+strTitle.substring(0,8)+"</a></div>";
}

Tree=Tree+TreeNode;

} 
Tree+="</div>";
xmlTree=null;
return Tree;
}



function OpenNode(Img,NodePath,NodeName,NodeID)
{
Node=NodeName+"_"+NodeID;
ParentNode=NodeName+NodeID;
if(Img==null)
{
document.write(LoadNode(NodePath,NodeName,NodeID));
return;
}
if(document.getElementById(Node)==null)
{
document.getElementById(ParentNode).innerHTML=document.getElementById(ParentNode).innerHTML+LoadNode(NodePath,NodeName,NodeID);
Img.src=basePath+ImgExpanded;
document.getElementById(Node).style.display="block";
}
else
{
if(document.getElementById(Node).style.display=="none")
{
Img.src=basePath+ImgExpanded;
document.getElementById(Node).style.display="block";
}
else
{
document.getElementById(Node).style.display="none";
Img.src=basePath+Imgcollapsed;
}
}
}

