current = null;

function getTip()
{
	return document.getElementById('tooltip');
}

function showTip()
{
	var tip = getTip();
	tip.className = 'show';
	on = true;
}

function hideTip()
{
	if (!on)
	{
		var tip = getTip();
		tip.className = 'hide';
		tip.innerHTML        = '';	
		resetCurrent();
	}
	
	setTimeout("hideTip()", 200);
}

function resetCurrent()
{
	if (current != null)
	{
		current.src = current.src.substring(0, current.src.lastIndexOf('_')) + '.jpg';	
		current = null;
	}	
}

function setCurrent(ref)
{
	resetCurrent();
	current = ref;
	current.src = current.src.substring(0, current.src.lastIndexOf('.')) + '_hover.jpg';	
}	

function thumbOver()
{
	if (this.src.indexOf('empty.gif') == -1)
	{	
		if (current != this)
		{
			var tip        = getTip();	
			tip.innerHTML  = '<a href="'+this.parentNode.href+'">' + labels[this.src] + '</a>';
			tip.style.left = ((indexes[this.src] * 116) + 10) + 'px';
			setCurrent(this);
		}
	}
		
	showTip();
}

function thumbOut()
{
	on = false;
}

function tipOver()
{
	on = true;
	
}

function tipOut()
{
	on = false;
}

function tipClick()
{
	window.location = this.childNodes[0].href;
}

var thumbs  = document.getElementById('thumbs').getElementsByTagName('img');
var labels  = new Array();
var indexes = new Array();
		
for (var i=0; i<thumbs.length; i++)
{
	if (thumbs[i].alt != '')
	{
		labels[thumbs[i].src]  = thumbs[i].alt;
		indexes[thumbs[i].src] = i;
		
		thumbs[i].alt = '';
		
		thumbs[i].onmouseover = thumbOver;
		thumbs[i].onmouseout  = thumbOut;
	}
	else
	{
		thumbs[i].onmouseover = thumbOut;
	}
}
		
var on = false;

var tip = getTip();
tip.onmouseover = tipOver;
tip.onmouseout  = tipOut;
tip.onclick     = tipClick;

setTimeout("hideTip()", 1000);

