var mouse_x = 0;
var mouse_y = 0;
var tracking = false;
var barSize = 17;

document.onmousemove = mouseMove;
function mouseMove( evt )
{
	mouse_x = mouseX( evt );
	mouse_y = mouseY( evt );
	if( tracking )
	{
		//document.getElementById( 'tooltip' ).innerHTML += document.getElementById( 'tooltip' ).offsetWidth + ' ';
		/*if( ( document.getElementById( 'tooltip' ).offsetWidth + mouse_x + 10 ) > window.innerWidth - barSize )
			document.getElementById( 'tooltip' ).style.left = window.innerWidth - document.getElementById( 'tooltip' ).offsetWidth - barSize + 'px';
		else*/
			document.getElementById( 'tooltip' ).style.left = mouse_x + 10 + 'px';
		document.getElementById( 'tooltip' ).style.top = mouse_y + 10 + 'px';
	}
}
function mouseX(evt)
{
	if ( navigator.appName == "Microsoft Internet Explorer" )
	{
		return window.event.clientX;
	}
	else
	{
		if (evt.pageX)
			return evt.pageX;
		else if (evt.clientX)
			return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
		else
			return null;
	}
}
function mouseY(evt)
{
	if ( navigator.appName == "Microsoft Internet Explorer" )
	{
		return window.event.clientY;
	}
	else
	{
		if (evt.pageY)
			return evt.pageY;
		else if (evt.clientY)
			return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
		else
			return null;
	}
}

function showTooltip( text )
{
	document.getElementById( 'tooltip' ).style.visibility = 'visible';
	document.getElementById( 'tooltip' ).innerHTML = text;
	//$( 'div#tooltip' ).show( 'fast' );
	tracking = true;
}

function hideTooltip()
{
	document.getElementById( 'tooltip' ).style.visibility = 'hidden';
	//$( 'div#tooltip' ).hide();
	tracking = false
}
