﻿// tooltip

////////////////////  END OF CUSTOMIZATION AREA  ///////////////////

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
//		Global variables for tooltip. 
//		Set styles
//		Set up mousemove capture if tipFollowMouse set true.
////////////////////////////////////////////////////////////
var tooltip = function()
{

    var origWidth, origHeight;

    // avoid error of passing event object in older browsers
    if (nodyn) { event = "nope" }

    ///////////////////////  CUSTOMIZE HERE   ////////////////////
    // settings for tooltip 
    // Do you want tip to move when mouse moves over link?
    var tipFollowMouse= false;	
    // Be sure to set tipWidth wide enough for widest image
    var offX= -12;	// how far from mouse to show tip
    var offY= -12; 

    // tooltip content goes here (image, description, optional bgColor, optional textcolor)
    var toolTipBody;


    var _tooltip;
    
    function tip() {
	    if (nodyn) return;
		_tooltip = document.createElement('DIV');
		_tooltip.id = 'tipDiv';
	    
	    tipcss = _tooltip.style;
	    if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		    tipcss.height = "10px";
	    }
	    if (_tooltip && tipFollowMouse) {
		    document.onmousemove = trackMouse;
	    }
    }


    /////////////////////////////////////////////////
    //  doTooltip function
    //			Assembles content for tooltip and writes 
    //			it to tipDiv
    /////////////////////////////////////////////////
    var t1,t2;	// for setTimeouts
    var tipOn = false;	// check if over tooltip link
    tip.prototype.showTooltip = function(evt, bodyElement) {
	    if (!_tooltip) return;
	    if (t1) clearTimeout(t1);	
	    if (t2) clearTimeout(t2);
	    tipOn = true;

	    if (ie4||ie5||ns5) 
	    {
	 	    _tooltip.innerHTML = document.getElementById(bodyElement).innerHTML;
	    }
	    if (!tipFollowMouse) 
	        positionTip(evt);
	    else 
	        t1=setTimeout("tipcss.visibility='visible';tipcss.focus();",100);
	        
    }

    var mouseX, mouseY;
    function trackMouse(evt) {
	    standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes
	    mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	    mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	    if (tipOn) 
	        positionTip(evt);
    }

    /////////////////////////////////////////////////////////////
    //  positionTip function
    //		If tipFollowMouse set false, so trackMouse function
    //		not being used, get position of mouseover event.
    //		Calculations use mouseover event position, 
    //		offset amounts and tooltip width to position
    //		tooltip within window.
    /////////////////////////////////////////////////////////////
    function positionTip(evt) {
	    if (!tipFollowMouse) {
		    standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		    mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
		    mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	    }
	    // tooltip width and height
	    var tpWd = 400;//(ie4||ie5)? _tooltip.clientWidth: _tooltip.offsetWidth;
	    var tpHt = 300;//(ie4||ie5)? _tooltip.clientHeight: _tooltip.offsetHeight;
	    // document area in view (subtract scrollbar width for ns)
	    var winWd = _winWidth() + _scrollX();
	    var winHt = _winHeight() + _scrollY();
	    
	    // check mouse position against tip and window dimensions
	    // and position the tooltip 
	    if ((mouseX+offX+tpWd)>winWd) 
		    tipcss.left = mouseX-(tpWd+offX)+"px";
	    else tipcss.left = mouseX+offX+"px";
	    if ((mouseY+offY+tpHt)>winHt) 
		    tipcss.top = winHt-(tpHt+offY)+"px";
	    else tipcss.top = mouseY+offY+"px";
	    if (!tipFollowMouse) t1= setTimeout("tipcss.visibility='visible';",100);
    }

    tip.prototype.hideTip = function() {
	    if (!_tooltip) return;
	    t2 = setTimeout("tipcss.visibility='hidden'",100);
	    tipOn = false;
    }
    return {tip:tip}
}();

var _tooltip, tipcss;
addListener(this, "load", function() { _tooltip = new tooltip.tip(); });

