﻿/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var toolTipOffsetXPoint = 0 //Customize x offset of tooltip
var toolTipOffsetYPoint = 20 //Customize y offset of tooltip
var toolTipIE = document.all
var toolTipNS6 = document.getElementById && !document.all
var enableToolTip = false
if (toolTipIE || toolTipNS6)
var toolTipObj = document.all? document.all["divToolTip"] : document.getElementById? document.getElementById("divToolTip") : ""

function ietruebody() {
	return (document.compatMode && document.compatMode !== "BackCompat") ? document.documentElement : document.body
}

function showToolTip(thetext, thecolor, thewidth) {
    initiateToolTip();
	if (toolTipNS6 || toolTipIE) {
		if (typeof thewidth !== "undefined") toolTipObj.style.width = thewidth + "px"
		if (typeof thecolor !== "undefined" && thecolor !== "") toolTipObj.style.backgroundColor = thecolor
		toolTipObj.innerHTML = thetext
		enableToolTip = true
		return false
	}
}

function positionToolTip(e) {
    initiateToolTip();
	if (enableToolTip) {
		var curX = (toolTipNS6) ? e.pageX : event.clientX + ietruebody().scrollLeft;
		var curY = (toolTipNS6) ? e.pageY : event.clientY + ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge = toolTipIE && !window.opera ? ietruebody().clientWidth - event.clientX - toolTipOffsetXPoint : window.innerWidth - e.clientX - toolTipOffsetXPoint - 20
		var bottomedge = toolTipIE && !window.opera ? ietruebody().clientHeight - event.clientY - toolTipOffsetYPoint : window.innerHeight - e.clientY - toolTipOffsetYPoint - 20

		var leftedge = (toolTipOffsetXPoint < 0) ? toolTipOffsetXPoint * (-1) : -1000

		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge < toolTipObj.offsetWidth)
			//move the horizontal position of the menu to the left by it's width
			toolTipObj.style.left = toolTipIE ? ietruebody().scrollLeft + event.clientX - toolTipObj.offsetWidth + "px" : window.pageXOffset + e.clientX - toolTipObj.offsetWidth + "px"
		else if (curX < leftedge)
			toolTipObj.style.left = "5px"
		else
			//position the horizontal position of the menu where the mouse is positioned
			toolTipObj.style.left = curX + toolTipOffsetXPoint + "px"

		//same concept with the vertical position
		if (bottomedge < toolTipObj.offsetHeight)
			toolTipObj.style.top = toolTipIE ? ietruebody().scrollTop + event.clientY - toolTipObj.offsetHeight - toolTipOffsetYPoint + "px" : window.pageYOffset + e.clientY - toolTipObj.offsetHeight - toolTipOffsetYPoint + "px"
		else
			toolTipObj.style.top = curY + toolTipOffsetYPoint + "px"
			toolTipObj.style.visibility = "visible"
	}
}

function hideToolTip() {
    initiateToolTip();
	if (toolTipNS6 || toolTipIE) {
		enableToolTip = false
		toolTipObj.style.visibility = "hidden"
		toolTipObj.style.left = "-1000px"
		toolTipObj.style.backgroundColor = ''
		toolTipObj.style.width = ''
	}
}

function initiateToolTip () {

    if (typeof toolTipObj == "undefined" || toolTipObj == null) {
        toolTipObj = document.all? document.all["divToolTip"] : document.getElementById? document.getElementById("divToolTip") : ""
    }

}

document.onmousemove = positionToolTip
/***********************************************
* End Cool DHTML Script
***********************************************/