// ================================================
//
//   TT.JS - Tool Tip Popups
//
//		V1.1  07/18/03 - GNM
//
//	Copyright © 2003 Conceptron Associates
//
// ================================================
//
//	USAGE:
//
//		Add this immediately after the body tag:
//
//			<div id="ToolTip"></div>
//
//		To create a tooltip popup, use an <a> tag containing
//		onMouseover and onMouseout properties:
//
//			onMouseOver="stt('Insert tooltip text here'); return true;"
//			onMouseOut="htt(); return true;"
//
//	Tool tip text formatting relies on the following CSS definitions:
//
//	.tooltipcontent <== defines appearance of Tool Tip text
//		{
//		font-family: Verdana, Arial, Helvetica, sans-serif;
//   	text-decoration: none;
//		color: #0000FF;
//		font-size: 6pt
//		}
//
//	#ToolTip <== ID for ToolTip layer -- must match TTdivname & DIV tag
//		{
//		position: absolute;
//		width: 150px;
//		top: 0px;
//		left: 0px;
//		z-index: 4;
//		visibility: hidden;
//		}
//
//	Supports IE 6 and Netscape 6 and up.
//
// ================================================
//
// CONFIGURATION SETTINGS
//
///////////////////////////////////////////////////
// Tool tip width (in pixels)
var TTwidth = 150;

// Tool tip background colour
var TTbgcolour = "#E5E5E5";

// Tool tip border size (in pixels - 0 for no border)
var TTbordersize = 0;

// Tool tip border colour
var TTbordercolour = "#FFFFFF";

// Padding between text and tool tip border (in pixels)
var TTtextpad = 3;

// Horizontal offset for tool tip popup (left or right of cursor position, in pixels)
var TTHoffset = 15;

// Vertical offset for tool tip popup (below cursor position, in pixels)
var TTVoffset = 10;

// Copy the tool tip text to the status bar? (no=0 yes=1)
var TTstatus = 1;

// DIV name for tool tips (must match ID in DIV tag & CSS defs)
var TTdivname = "ToolTip";


///////////////////////////////////////////////////
// VARIABLES
///////////////////////////////////////////////////
var TTcontents, TTdiv;
var winwidth = 0, hcurpos = 0;
var visible = false;


///////////////////////////////////////////////////
// BROWSER TEST & CONFIG
///////////////////////////////////////////////////
var nav = false, old = false;
if (navigator.appName == "Netscape") nav = true;

if (nav)
{
	var version = navigator.appVersion;
	if (eval(version.substring(0,1)) < 5 ) old = true;
}


///////////////////////////////////////////////////
// INSTALL THE MOUSE HANDLER
///////////////////////////////////////////////////
document.onmousemove = TThandler;


///////////////////////////////////////////////////
// FUNCTIONS
///////////////////////////////////////////////////

// ONMOUSEMOVE HANDLER
function TThandler(e)
{
	if (old) return;

	// Get the layer pointer from the DIV tag
	TTdiv = document.getElementById(TTdivname);

	// Get the current mouse coordinates
	if (!nav) xm = event.x + document.body.scrollLeft;
	if (nav) xm = e.pageX;

	if (!nav) ym = event.y + document.body.scrollTop;
	if (nav) ym = e.pageY;

	// Do the tool tip popup
	if (visible)
	{
		PosToolTip(xm, ym);
		TTdiv.style.visibility = "visible";
	}
	else
	{
		PosToolTip(0, 0);
		TTdiv.style.visibility = "hidden";
	}
}


// POSITION THE POPUP
function PosToolTip(xmpos, ympos)
{
	// Determine the cursor position for horizontal placement
	if (!nav) winwidth = document.body.clientWidth;
	if (nav) winwidth = window.innerWidth;

	if ( xmpos > (winwidth / 2))
	{
		// Cursor is in left half of window
		hcurpos = ((xmpos - TTwidth) - TTHoffset);
	}
	else
	{
		// Cursor is in right half of window
		hcurpos = xmpos + TTHoffset;
	}

	// Position the popup horizontally
	TTdiv.style.left = hcurpos;

	// Position the popup vertically
	TTdiv.style.top = ympos + TTVoffset;
}


// SHOW A POPUP
function stt(TTtext)
{
	if (old) return;

	// Build the tool tip as an HTML table
	TTcontents = '<table border=' + TTbordersize +
	' width="' + TTwidth +
	'" bgcolor="' + TTbordercolour + '" bordercolor="' + TTbordercolour +
	'" cellspacing="0" cellpadding="' + TTtextpad + '"><tr>' +
	'<td width="100%" bgcolor="' + TTbgcolour + '">' +
	'<font class="tooltipcontent">' + TTtext + '</font>' +
	'</td></tr></table>';

	// Turn it on
	visible = true;

	// Write the contents to the popup
	TTdiv.innerHTML = TTcontents;

	// Write the contents to the status bar
	if (TTstatus) self.status = TTtext;
}


// HIDE THE POPUP & CLEAR THE STATUS BAR
function htt()
{
	if (old) return;

	// Turn it off
	visible = false;

	// Clear the status bar
	if (TTstatus) self.status = "";
}

