// Copyright © 2005-2006 Water Street USA, LLC.  All rights reserved. --
// ----------------------------------------------------------------------------------
// Water Street USA, LLC (WSUSA) software and code [both binary and source 
// (if released)] (Software) is intellectual property owned by WSUSA and is copyright 
// of WSUSA in all countries in the world, and ownership remains with WSWS.
//
// You (Licensee) may use the WSUSA Software and install it only in accordance with 
// use and licensing agreements you have signed with WSWS.  Licenses are distributed 
// only by WSWS. Please send an email to info@waterstreetusa.com for more information.
//
// If you do not have a valid signed license agreement, you may not use, copy or
// distribute the Software for any purpose.
//
// This copyright notice may not be removed or altered or it will constitute a
// violation of any license agreements.
// ----------------------------------------------------------------------------------

/* ------------------------------------------------------------------
	Name: WSTooltip

	USAGE: to include in HTML page at the top of the body section
		<script language=javascript src=wsws_core.js></script>

--------------------------------------------------------------------- */

/* ------------------------------- */
/* set the appropriate body object */
/* ------------------------------- */
var trueBody =	(document.compatMode && document.compatMode != "BackCompat")
				? document.documentElement 
				: document.body;

/* -------------------------- */
/* does browser support DHTML */
/* -------------------------- */
var dhtml = (document.getElementById || document.all || document.layers);

/* -------------------------------------------------------- */
/* while we minimize their use, here are some browser flags */
/* -------------------------------------------------------- */
var bf_useragent = navigator.userAgent.toLowerCase();
var bf_version = navigator.appVersion;
var bf_opera = !!(window.opera && document.getElementById);
var bf_ie = bf_useragent.indexOf("msie") != -1 && document.all && trueBody && !bf_opera;
var bf_ieVersion;
if (bf_ie) bf_ieVersion = parseFloat(bf_version.substring(bf_version.indexOf("MSIE")+5, bf_version.indexOf("MSIE")+9));
var bf_netscape4 = (document.layers && typeof(document.classes) != "undefined");

/* ------------------------------------------ */
/* get an object by name in cross-browser way */
/* ------------------------------------------ */
function getObject(obj)
{
	var theObj;
	if (document.all) {
		if (typeof obj=='string') {
			return document.all(obj);
		} else {
			return obj.style;
		}
	}
	else if (document.getElementById) {
		if (typeof obj=='string') {
			return document.getElementById(obj);
		} else {
			return obj.style;
		}
	}
	else if (document.layers)
	{
		if (typeof obj=='string') {
			return getObjNN4(document, obj);
		} else {
			return obj.style;
		}
	}
	return null;

}
/* --------------------------- */
/* get an object in netscape 4 */
/* --------------------------- */
function getObjNN4(obj,name)
{
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}
/* --------------------------- */
/* conversions                 */
/* --------------------------- */
function toInt(input)
{
	// attempts to extract a number from start of string, returns 0 for NaN.

	// parseInt:
	// if the first non-whitespace character is not a number the result is NaN
	// if the first non-whitespace character is a number, continues until a non-digit
	// or decimal is encounter and discards everything to the right including a decimal
	var val = parseInt(input);
	return isNaN(val) ? 0 : val;
}
/* --------------------------- */
/* mouse/cursor coordinates    */
/* --------------------------- */
function mouseX(e) 
{
	// returns the distance of the cursor from the left of the
	// html page (the full html document), NOT the left of the visible window
	var evt = e;
	if (!evt) 
		evt = window.event;
	if (evt.pageX) 
		return evt.pageX;
	else if (evt.clientX)
		return evt.clientX + trueBody.scrollLeft;
	else 
		return null;
}
function mouseY(e)
{
	// returns the distance of the cursor from the top of the
	// html page (the full html document), NOT the top of the visible window
	var evt = e;
	if (!evt) 
		evt = window.event;
	var y;
	if (evt.pageY) 
		y = evt.pageY;
	else if (evt.clientY)
		y = evt.clientY + trueBody.scrollTop;
	else 
		y = null;
	return y;
}
function getBrowserScreenHeight()
{
	// height of the visible portion of the window
	if (window.innerHeight)
		var windowHeight = window.innerHeight; 
	else
		var windowHeight = trueBody.clientHeight; 
	return windowHeight;
}
function getBrowserScreenWidth()
{
	// width of the visible portion of the window
	if (window.innerWidth)
		var windowWidth = window.innerWidth; 
	else
		var windowWidth = trueBody.clientWidth; 
	return windowWidth;
}
function getScrollOffsetX()
{
	// return x coord of DSOC, the coordinate in the full html document that displays
	// at the upper left corner of the visible browser window
	var o = document.all ? trueBody.scrollLeft : pageXOffset;
	return o;
}
function getScrollOffsetY()
{
	// return y coord of DSOC, the coordinate in the full html document that displays
	// at the upper left corner of the visible browser window
	var o = document.all ? trueBody.scrollTop : pageYOffset;
	return o;
}


