function FindPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent)
	{
		do
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function GetText(textName)
{
	for (x in Texts)
	{
		if (Texts[x][0] == textName)
		{
			return "<span class=\"header\">"+Texts[x][1]+"</span><br>"+Texts[x][2];
		}
	}
	return "?";
}

function ShowBox(object, imgName)
{
	var boxA = document.getElementById("boxA");
	var boxB = document.getElementById("boxB");
	if ((object != null) && (boxA != null) && (boxB != null))
	{
		var position = FindPos(object);
		
		// Move box
		boxA.style.left = position[0]-8;
		boxA.style.top = position[1]-8;
		boxA.style.visibility = "visible";

		boxB.style.left = position[0] - 8 + 206;
		boxB.style.top = boxA.style.top;
		boxB.style.visibility = "visible";

		// Set box content
		var textBox = document.getElementById("textbox");
		textBox.innerHTML = GetText(imgName);

		// Change image
		object.src = "images/thumbs/"+imgName+".png";
	}
}

function HideBox(object, imgName)
{
	var boxA = document.getElementById("boxA");
	if (boxA != null)
		boxA.style.visibility = "hidden";
	var boxB = document.getElementById("boxB");
	if (boxB != null)
		boxB.style.visibility = "hidden";
	// Change image
	if (object != null)
	{
		object.src = "images/thumbs/"+imgName+"_dark.png";
	}
}

function ShowBox2(object, imgName)
{
	var box = document.getElementById("box");
	if ((object != null) && (box != null))
	{
		var position = FindPos(object);
		
		// Move box
		box.style.left = position[0]-8;
		box.style.top = position[1]-8;
		box.style.visibility = "visible";

		// Change image
		object.src = "images/thumbs/"+imgName+".png";
	}
}

function HideBox2(object, imgName)
{
	var box = document.getElementById("box");
	if (box != null)
		box.style.visibility = "hidden";
	// Change image
	if (object != null)
		object.src = "images/thumbs/"+imgName+"_dark.png";
}
