function isIE() {
	var browserName=navigator.appName; 
	if (browserName=="Microsoft Internet Explorer") return true;
	else false;
}

function createTooltip() {
	if  (document.getElementById("tooltip") == null) {
		var div = document.createElement("div");
		
		if (isIE()) {
			div.setAttribute('id', 'tooltip');
			div.setAttribute('className', 'tooltip');
		} else {
			div.setAttribute('id', 'tooltip');
			div.setAttribute('class', 'tooltip');
		}
		document.getElementById("MainText").appendChild(div);
	}
}

function showTooltip() {
	createTooltip();
	wmtt = document.getElementById("tooltip");
	wmtt.style.display = "block";
	
	var value = "";
	for (var i = 0; i < showTooltip.arguments.length; ++i) {
		value += showTooltip.arguments[i];
		value += "<br>";
	}

	if (showTooltip.arguments.length > 0) wmtt.innerHTML = value;
}

function toggleTooltip() {
	wmtt = document.getElementById("tooltip");
	if (wmtt != null) {
		hideTooltip();
		return false;
	} else {
		showTooltip();
		return true;
	}
}

function isTooltip() {
	wmtt = document.getElementById("tooltip");
	if (wmtt == null) return false;
	else true;
}

function updateTooltip(e) {
	if (!e) e = window.event;
	wmtt = document.getElementById("tooltip");
	if (wmtt == null) {
		createTooltip();
		return;
	}
	
	if (isIE()) {
		wmtt.style.left  =  e.x + 10;
		wmtt.style.top  = e.y + 10;
	} else {
		wmtt.style.top  = e.layerY + 10;
		wmtt.style.left  = e.layerX + 10;
	}
	
	var innerHeight = window.innerHeight;
	var tooltipHeight = wmtt.offsetHeight;
	var tooltipBottom = parseInt(wmtt.style.top) + tooltipHeight;

	if (tooltipBottom > innerHeight) wmtt.style.top = parseInt(wmtt.style.top) - (tooltipBottom - innerHeight);
	if (parseInt(wmtt.style.top) < 0) wmtt.style.top = 0;
}

function hideTooltip() {
	wmtt = document.getElementById("tooltip");
	if (wmtt != null) wmtt.parentNode.removeChild(wmtt);//wmtt.style.display = "none";
	document.onmousemove=null;
}

function toggleDisplay(id) {
	var element = document.getElementById(id);
	
	if (element.style.display == "none") element.style.display = "block";
	else element.style.display = "none";
}