var parentObj = new Object();

window.onload = function()
{
	parentObj = window.opener.parent;
	
	var currElement = document.getElementById("back");
	currElement.onclick 		= function(){history.back()};
	currElement.onmouseover	= function(){this.src = "../misc/images/instance/button_back_high.gif"};
	currElement.onmouseout	= function(){this.src = "../misc/images/instance/button_back_low.gif"};
	currElement.title				=	window.opener.parent.strElemTitleBack;
	var currElement = document.getElementById("next");
	currElement.onclick 		= function(){history.forward()};
	currElement.onmouseover	= function(){this.src = "../misc/images/instance/button_next_high.gif"};
	currElement.onmouseout	= function(){this.src = "../misc/images/instance/button_next_low.gif"};	
	currElement.title				=	window.opener.parent.strElemTitleForward;
	
	highLightObject(true);
	
	var arrElems = document.getElementsByTagName('tr');
	for (var i = 0; i < arrElems.length; i++)
	{
		arrElems[i].onmouseover = function(){this.className = "rowHover"};
		arrElems[i].onmouseout = function(){this.className = ""};
	}
}

window.onunload = function()
{
	highLightObject(false);
}

function openWindow(modId, instId)
{
	if (instId != "")
	{
		instLink = "../" + modId + "/" + instId + ".html";
		self.location = instLink;
  }
  else
  {
  	modLink = "../" + modId + "/" + modId + ".html";
  	window.opener.parent.model.location.href = modLink;
  }
}

function highLightObject(boolean)
{
	var currentId = (location.href.substring(location.href.lastIndexOf("ID"), location.href.lastIndexOf(".html")));
	
	highLightElem = parentObj.model.document.getElementById(currentId + "Flag");
	lastHighLightedObject = parentObj.header.actHighLightedObject
	if (highLightElem)
	{
		if (lastHighLightedObject != "" && parentObj.model.document.getElementById(lastHighLightedObject + "Flag"))
		{
			parentObj.model.document.getElementById(lastHighLightedObject + "Flag").style.display = "none";
			parentObj.model.document.getElementById(lastHighLightedObject + "Arrow").style.display = "none";
		}
		
		if (boolean)
		{
			highLightElem.style.display = "block";
			parentObj.model.document.getElementById(currentId + "Arrow").style.display = "block";
			posObject(currentId);
		}
	}
	
	if (boolean)
	{
		parentObj.header.actHighLightedObject = currentId;
	}
	else
	{
		parentObj.header.actHighLightedObject = "";
	}
}

function posObject(objid)
{
	if (window.innerWidth)
	{
		windowWidth = parentObj.model.window.innerWidth;
		windowHeight = parentObj.model.window.innerHeight;	
	}
	else
	{
		windowWidth = parentObj.model.document.body.offsetWidth;
		windowHeight = parentObj.model.document.body.offsetHeight;
	}
	currObj = parentObj.model.document.getElementById(objid + "Flag");
	objLeft = currObj.offsetLeft;
	objTop = currObj.offsetTop;
	newPosLeft = (windowWidth/2 > objLeft) ? 0 : Math.abs(objLeft - windowWidth/2);
	newPosTop = (windowHeight/2 > objTop) ? 0 : Math.abs(objTop - windowHeight/2);
	parentObj.model.scrollTo(newPosLeft, newPosTop);
}