// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

// Temporary variables to hold mouse x-y pos.s
var tempX = 0;
var tempY = 0;

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft;
    tempY = event.clientY + document.body.scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }
  // catch possible negative values in NS4
  if (tempX < 0) {
	  tempX = 0;
	}
  if (tempY < 0){
	  tempY = 0;
	}
	// Success
  return true;
}

var baseopacity=0

function showtext(thetext) {
	if (!document.getElementById) {
		return;
	}
	document.getElementById("help_content").innerHTML=thetext;
	// Get the text container
	textcontainerobj = document.getElementById("help_description");
	// Show the div
	textcontainerobj.style.display = "block";
	
	text_height = document.getElementById("help_description").offsetHeight;
	// Position the text container div
	textcontainerobj.style.left = tempX + 16;
	textcontainerobj.style.top = tempY - (text_height/2);
	// Set the position of the pointer
	document.getElementById("help_pointer").style.top = (text_height/2) - 9;
	// Do other stuff
	browserdetect=textcontainerobj.filters? "ie" : typeof textcontainerobj.style.MozOpacity=="string"? "mozilla" : "";
	instantset(baseopacity);
	highlighting = setInterval("gradualfade(textcontainerobj)",50);
}

function hidetext() {
	cleartimer();
	instantset(baseopacity);
	textcontainerobj = document.getElementById("help_description");
	textcontainerobj.style.display = "none";
}

function instantset(degree) {
	if (browserdetect=="mozilla") {
		textcontainerobj.style.opacity = degree/100;
	}	else if (browserdetect=="ie") {
		textcontainerobj.filters.alpha.opacity=degree;
	}
}

function cleartimer() {
	if (window.highlighting) {
		clearInterval(highlighting);
	}
}

function gradualfade(cur2) {
	if (browserdetect=="mozilla" && cur2.style.MozOpacity<1) {
		cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.2, 0.99);
	}	else if (browserdetect=="ie" && cur2.filters.alpha.opacity < 100) {
		cur2.filters.alpha.opacity+=20;
	}	else if (window.highlighting) {
		clearInterval(highlighting);
	}
}

