var nd_doc_id = '';
var nd_grp_id = '';
var nd_topic_id = '';
var nd_openc_id = '';

function setAll(keyScroll, doc_id, grp_id, topic_id, opencategories)
{
	nd_doc_id = doc_id;
	nd_grp_id = grp_id;
	nd_topic_id = topic_id;
	nd_openc_id = opencategories;

	if (window.focus) window.focus()

	if (keyScroll)
	{
		document.onkeydown=scrollingHandler;
	}
}

function scrollingHandler(e) 
{
	if (!e && window) e = window.event; 

	if (!e)
		return false;

	if (e.keyCode)
		key = e.keyCode;
	else if (e.which) 
		key = e.which; 
	else return false;

	var chr = String.fromCharCode(key).toLowerCase();

	if ((e.altKey || e.ctrlKey) && (key == 40 || key == 57386)) // Next topic
	{
		if (top.body && top.body.document)
		{
			var listEls = top.body.document.getElementsByTagName("A");
			for (var i = 0; i < listEls.length; i++) {
				if (typeof(listEls[i].rel) != undefined && listEls[i].rel == "next")
				{
					top.body.location.replace(listEls[i].href);
				}
			}
		}
		else
		{
			parent.body.location.href = "help.php?frame=body&op=shownextt&doc="+nd_doc_id+"&id="+nd_topic_id+"&opencategories="+nd_openc_id+"&grp="+nd_grp_id+"&synctoc=1";
		}
		return false;
	}
	else if ((e.altKey || e.ctrlKey) && (key == 38 || key == 57385)) // Prev topic
	{
		if (top.body && top.body.document)
		{
			var listEls = top.body.document.getElementsByTagName("A");
			for (var i = 0; i < listEls.length; i++) {
				if (typeof(listEls[i].rel) != undefined && listEls[i].rel == "previous")
				{
					top.body.location.replace(listEls[i].href);
				}
			}
		}
		else
		{
			parent.body.location.href = "help.php?frame=body&op=showprevt&doc="+nd_doc_id+"&id="+nd_topic_id+"&opencategories="+nd_openc_id+">&grp="+nd_grp_id+"&synctoc=1";
		}
		return false;
	}
	else if (key == 27) // ESC - exit
	{
		top.window.close();
	}
}

function onMouseDownHandler(e) {
	var rightclick;

	if (!e && window && window.event) 
		e = window.event;

	if (e.which) rightclick = (e.which == 3);
		else if (e.button) rightclick = (e.button == 2);

	if (rightclick) return false;
}

function showTopicContextMenu(e, obj, id) {

	hideTopicContextMenu();

	var rightclick;
	var posx = 0;
	var posy = 0;

	if (!e && window && window.event) 
		e = window.event;

	if (!e) return false;

	if (e.which) rightclick = (e.which == 3);
		else if (e.button) rightclick = (e.button == 2);

	if (!rightclick) return false;

	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.body.scrollLeft;
		posy = e.clientY + document.body.scrollTop;
	}

	if (window.clipboardData) 
		PropProjLayer = document.getElementById('topiccontextlayer1');
	else
		PropProjLayer = document.getElementById('topiccontextlayer2');

	if (PropProjLayer)
	{
		PropProjLayer.style.display='block';

		if (window.clipboardData) 
		{
			PropProjLayer.style.top=posy+'px';
			PropProjLayer.style.left=posx+'px';
		}
		else
		{
			PropProjLayer.style.top='10px';
			PropProjLayer.style.left='10px';
		}
	}

	return false;
}

function CopyShortcutToTopic(copytext) {

	PropProjLayer = document.getElementById('topiccontextlayer1');
	if (PropProjLayer) PropProjLayer.style.display='none';

	if (window.clipboardData) 
	{
		window.clipboardData.setData("Text", copytext);
	}
}


function hideTopicContextMenu() {
	PropProjLayer = document.getElementById('topiccontextlayer1');
	if (PropProjLayer) PropProjLayer.style.display='none';
	PropProjLayer = document.getElementById('topiccontextlayer2');
	if (PropProjLayer) PropProjLayer.style.display='none';
}

function mouseOverTopicContextMenu(Obj)
{
	Obj.style.backgroundColor = '#316AC5';
	Obj.style.color = '#FFFFFF';
	Obj.style.cursor = 'default';
}

function mouseOutTopicContextMenu(item)
{
	item.style.backgroundColor = '#FFF';
	item.style.color = '#000';
}

function OpenHelp(parameter, location)
{
	if (!location)
	{
		location = '';
	}

	if (!parameter)
	{
		parameter = '';
	}

	x = window.open(location+'starthelp.php?'+parameter+'&js=1','','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1, resizable=1,width=700,height=700');

	return !x;
}


function Quickhelp(grp, doc, id, e, location)
{	
	var goext = 0;

	if (!e) var e = window.event;
	if (!e) goext = 1;

	if (!document.getElementById) 
	{
		goext = 1;
	}
	else
	{
		obj = document.getElementById('qh_'+id);
		if (!obj) { goext = 1; }
	}

	if (goext)
	{
		x = window.open(location+'help.php?grp='+grp+'&doc='+doc+'&op=showt&id='+id,'','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1, resizable=1,width=700,height=700');
		return false;
	}

	var x,y;
	var xmax,ymax;

	if (e.pageX || e.pageY)
	{
		x = e.pageX;
		y = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		x = e.clientX;
		y = e.clientY;
	}

	// Frame size
	if (self.innerHeight) // all except Explorer
	{
		xmax = self.innerWidth;
		ymax = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
		// Explorer 6 Strict Mode
	{
		xmax = document.documentElement.clientWidth;
		ymax = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		xmax = document.body.clientWidth;
		ymax = document.body.clientHeight;
	}

	// Scrolling offset
	var scrollx,scrolly;
	if (self.pageYOffset) // all except Explorer
	{
		scrollx = self.pageXOffset;
		scrolly = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		scrollx = document.documentElement.scrollLeft;
		scrolly = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		scrollx = document.body.scrollLeft;
		scrolly = document.body.scrollTop;
	}

	x = x + scrollx - 20;
	y = y + scrolly - 150;

	if (x + 430 > xmax)
	{
		x = xmax - 430;
	}

	if (obj)
	{
		obj.style.display = 'block';
		obj.style.top = y+'px';
		obj.style.left = x+'px';
		return false;
	}
}

function HideQuickhelp(id, e)
{
	if (!e) var e = window.event;
	if (!e) goext = 1;

	obj = document.getElementById('qh_'+id);
	if (obj)
	{
		obj.style.display = 'none';
		obj.style.top = '100px';
		obj.style.left = '100px';
		return false;
	}
}

function ShowThumbnail(parameter, location)
{
	x = window.open(location+parameter,'','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0, resizable=1,width=500,height=500');

	return !x;
}

/* NETDOC MENU */
function Showndmenu2()
{
	obj = document.getElementById('ndmenu2');
	if (obj)
	{
		obj.className = "over";
	}


	return false;
}

function Hidendmenu2()
{
	obj = document.getElementById('ndmenu2');
	if (obj)
	{
		obj.className="";
	}

	return false;
}