function treeMenu (id)
{
	var tree = document.getElementById(id);
	var cur = null;
	parseRootItems(tree);
	renderCur(cur);
	function parseRootItems(obj)
	{
		obj.childItems = new Array();
		for(var i=0; i<obj.childNodes.length; i++)
		{
			if(obj.childNodes[i].tagName == "DIV")
			{
				obj.childItems[obj.childItems.length] = parseSubItems(obj.childNodes[i]);
			}
		}
	}
	function parseSubItems (obj)
	{	
		obj.subItem = null;
		for(var i=0; i<obj.childNodes.length; i++)
		{
			if(obj.childNodes[i].tagName == "A")
			{
					obj._link = obj.childNodes[i];
			}
			if(obj.childNodes[i].tagName == "DIV")
			{
				obj.subItem = obj.childNodes[i];
				parseRootItems(obj.subItem);
				obj.subItem.style.display = "none";
			}
		}
		/*if (obj.subItem == null)
		{
			//obj._link.className = "emptyLink";
		}*/
		obj._link.onclick = _onClickHandler;
		if(obj._link.rel == 'cur')
		{
			cur = obj._link;
		}
		return obj;
	}
	function _onClickHandler()
	{
		if (this.parentNode.subItem == null)
		{
			return true;
		}
		this.style.display = "none";
		this.style.display = "block";
		if(this.parentNode.subItem.style.display == "none")
		{
			this.parentNode.subItem.style.display = "block";
			this.className = "openLink";
		}
		else
		{
			this.parentNode.subItem.style.display = "none";
			this.className = "link";
		}
		return false;
	}
	function renderCur(obj)
	{
		if(obj == null)
		{
			return false;
		}
		if (obj.parentNode.subItem == null)
		{
			//alert(cur.parentNode.parentNode.parentNode);
			openParent(obj);
			return true;
		}
		obj.parentNode.subItem.style.display = "block";
		obj.className = "openLink";
		openParent(obj);
	}
	function openParent(obj)
	{
		var prnt;
		for(var i=0; i<obj.parentNode.parentNode.parentNode.childNodes.length; i++)
		{
			if((obj.parentNode.parentNode.parentNode.childNodes[i].tagName == "A") && (obj.parentNode.parentNode.parentNode.childNodes[i].className == "link"))
			{
				//alert(obj.parentNode.parentNode.parentNode.childNodes[i]);
					prnt = obj.parentNode.parentNode.parentNode.childNodes[i];
					renderCur(prnt);
					return;
			}
		}
	}
}
