// JavaScript Document

var linkid = 0;
var windowWidth = 0
var windowHeight = 0;
var tooltipwidth = 0;
var x = 0
var y = 0;
var toolTipState = 'off';

function windowSize() {
	if (typeof(window.innerWidth) == 'number') {
		//Non-IE
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
}

function getMousePosition(e) {
	return e.pageX ? {'x':e.pageX, 'y':e.pageY} : {'x':e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft, 'y':e.clientY + document.documentElement.scrollTop + document.body.scrollTop};
}

function showMousePos(e) {
	if (!e) e = event; // make sure we have a reference to the event
	var mp = getMousePosition(e);
	x = mp.x;
	y = mp.y;
}

function showtooltip(p_tiptext) {
	document.onmousemove = showMousePos;
	tooltipwidth = document.getElementById("tooltip").offsetWidth;
	
	if (document.getElementById("tooltip")) {
		if ((windowWidth - x) < (tooltipwidth + 10)) {
			if(toolTipState == 'off'){
				//document.getElementById("tooltip").innerHTML = "<img src=\"images/tooltip-marker-flip.gif\" alt=\"\" class=\"tooltipflip\" />" + p_tiptext;
				document.getElementById("tooltip").innerHTML = p_tiptext;
			}
			document.getElementById("tooltip").style.left = (x - tooltipwidth - 10)+"px";
			document.getElementById("tooltip").style.top = (y + 28)+"px";
		} else {
			if(toolTipState == 'off'){
				//document.getElementById("tooltip").innerHTML = "<img src=\"images/tooltip-marker.gif\" alt=\"\" class=\"tooltipflip\" />" + p_tiptext;
				document.getElementById("tooltip").innerHTML = p_tiptext;
			}
			document.getElementById("tooltip").style.left = (x + 10)+"px";
			document.getElementById("tooltip").style.top = (y + 28)+"px";
		}
		document.getElementById("tooltip").style.display = "block";
		toolTipState = 'on';
	}
}

function hidetooltip() {
	//document.onmousemove = null;
	if (document.getElementById("tooltip")) {
		document.getElementById("tooltip").style.display = "none";
		toolTipState = 'off';
	}
}
