//
//		NAME:			$Workfile: ToolTip.js $
// 		AUTHOR:			Chris Langdon, SDBOR, Regents Information Systems
//		LAST EDITED:	$Header: /SDBOR/RIS/Reporting/Web Based/Web Site/Includes/ToolTip.js 5     5/25/06 9:21a Clangdon $
//		DESCRIPTION:	Import this script into your document by adding the below lines.  It'll allow
//						the use of tool tip type windows in your application.
//
//		USAGE:
//
//		Add the following to the head of your document.
/*
		<head>
			<script language="javascript" src="Tooltip.js" type="text/javascript"></script>
		</head>
*/
//		Add the following to the body of your document.
/*
		<body>
			<div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>
			<script language="javascript" type="text/javascript">initToolTips();</script>
		</body>
*/

// Local const
offsetX = 5;
offsetY = 10;

// Local vars
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
var toolTipSTYLE = "";

//
// Function initToolTips()
//
function initToolTips()
{
	if (ns4 || ns6 || ie4)
  	{
    	if (ns4) toolTipSTYLE = document.toolTipLayer;
    	else if (ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
    	else if (ie4) toolTipSTYLE = document.all.toolTipLayer.style;

	    if (ns4)
		{
			document.captureEvents(Event.MOUSEMOVE);
		}
		else
    	{
      		toolTipSTYLE.visibility = "visible";
      		toolTipSTYLE.display = "none";
    	}
    
		// Capture mouse movement events.
		document.onmousemove = moveToMouseLoc;
	}
}

//
// Function toolTip()
//
function toolTip (msg, fg, bg)
{
	// Hide the tool tip.
	if (toolTip.arguments.length < 1)
	{
    	if (ns4)
		{
			toolTipSTYLE.visibility = "hidden";
		}
	    else
		{
			toolTipSTYLE.display = "none";
		}
	}

	// Show the tool tip.
	else 
	{

		// Default colors.
		if (!fg) fg = "#777777";	// Gray
		if (!bg) bg = "#FFFFFF";	// White
		
		// This is what is rendered to the web page displaying the tool tip.
		var content =
			'<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
			'<table width="225" height="10" border="0" cellspacing="0" cellpadding="1" bgcolor="' + bg + 
			'"><td valign="top" width="225" align="left"><font face="sans-serif" color="' + fg +
			'" size="-2">' + msg + '</font></td></table></td></table>';

		if (ns4)
		{
			toolTipSTYLE.document.write(content);
			toolTipSTYLE.document.close();
			toolTipSTYLE.visibility = "visible";
		}

		if (ns6)
		{
			document.getElementById("toolTipLayer").innerHTML = content;
			toolTipSTYLE.display = 'block'
		}

		if (ie4)
		{
			document.all("toolTipLayer").innerHTML = content;
			toolTipSTYLE.display = 'block'
		}
	}
}

//
// Function: moveToMouseLoc()
//
function moveToMouseLoc(e)
{
	if (ns4 || ns6)
	{
		x = e.pageX;
    	y = e.pageY;
	}
	else
  	{
		x = event.x + document.body.scrollLeft;
    	y = event.y + document.body.scrollTop;
	}
	
	toolTipSTYLE.left = x + offsetX;
	toolTipSTYLE.top = y + offsetY;	
	
	return true;
}
