
var timerID = null;
var timerRunning = false;
var last_shown = "";

function StopTheClock()
{
	if(timerRunning)
	clearTimeout(timerID);
	timerRunning = false;
}

function StartTheTimer(secs, callback)
{
	StopTheClock();
	timerRunning = true;
	timerID = setTimeout(callback, secs*1000);
}

function mouseincallback()
{
	if (last_shown != "") mouseout(last_shown);
	StopTheClock();
}

function mousein(id, secs, x, y)
{
	document.getElementById(id).style.display='block';
	document.getElementById(id).style.left = x + "px";
	document.getElementById(id).style.top = y + "px";
	last_shown = id;
	StartTheTimer(secs, "mouseincallback()");
}

function mouseout(id)
{
	document.getElementById(id).style.display='none';
	last_shown = "";
}
