// JavaScript Document

var currentThumb = -1;
var thumbs = new Array();
var nThumbs = 0;

function MyImageClickFunction(e)
{
	if (!e) e = window.event;
	thumbImage = (e.target) ? e.target : e.srcElement;
	thumb = thumbImage.thumbIndex;
	if (thumb != currentThumb)
	{
		thumbs[currentThumb].src = thumbs[currentThumb].src.replace("black", "light");
		thumbs[currentThumb].nextSibling.style.visibility = "hidden";
		thumbImage.nextSibling.style.visibility = "visible";
		thumbImage.src = thumbImage.src.replace("dark", "black");
		currentThumb = thumb;
	}
}

function MyImageOverFunction(e)
{
	if (!e) e = window.event;
	thumbImage = (e.target) ? e.target : e.srcElement;
	thumb = thumbImage.thumbIndex;
	if (thumb != currentThumb)
		thumbImage.src = thumbImage.src.replace("light", "dark");
}

function MyImageOutFunction(e)
{
	if (!e) e = window.event;
	thumbImage = (e.target) ? e.target : e.srcElement;
	thumb = thumbImage.thumbIndex;
	if (thumb != currentThumb)
		thumbImage.src = thumbImage.src.replace("dark", "light");
}

function MyImageDownFunction(e)
{
	if (currentThumb > 0)
	{
		thumbImage = thumbs[currentThumb - 1];
		thumbs[currentThumb].src = thumbs[currentThumb].src.replace("black", "light");
		thumbs[currentThumb].nextSibling.style.visibility = "hidden";
		thumbImage.nextSibling.style.visibility = "visible";
		thumbImage.src = thumbImage.src.replace("light", "black");
		--currentThumb;
	}
}

function MyImageUpFunction(e)
{
	if (currentThumb < nThumbs-1)
	{
		thumbImage = thumbs[currentThumb + 1];
		thumbs[currentThumb].src = thumbs[currentThumb].src.replace("black", "light");
		thumbs[currentThumb].nextSibling.style.visibility = "hidden";
		thumbImage.nextSibling.style.visibility = "visible";
		thumbImage.src = thumbImage.src.replace("light", "black");
		++currentThumb;
	}
}

function MyLoadFunction()
{
	links = document.getElementsByTagName("a");
	anchor = location.hash;
	if (anchor.length) anchor = anchor.substring(1,anchor.length);
	
	for (i = 0; i < links.length; i++)
	{
		linkObj = links[i];
		if (linkObj.className == "thumbnail")
		{
				
			thumbImage = linkObj.firstChild;
			thumbImage.thumbIndex = nThumbs;
			thumbs[nThumbs++] = thumbImage;
			spanImage = linkObj.lastChild;
			fullImage = spanImage.firstChild;
			thumbImage.onclick = MyImageClickFunction;
			thumbImage.onmouseover = MyImageOverFunction;
			thumbImage.onmouseout = MyImageOutFunction;
			
			thumbImage.style.border = "none";
			thumbImage.style.margin = "none";
			
			spanImage.style.position = "absolute";
			spanImage.style.left = (290 - fullImage.width/2) + "px";
			spanImage.style.top  = (218 - fullImage.height/2) + "px";
			if (anchor.length && linkObj.id == anchor)
			{
				currentThumb = thumbImage.thumbIndex;
				spanImage.style.visibility = "visible";
				thumbImage.src = thumbImage.src.replace("light", "black");
			}
			else
			{
				spanImage.style.visibility = "hidden";
			}
			spanImage.style.color = "#000000";
			spanImage.style.fontFamily = "Arial, sans-serif";
			spanImage.style.fontSize = "9pt";
			spanImage.style.textDecoration = "none";
			
			fullImage.style.borderWidth = "0";
			fullImage.style.padding = "none";
			
			linkObj.className = "JavaImg";
		}
		else if (linkObj.id == "leftarrow")
		{
			thumbImage = linkObj.firstChild;
			thumbImage.thumbIndex = -1;
			thumbImage.onclick = MyImageDownFunction;
			thumbImage.onmouseover = MyImageOverFunction;
			thumbImage.onmouseout = MyImageOutFunction;
		}
		else if (linkObj.id == "rightarrow")
		{
			thumbImage = linkObj.firstChild;
			thumbImage.thumbIndex = -1;
			thumbImage.onclick = MyImageUpFunction;
			thumbImage.onmouseover = MyImageOverFunction;
			thumbImage.onmouseout = MyImageOutFunction;
		}
	}
	
	if (currentThumb < 0)
	{
		currentThumb = 0;
		thumbs[0].nextSibling.style.visibility = "visible";
		thumbs[0].src = thumbs[0].src.replace("light", "black");
	}
}

if (document.getElementsByTagName) window.onload = MyLoadFunction;
