	function showchild(Nodeid)
	{
		if (!document.all[Nodeid+"_CHILD"])
		{
			return;
		}
		if (document.all[Nodeid+"_CHILD"].style.display=="")
		{
			document.all[Nodeid+"_CHILD"].style.display="none";
			document.all[Nodeid+"_img"].src="images/plus.gif";
		}
		else
		{
			document.all[Nodeid+"_CHILD"].style.display="";
			document.all[Nodeid+"_img"].src="images/minus.gif";
		}
	}
	function opennode(Nodeid)
	{
		if (!document.all[Nodeid+"_CHILD"])
		{
			return;
		}
			document.all[Nodeid+"_CHILD"].style.display="";
			document.all[Nodeid+"_img"].src="images/minus.gif";
	}
	function newNode(NodeID,NodeText,ParentID,NodeAction)
	{
		var treeNode=new Object();
		treeNode.ID=NodeID;
		treeNode.Text=NodeText;
		treeNode.Action=NodeAction;
		treeNode.parentNode=0;
		treeNode.firstChildNode=0;
		treeNode.nextNode=0;
		treeNode.parentID=ParentID;
		treeNode.addChild=addChildNode;
		treeNode.appendNode=appendTreeNode;		
		return treeNode;
	}
	function appendTreeNode(Node)
	{
		if (this.nextNode==0)
		{
			this.nextNode=Node;
			return true;
		}
		else
		{
			return this.nextNode.appendNode(Node);
		}
	}
	
	function addChildNode(Node)
	{
		Node.parentNode=this;
		if (this.firstChildNode==0)
		{
			this.firstChildNode=Node;
			return true;
		}
		else
		{
			return this.firstChildNode.appendNode(Node);
		}
	}
	function getTreeNodeHtml(Node,Level)
	{
		//alert(Node.ID+Level);
		var Htm;
		if (Node==0)
		{
			return "";
		}
		else
		{
			Htm='<div>';
			var i=0;
			for (i=0;i<Level;i++)
			{
				Htm+="&nbsp;&nbsp;&nbsp;"
			}
			Htm += '<nobr><SPAN CLASS="NODEHEADCLASS" id="N' + Node.ID + '" ' + ((Node.firstChildNode == 0) ? '><img id="N' + Node.ID + '_img" src="images/blank.gif">' : 'onclick="showchild(this.id);"><img id="N' + Node.ID + '_img" src="images/plus.gif">') + '</SPAN>';
			Htm += '<SPAN id="N' + Node.ID + '_txt" nowrap CLASS="NODETEXT" onclick="' + Node.Action + '">' + Node.Text + '</SPAN></nobr></div>\n';
				if (Node.firstChildNode!=0)
				{
					Htm+='<DIV nowrap CLASS="TREECLASS" id="N'+Node.ID+'_CHILD" style="display:none">';
					Htm+=getTreeNodeHtml(Node.firstChildNode,Level+1);
					Htm+="</DIV>";
				}
				if (Node.nextNode!=0 )
				{
					Htm+=getTreeNodeHtml(Node.nextNode,Level);
				}
		}
		return Htm;
	}
var nodelist=new Array();
	function findnode(nodeID)
	{
		var i=0;
		for (i=0;i<nodelen;i++)
		{
			if (nodelist[i].ID==nodeID)
			{
				return nodelist[i];
			}
		}
		return null;
	}
	function locate(lID)
	{
		for (i=0;i<nodelen;i++)
		{
			if (nodelist[i].ID==lID)
			{
				return nodelist[i];
			}
		}
	}
	function showtree(itop)
	{
		var i=0;
		for (i=0;i<nodelen;i++)
		{
			if (nodelist[i].parentID!="-1")
			{
				node=findnode(nodelist[i].parentID);
				node.addChild(nodelist[i]);
			}
		}
		//alert(nodelist[1].ID);
		//document.open();
		document.writeln(getTreeNodeHtml(findnode(nodelist[itop].parentID).firstChildNode,0));
		//alert(getTreeNodeHtml(nodelist[0],0));
	}
  function opentree(lID)
  {
  	node=locate(lID);
  	document.all["N"+lID+"_txt"].style.fontWeight="bold";
  	document.all["N"+lID+"_txt"].style.color="blue";
  	while (node.parentID!="-1")
  	{
  		opennode("N"+node.parentID);
     	node=locate(node.parentID);
  	}
  }
