/*
* this two functions depend on:
*	- the style sheet /styles/navigation/style.css
*		(styles with *_on: ...)
*   - the global variable tree that itself depends on the created tree (yahoo ui)
*   - the yahoo tree javascript files (event_min.js, treeview_min.js, yahoo_min.js)
*/


/*
* Toggles the node with the menu name denoted by name and 
* all its parentmenu, so the current node is opened
* 
* All Umlaut in the label names hast to be passed as html: ä is &auml ...
* @param name the name of the label of this node
* @param parentName the name of the label of the parent node 
*/
function openNavigation(name ,parentName)
{
	if(tree !=null)
	{
		nodes = tree.getNodesByProperty('key', name);
		
		if(nodes!=null && nodes.length>1)
		{
			tree.collapseAll();
			
			node = null;
			for(i=0; i< nodes.length; i++)
			{
				//multiple nodes found, decide by parents
				if(nodes[i].parent.data.key == parentName)
				{
					node=nodes[i];
					//for return val
					nodes[0] = node;
					break;
				}
			}
			if(node!=null)
			{
				node.toggle();
				while(node.parent && node.parent != tree.getRoot())
				{
					node = node.parent;
					node.toggle();
				}
			}
		}
		else
		{
			//just one node found
			tree.collapseAll();
			node = nodes[0];
			node.toggle();
			while(node.parent && node.parent != tree.getRoot())
			{
				node = node.parent;
				node.toggle();
			}
		}
		return nodes[0]
	}
}
/*
* Hightlights the path to the selected node and opens the menutree
* 
* All Umlaut in the label names hast to be passed as html: ä is &auml ...
* @param name the name of the label of this node
* @param parentName the name of the label of the parent node 
*/
function highlight(name, parentName)
{	//opens the menu
	node = openNavigation(name, parentName);
	if(node!=null)
	{
		node.labelStyle = node.labelStyle + '_on';
		node.refresh();
		while(node.parent && node.parent != tree.getRoot())
		{

			node = node.parent;
			node.labelStyle = node.labelStyle + '_on';
			node.refresh();
			
		}
		tree.draw();
	}
}

