/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

var title;
var text;
var tipBox;
var that;
var tip;
var tipBoxName;
var tempX = 0;
var tempY = 0;
// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all ? true : false;

// If NS -- that is, !IE -- then set up for mouse capture
if(!IE) document.captureEvents(Event.MOUSEMOVE);
// Set-up to use getMouseXY function onMouseMove
//document.onmousemove = getMouseXY;


function doToolTip()
{
    tip = that;
    tipBoxName = tipBox;
    tip.onmousemove=updatePos;
    document.getElementById(tipBoxName).innerHTML='<h2>'+title+'</h2><span>'+text+'</span>';
    document.getElementById(tipBoxName).style.display="block";
    window.onscroll=updatePos;
}

/**
 * The guts of the tooltip
 * @param title
 * @param text
 * @param tipBox The name of the <span> element to use (for multiple tooltips)
 * @param that That is "this" passed from the calling icon
 */
function toolTip(title, text, tipBox, that)
{
    this.title = title;
    this.text = text;
    this.tipBox = tipBox;
    this.that = that;
    setTimeout("doToolTip()", 0);
    tip.onmouseout=hideToolTip;
}

/**
 * Track the movements of the cursor
 */
function updatePos()
{
    var ev = arguments[0] ? arguments[0] : event;
    getMouseXY(ev);
    var x = tempX;
    var y = tempY;
    diffX=-100;
    diffY=-150;
    document.getElementById(tipBoxName).style.top  = y-2+diffY+"px";
    document.getElementById(tipBoxName).style.left = x-2+diffX+"px";
    tip.onmouseout=hideToolTip;
}

/**
 * This method brushes you teeth for you...
 * Actally, it just hides the tooltip when you
 * fall off the icon you're hovering over
 */
function hideToolTip()
{
    document.getElementById(tipBoxName).style.display="none";
}

// Main function to retrieve mouse x-y pos.s
function getMouseXY(e)
{
    if(IE)
    { // grab the x-y pos.s if browser is IE
        tempX = event.clientX + document.body.scrollLeft
        tempY = event.clientY + document.body.scrollTop
    }
    else
    {  // grab the x-y pos.s if browser is NS
        tempX = e.pageX
        tempY = e.pageY
    }
}