var tipWidth = 160;
var offX = 20;
var offY = 30; 
//var tipBgColor = "#EFEFEF"; 
var tipBgColor = "#f0f0f8"; 
var tipBorderColor =  "#CCCCDD";
var tipBorderWidth = 1;
var tipBorderStyle = "ridge";
var tipPadding = 4;

// var startStr = '<table><tr><td><h4>';
// var midStr = '</h4></td></tr><tr><td>';
// var endStr = '</td></tr></table>';

var DHTML = 0, DOM = 0, MS = 0, NS = 0, OPERA = 0, GECKO = 0;

////////////////////////////////////////////////////////////
//  initTip	- initialization for tooltip.
////////////////////////////////////////////////////////////
var tooltip, tipcss;
function initTip() {
	if(window.opera) OPERA = 1;
	if(document.getElementById) { DHTML = 1; DOM = 1; }
	if(document.all && !OPERA) { DHTML = 1; MS = 1; }
	if(document.layers) { DHTML = 1; NS = 1; }
	if(navigator.userAgent.indexOf("Mozilla") >= 0) {
		if(navigator.userAgent.indexOf("Gecko") >= 0) GECKO = 1;
		else if(navigator.userAgent.indexOf("MSIE") >= 0) MS = 1;
	}

	tooltip = document.getElementById("tipDiv");
	tipcss = tooltip.style;
	tipcss.backgroundColor = tipBgColor;
	tipcss.borderColor = tipBorderColor;
	tipcss.borderWidth = tipBorderWidth+"px";
	tipcss.padding = tipPadding+"px";
	tipcss.borderStyle = tipBorderStyle;
	if (tooltip) {
		if (DOM && !MS) document.addEventListener("mousemove", trackMouse, true);
		else if (MS) document.onmousemove = trackMouse;
		else {
			document.captureEvents(Event.MOUSEMOVE);
			document.onmousemove = trackMouse;
		}
	}
}

//window.onLoad = initTip;

////////////////////////////////////////////////////////////
//  doTooltip function
////////////////////////////////////////////////////////////
var t1,t2;				// for setTimeouts
var tipOn = false;		// check if over tooltip link
function doTooltip(num) {
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	
  	if (t2) clearTimeout(t2); 

	tipOn = true;
 	//tooltip.innerHTML = startStr + messages[num][0] + midStr + messages[num][1] + endStr;
 	tooltip.innerHTML = messages[num][0]; // show only name...
	positionTip();
}

var mouseX, mouseY;
function trackMouse(Ereignis) {
	mouseX = (NS||GECKO)? Ereignis.pageX: window.event.clientX + document.body.scrollLeft;
	mouseY = (NS||GECKO)? Ereignis.pageY: window.event.clientY + document.body.scrollTop;
	if (tipOn) positionTip();
}

////////////////////////////////////////////////////////////
//  positionTip function
/////////////////////////////////////////////////////////////
function positionTip() {
	var tpWd = (MS)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (MS)? tooltip.clientHeight: tooltip.offsetHeight;
	var winWd = (NS||GECKO)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth;
	var winHt = (NS||GECKO)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight;
	//tooltip width not bigger than window width
	if (tpWd > winWd) tipcss.width = (winWd-offX)+"px";
	// check mouse position against tip and window dimensions and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) tipcss.left = (winWd-tpWd)+"px";
	else tipcss.left = mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) tipcss.top = (winHt-tpHt)+"px";
	else tipcss.top = mouseY+offY+"px";
	tipcss.visibility="visible";
}

function hideTip() {
	if (!tooltip) return;
    if (t1) clearTimeout(t1);	
  	if (t2) clearTimeout(t2); 
    t2 = setTimeout("document.getElementById('tipDiv').style.visibility = 'hidden'",100);
	tipOn = false;
}