var windowName = "preview";
var HighlightedElement = null;
var HighlightedElementState = null;
var onLoadActions = new Array();

function InitSpecificMenu(mode, name)
{
	context.command.InitSpecificMenu(mode, name);
}

function getAccessory(name, def)
{
	var a = accessories[name]
	if(a == null) return def;
	return a;
}

function rClick()
{
	if(context == null) return;
	return context.command.rClick(event, "preview");
}

function executeLoadActions()
{
	var i;
	if(!isDiffusion) {
		document.body.oncontextmenu = rClick;
		document.body.onclick = showNode;
	}
	for(i=0;i < onLoadActions.length;i++) {
		var action = onLoadActions[i];
		if(typeof(action) == "function") {
			action();
		}
	}
}

function addLoadAction(action)
{
	onLoadActions[onLoadActions.length] = action;
	if(window.document.body != null) {
		window.document.body.onload = executeLoadActions;
	}
}

function showNode()
{
	if(context == null) return;
	var element = context.command.getHTMLPivot(window.event.srcElement);
	if(element == null) return;
	if(HighlightedElement) HighlightedElement.style.backgroundColor = HighlightedElementState;
	HighlightedElementState = element.style.backgroundColor; 
	element.style.backgroundColor = "#E0E0E0";
	HighlightedElement = element;
	var node = context.command.getXMLPivot(window.event.srcElement, "preview");
	while(node != null) {
		var definition = context.model.getDefinition(node);
		if(definition == null || definition.visible == true) break;
		node = node.parentNode;
	}
	if(node != null) {
		context.setCurrentNode(node, false);
	}
	context.command.manageRefresh(event.srcElement);
}

function linkTo(search)
{
	if(context == null) {
		var url = "balloon.asp?login=" + login + "&" + search;
		document.location.href = url;
	} else {
		context.processor.broadcastPath = context.previewPath;
		context.processor.run(search, "HTML");
	}
}

