<!--
/*
Everything in here is Copyright (2005) Jamie Nicol.

Usage:
	<scr ipt type="text/javascript" language = "javascript" src="tooltip.js"></scr ipt>
	<a href="blah" onMouseOver="hoverText(this, 'Tooltip text')" onMouseOut="hoverText()">

You can also use this on any tag/element that supports mouseover/mouseout events.
Don't forget to remove the spaces from the scr ipt tags above!
*/


document.write("<div id='hoverBox'><!-- empty --></div>");
document.onmousemove = mouseMove;

var hoverObj = document.getElementById("hoverBox");	// the hoverbox div object
var hoverBox = false;								// flag to indicate if the hoverbox is visible or not
var tempTitle = "";									// temp store for an A tag's title

var isIE = (document.all && !window.opera);			// Internet Explorer?
var isOpera = window.opera;							// Opera?


function mouseMove(e) {

	if (hoverBox) { // flag to show that the hoverbox is visible

		if (isIE) { // IE
			var xCoord = event.x + document.documentElement.scrollLeft;
			var yCoord = event.y + document.documentElement.scrollTop + 20; // document.body doesn't work if a doctype is set

			if (xCoord + hoverObj.clientWidth + 5 > document.documentElement.scrollLeft + document.documentElement.clientWidth) {
				xCoord = xCoord - hoverObj.clientWidth + 8;
			} // end if
		
			if (yCoord + hoverObj.clientHeight + 5 > document.documentElement.clientHeight + document.documentElement.scrollTop) {
				yCoord = yCoord - 60;
			} // end if

			hoverObj.style.pixelLeft = xCoord;
			hoverObj.style.pixelTop = yCoord;
		} // end if

		else { // non-IE
			var xCoord = e.pageX
			var yCoord = e.pageY + 20;

			if (xCoord + hoverObj.clientWidth + 5 > document.documentElement.clientWidth + document.documentElement.scrollLeft) {
				xCoord = xCoord - hoverObj.clientWidth + 8;
			} // end if
		
			if (yCoord + hoverObj.clientHeight + 5 > document.documentElement.clientHeight + document.documentElement.scrollTop) {
				yCoord = yCoord  - 60
				if (isOpera) {  }
			} // end if
		
			hoverObj.style.left = xCoord + "px";
			hoverObj.style.top = yCoord + "px";
		} // end else

	} // end if

} // end mouseMove()


function hoverText(aObj, textData) {

	if (!aObj) {							// function was called with no arguments, so remove the hoverbox
		hoverBox.title = tempTitle;			// reset anchor title
		tempTitle = "";						// reset temp store for anchor title
		hoverBox = false;					// unstore reference to anchor object
		hoverObj.style.display = "none";	// hide the hoverbox
	} // end if

	else {
		hoverBox=aObj;						// store reference to element, just as a flag so we know that the hoverbox is visible
		tempTitle = aObj.title;				// temp store for anchor title
		aObj.title = "";					// disable anchor title
		hoverObj.innerHTML = textData;		// set the text in the hoverbox
		hoverObj.style.display = "block";	// display the hoverbox
		if (isIE) mouseMove();				// the first movement over the element will not invoke the hoverbox in IE, so force it
	} // end else

} // end hoverText()

-->
