/*
 * infobox.js - Information in style.
 *
 * :tabSize=4:indentSize=4:noTabs=false:
 * :folding=explicit:collapseFolds=1:
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the 
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

var posX;	// Mouse X position
var posY;	// Mouse Y position
 
// Listen for mouse move events so we can get the mouse position.
document.onmousemove = getMousePos;

/**
 * Function: getMousePos
 *
 * Retrieves the position of the mouse cursor and sets the values of posX
 * and posY.
 */
function getMousePos(e)
{
	if (!e) var e = window.event;
	
	if (e.pageX || e.pageY)
	{	// Mozilla.
		posX = e.pageX;
		posY = e.pageY;
	}
	else if (e.clientX || e.clientY)
	{
		if (document.documentElement && document.documentElement.scrollTop)
		{	// IE6 "standards compliance" mode. Heh.
			posX = e.clientX + document.documentElement.scrollLeft;
			posY = e.clientY + document.documentElement.scrollTop;
		}
		else
		{	// IE5, Opera, etc.
			posX = e.clientX + document.body.scrollLeft;
			posY = e.clientY + document.body.scrollTop;
		}
	}
}

/**
 * Function: infoBoxOn
 *
 * Displays an infobox at the location of the mouse cursor.
 *
 * Parameters:
 *
 *     source  - Source element.
 *     content - HTML content to be displayed in the infobox.
 */ 
function infoBoxOn(source, content)
{
	var infobox = document.getElementById("infoBox");
	
	infobox.innerHTML = content;
	
	infobox.style.left    = (posX + 25) + "px";
	infobox.style.top     = posY + "px";
	infobox.style.display = "block";
}

/**
 * Function: infoBoxOff
 *
 * Turns the infobox off.
 */
function infoBoxOff()
{
	var infobox = document.getElementById("infoBox");
	
	infobox.style.display = "none";
}
