﻿function statsHover(caller,message)
{
	position = getPosition(caller);
	var newdiv = document.createElement('div');
	newdiv.setAttribute('class', 'stat_translation');
	newdiv.setAttribute('id','jbn_stats_hover');
	newleft = position.x;
	newtop = position.y-15;
	newleft=newleft+"px";
	newtop=newtop+"px";
	newdiv.style.left=newleft;
	newdiv.style.top=newtop;
	newdiv.innerHTML=message;
	document.body.appendChild(newdiv);
}

function killHover()
{
	var hoverer = document.getElementById('jbn_stats_hover');
	document.body.removeChild(hoverer);
}

////******Get Position***
function getPosition(e)
{
	var left = 0;
    var top  = 0;
	/** Safari fix -- thanks to Luis Chato for this! */
	if (e.offsetHeight == 0) {
		/** Safari 2 doesn't correctly grab the offsetTop of a table row
		    this is detailed here:
		    http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
		    the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
		    note that firefox will return a text node as a first child, so designing a more thorough
		    solution may need to take that into account, for now this seems to work in firefox, safari, ie */
		e = e.firstChild; // a table cell
	}
    while (e.offsetParent){
    	left += e.offsetLeft;
        top  += e.offsetTop;
        e     = e.offsetParent;
    }

    left += e.offsetLeft;
    top  += e.offsetTop;

    return {x:left, y:top};
}

