/****************************************************************************
* JavaScript Tool-Tips by lobo235 - www.netlobo.com
*
* This script allows you to add javascript tool-tips to your pages in a very
* unobtrusive manner. To learn more about using this script please visit
* http://www.netlobo.com/javascript_tooltips.html for usage examples.
****************************************************************************/

// Empty Variables to hold the mouse position and the window size
var mousePos = null;
var winSize = null;

// Set events to catch mouse position and window size
document.onmousemove = mouseMove;
window.onresize = windowResize;

// The mouseMove and mouseCoords function track the mouse position for us
function mouseMove(ev)
{
	ev = ev || window.event;
	mousePos = mouseCoords(ev);
}
function mouseCoords(ev)
{


	if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
	}
	if (!ev) ev = window.event;



	xx = ev.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
	yy = ev.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	//if (mousePos != null && xx - mousePos.x > 10)	{
		//alert("1, 2: " + ev.clientX + ", " + document.body.scrollLeft +  ", " + document.documentElement.scrollLeft + ", " + xx);
	//}
	return {
		x: xx,
		y: yy
	};
}

// The windowResize function keeps track of the window size for us
function windowResize( )
{
var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }



	winSize = {
		x: myWidth,
		y: myHeight
	}
}

// This function shows our tool-tips
function showTip(anchor)
{
	var tip = document.getElementById('t'+anchor.id);
	tip.style.position = "absolute";
	var newTop = mousePos.y - tip.clientHeight - 10;
	var newLeft = mousePos.x - ( tip.clientWidth / 2 );
	if( newTop < 0 )
		newTop = mousePos.y + 20;
	if( newLeft < 0 )
		newLeft = 0;
	//if( ( mousePos.x + ( tip.clientWidth / 2 ) ) >= winSize.x - 1 )
	//	newLeft = winSize.x - tip.clientWidth - 2;

	var elem = document.getElementById("page");



	tip.style.top = newTop + "px";
	tip.style.left = (newLeft - elem.offsetLeft) + "px";
	tip.style.display = "block";
}






// This function hides the tool-tips
function hideTip(anchor)
{
	var tip = document.getElementById('t'+anchor.id);
	tip.style.display = "none";
}

