// LyTreeScript.js
// Copyright (c) 2000-2009, Lyria-W4.
// All rights reserved.
// @version	$Id: LyTreeScript.js,v 1.5 2009/01/06 11:04:03 jls Exp $

// Scroll down to the active node
function ShowActiveNode(name)
{
	var netscapeNavigation = (navigator.appName == "Netscape");

	if (!netscapeNavigation)
		location = "#" + name;
}

// Select a node.
function SelectTreeNode(treeNodeId, controllerId, path)
{
	InvokeSelection("_select", treeNodeId, controllerId, "false", path);
}

// Consult a node.
function ConsultTreeNode(nodeId, controllerId, treeId, path)
{
	InvokeAction(treeId, null, null, controllerId, nodeId, null);
}

// Change the expand state of a node
function ExpandTreeNode(nodeId, controllerId, path)
{
	InvokeAction(null, path, null, controllerId, nodeId, "expand");
}

// Change the color of a tree node
function SetTreeNodeColor(cellId, fontId, color, textColor)
{
	var frame = findTargetByContent(null, cellId);

	if (frame != null)
	{
		var tdObj = frame.document.getElementById(cellId);
		var fontObj = frame.document.getElementById(fontId);
		
		tdObj.style.backgroundColor = color;
		fontObj.style.color = textColor;
	}
}

// Called when a contextual menu is performed on a tree node
function InvokeTreeNodePopup(treeNodeId, treeId, controllerId, path, selectPath, event)
{
	var methodParam = ReplaceString(treeNodeId, "\\", "\\\\");

	SelectTreeNode(treeNodeId, controllerId, selectPath);
	
	setTimeout("InvokePopup('" + treeId + "','" + ReplaceString(treeNodeId,"\\","\\\\") +
		"','" + path + "','" + controllerId + "',false," +
		event.clientX + "," + event.clientY + ")", 300);
}
