﻿<!-- Begin to hide script contents from old browsers.

var g_tooltip_elm = null;
var g_tooltip_showing = 0;
var g_tooltip_link_elm = null;
var g_tooltip_previous_click = null;
var g_tip_elm = null;

function InitTooltip(className) {
  if ( !g_tooltip_elm ) {
    g_tooltip_elm = document.createElement('DIV');
    g_tooltip_elm.className = className;
    g_tooltip_elm.style.display = 'none';
    document.body.appendChild(g_tooltip_elm);
  } else {
    g_tooltip_elm.className = className;
  }
}

function ShowTooltip(link, text, className, width, xOffset, yOffset) {

    InitTooltip(className);
	if (g_tooltip_showing) {
		if (g_tooltip_link_elm == link){
			HideTooltip();
			return;
		}
		HideTooltip();
	}

	var x = TooltipFindPosX(link);
	var y = TooltipFindPosY(link);

    g_tooltip_elm.style.width = width+'px';
	g_tooltip_elm.style.left = (x+xOffset)+'px';
	g_tooltip_elm.style.top = (y+yOffset)+'px';

	g_tip_elm = document.getElementById(text);
	if (g_tip_elm) {
	    MoveChildren(g_tip_elm, g_tooltip_elm);

	    g_tooltip_showing = 1;
	    g_tooltip_elm.style.display = 'block';
	    g_tooltip_link_elm = link;

	    document.onmousedown = TooltipMousedown;
        HideShowCovered( g_tooltip_elm );
    }
}

function TooltipMousedown(e){
	if (GetEventSrc(e) == g_tooltip_link_elm) {
		document.onmousedown = function(){};
	} else{
		HideTooltip();
	}
}

function HideTooltip() {

	document.onmousedown = function(){};

	if (!g_tooltip_elm){
		return false;
	}

	g_tooltip_showing = 0;
	g_tooltip_elm.style.display = 'none';
	g_tooltip_link_elm = 'null';

	MoveChildren(g_tooltip_elm, g_tip_elm);

  HideShowCovered( g_tooltip_elm );

	return false
}

function MoveChildren(e_from, e_to) {
	while(e_from.childNodes.length){
		e_to.appendChild(e_from.removeChild(e_from.childNodes[0]));
	}
}

// findPosX & findPosY courtesy PPK
// http://www.quirksmode.org/js/findpos.html

function TooltipFindPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) curleft += obj.x;
	return curleft;
}

function TooltipFindPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) curtop += obj.y;
	return curtop;
}

// End the hiding here. -->
