//----------------------------------------------------------------------
// global variables
var browser; // what browser the client is using

if (document.all)
	browser = "ie"; // interent explorer
else
	browser = "ff"; // firefox or other
		
var mouseX = 0;
var mouseY = 0;

//----------------------------------------------------------------------
// update the mouse position with move
document.onmousemove = updateMousePosition;

//----------------------------------------------------------------------
// cross-browser get object by id
function getObjectById(id) 
{
	if (browser == "ff")
		return (document.getElementById(id));
	else
		return (document.all[id]);
}

//----------------------------------------------------------------------
// toggle an object's visibility by id
function toggleVisibility(id)
{
	o = getObjectById(id);
	
	if (o.style.visibility == "hidden")
		o.style.visibility = "visible";
	else 
		o.style.visibility = "hidden";
}

//----------------------------------------------------------------------
// update mouse coordinates
function updateMousePosition(e)
{
	if (!e) var e = window.event;
	
	if (browser == "ff")	
	{
		mouseX = e.pageX;
		mouseY = e.pageY;
	}
	
	// internet explorer
	else if (browser == "ie")
	{
		mouseX = e.clientX;
		mouseY = e.clientY;
	}
}

//----------------------------------------------------------------------
// move to mouse coordinates
function moveObjectWithMouse(id, e)
{
	o = getObjectById(id);
	
	if (o.style.position != "absolute")
		o.style.position = "absolute";

	
	// top-left corner with mouse
	o.style.position.top = mouseX;
	o.style.position.left = mouseY;
}
