/// <summary>
///  Custom Global variables
/// </summary>

var ToolTipOnMouseOverDelay = 500;
var ToolTipOffsetX = 10;
var ToolTipOffsetY = 10;

/// <summary>
///  This function displays a help information message tooltip.
///  Significant portions of this code are based on Zorn, W. (2005), "wz_tooltip.js v. 3.37", www.walterzorn.com [http://www.walterzorn.com/tooltip/tooltip_e.htm] cited below
///
///  wz_tooltip.js    v. 3.37
///  The latest version is available at http://www.walterzorn.com or http://www.devira.com or http://www.walterzorn.de
///  Copyright (c) 2002-2005 Walter Zorn. All rights reserved.
///  Created 1.12.2002 by Walter Zorn (Web: http://www.walterzorn.com)
///  Last modified: 2.12.2005
///  Cross-browser tooltips working even in Opera 5 and 6, as well as in NN 4, Gecko-Browsers, IE4+, Opera 7 and Konqueror. No onmouseouts required. Appearance of tooltips can be individually configured via commands within the onmouseovers.
///  LICENSE: LGPL
///  This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.
///  This library 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.
///  For more details on the GNU Lesser General Public License, see http://www.gnu.org/copyleft/lesser.html
/// </summary>

function SetGlobalVariables ()
{
	try
	{
		if (typeof(GlobalVariablesSet) == "undefined")
		{
			GlobalVariablesSet = true;
			Opera = !!(window.opera && document.getElementById);
			Opera6 = Opera && !document.defaultView;
			Opera7 = Opera && !Opera6;
			InternetExplorer = navigator.userAgent.toLowerCase().indexOf("msie") != -1 && document.all && ((document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body? document.body : null) && !Opera;
			InternetExplorer6 = InternetExplorer && parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf("MSIE")+5)) >= 5.5;
			NetscapeNavigator4 = (document.layers && typeof document.classes != "undefined");
			NetscapeNavigator6 = (!Opera && document.defaultView && typeof document.defaultView.getComputedStyle != "undefined");
			W3CCompliant = !InternetExplorer && !NetscapeNavigator6 && !Opera && document.getElementById;
			DocumentBody = (((document.compatMode) && (document.compatMode != "BackCompat")) ? document.documentElement : ((document.body) ? document.body : null));
			PixelSuffix = (Opera6 || NetscapeNavigator4) ? "" : "px";
			ToolTipOnMouseOverHTML = "ToolTip(event,this);";
			ToolTipInterval = null;
			ToolTipLastId = 0;
		}
	}
	catch (ExceptionObject)
	{
		alert(ExceptionObject.name + "\n\n" + ExceptionObject.number + "\n\n" + ExceptionObject.message + "\n\n" + ExceptionObject.description);
	}
}

function SetVisibility (Tag, Visible)
{
	if (NetscapeNavigator4)
	{
		Tag.visibility = (Visible ? "show" : "hide");
	}
	else
	{
		Tag.style.visibility = (Visible ? "visible" : "hidden");
		if (InternetExplorer6 && (typeof(ToolTipInternetExplorer6OverrideTag) != "undefined"))
		{
			ToolTipInternetExplorer6OverrideTag.style.display = (Visible ? "block" : "none");
		}	
	}
}

function SetPositionToCursor (Tag, TagEvent)
{
	var TagInstance;
	var TagWidth;
	var TagHeight;
	var TagX;
	var TagY;
	var MaximumTagX;
	var MinimumTagY;
	var MinimumTagX;
	var MinimumScrollableTagY;
	
	TagEvent = (TagEvent || window.event);
	TagInstance = (Tag.style || Tag);
	if (TagInstance)
	{
		if (window.dd && dd.z)
		{
			TagInstance.zIndex = Math.max((dd.z + 1), TagInstance.zIndex);
		}
	}
	TagWidth = GetWidth(Tag);
	TagX = ParseInteger(TagEvent.pageX || TagEvent.clientX || 0) + ParseInteger(InternetExplorer ? DocumentBody.scrollLeft : 0) + ToolTipOffsetX;
	MaximumTagX = ParseInteger((DocumentBody && DocumentBody.clientWidth) ? DocumentBody.clientWidth : window.innerWidth) + ParseInteger(window.pageXOffset || (DocumentBody ? DocumentBody.scrollLeft : 0) || 0) - TagWidth - (NetscapeNavigator4 ? 21 : 0);
	if (TagX > MaximumTagX)
	{
		TagX = MaximumTagX;
	}
	MinimumTagX = ParseInteger(window.pageXOffset || (DocumentBody ? DocumentBody.scrollLeft : 0) || 0);
	if (TagX < MinimumTagX)
	{
		TagX = MinimumTagX;
	}
	TagHeight = GetHeight(Tag);
	TagY = ParseInteger(TagEvent.pageY || TagEvent.clientY || 0) + ParseInteger(InternetExplorer ? DocumentBody.scrollTop : 0);
	MaximumTagY = ParseInteger(window.innerHeight || DocumentBody.clientHeight) + ParseInteger(window.pageYOffset || (DocumentBody ? DocumentBody.scrollTop : 0) || 0) - TagHeight - ToolTipOffsetY;
	if (TagY > MaximumTagY)
	{
		TagY -= (TagHeight + 5);
	}
	else
	{
		TagY += ToolTipOffsetY;
	}
	TagInstance.left = TagX + PixelSuffix;
	TagInstance.top = TagY + PixelSuffix;
	if (InternetExplorer6 && (typeof(ToolTipInternetExplorer6OverrideTag) != "undefined"))
	{
		ToolTipInternetExplorer6OverrideTag.style.width = TagWidth + PixelSuffix;
		ToolTipInternetExplorer6OverrideTag.style.height = TagHeight + PixelSuffix;
		ToolTipInternetExplorer6OverrideTag.style.left = TagX + PixelSuffix;
		ToolTipInternetExplorer6OverrideTag.style.top = TagY + PixelSuffix;
	}
}

function ShowToolTip (ToolTipTagId)
{
	var ToolTipTag;
	try
	{
		ToolTipTag = GetElement(ToolTipTagId);
		SetVisibility(ToolTipTag, true);
		window.clearTimeout(ToolTipInterval);
		ToolTipInterval = null;
	}
	catch (ExceptionObject)
	{
		alert(ExceptionObject.name + "\n\n" + ExceptionObject.number + "\n\n" + ExceptionObject.message + "\n\n" + ExceptionObject.description);
	}
}

function HideToolTip (ToolTipTagId)
{
	var ToolTipTag;
	try
	{
		ToolTipTag = GetElement(ToolTipTagId);
		SetVisibility(ToolTipTag, false);
		window.clearTimeout(ToolTipInterval);
		ToolTipInterval = null;
	}
	catch (ExceptionObject)
	{
		alert(ExceptionObject.name + "\n\n" + ExceptionObject.number + "\n\n" + ExceptionObject.message + "\n\n" + ExceptionObject.description);
	}
}

function RequestShowToolTip (ToolTipEvent, ToolTipTagId)
{
	var ToolTipTag;
	try
	{
		if (ToolTipInterval != null)
		{
			window.clearTimeout(ToolTipInterval);
		}
		ToolTipTag = GetElement(ToolTipTagId);
		SetPositionToCursor(ToolTipTag, ToolTipEvent);
		ToolTipInterval = window.setTimeout(("ShowToolTip(\"" + ToolTipTagId + "\");"), ToolTipOnMouseOverDelay);
	}
	catch (ExceptionObject)
	{
		alert(ExceptionObject.name + "\n\n" + ExceptionObject.number + "\n\n" + ExceptionObject.message + "\n\n" + ExceptionObject.description);
	}
}

function ToolTip (ToolTipEvent, Tag)
{
	var TagOnMouseOverHTML;
	var ToolTipId;
	var ToolTipTag;
	var ToolTipTagId;
	
	SetGlobalVariables();

	try
	{
		if (Opera || NetscapeNavigator4 || NetscapeNavigator6 || InternetExplorer || W3CCompliant)
		{
			if (NetscapeNavigator6)
			{
				TagOnMouseOverHTML = Tag.getAttribute("onmouseover");
			}
			else
			{
				if (typeof(Tag.onmouseover) == "function")
				{
					TagOnMouseOverHTML = Tag.onmouseover.toString();
				}
				else
				{
					TagOnMouseOverHTML = "";
				}
			}
			if (TagOnMouseOverHTML.indexOf(ToolTipOnMouseOverHTML) != -1)
			{
				if (InternetExplorer6 && (typeof(ToolTipInternetExplorer6OverrideTag) == "undefined"))
				{
					ToolTipInternetExplorer6OverrideTag = document.createElement("iframe");
					ToolTipInternetExplorer6OverrideTag.id = "ToolTip";
					ToolTipInternetExplorer6OverrideTag.src = "javascript:false";
					ToolTipInternetExplorer6OverrideTag.scrolling = "no";
					ToolTipInternetExplorer6OverrideTag.frameborder = "0";
					ToolTipInternetExplorer6OverrideTag.className = "ToolTip";
					document.body.insertBefore(ToolTipInternetExplorer6OverrideTag, null);
				}
				if (NetscapeNavigator6)
				{
					Tag.onmouseover = new Function(Tag.getAttribute("onmouseover"));
				}
				ToolTipTag = document.createElement("div");
				ToolTipId = ++ToolTipLastId;
				ToolTipTagId = "ToolTip" + ToolTipId;
				ToolTipTag.id = ToolTipTagId;
				ToolTipTag.innerHTML = Tag.title;
				ToolTipTag.className = "ToolTip";
				ToolTipTag.style.visibility = "hidden";
				ToolTipTag.style.position = "absolute";
				document.body.insertBefore(ToolTipTag, null);
				Tag.onmouseover = new Function("ToolTipEvent","RequestShowToolTip(ToolTipEvent, \"" + ToolTipTagId + "\");");
				Tag.onmouseout = new Function("HideToolTip(\"" + ToolTipTagId + "\");");
				if (Tag.alt)
				{
					Tag.alt = "";
				}
				if (Tag.title)
				{
					Tag.title = "";
				}
				RequestShowToolTip(ToolTipEvent, ToolTipTagId);
			}
		}
	}
	catch (ExceptionObject)
	{
		alert(ExceptionObject.name + "\n\n" + ExceptionObject.number + "\n\n" + ExceptionObject.message + "\n\n" + ExceptionObject.description);
	}
}