var IE = document.all ? true : false;
if (!IE) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = getMouseXY;

var tempX = 0;
var tempY = 0;

var fMin = 0;
var fMax = 99;

function getMouseXY(e) {
  if (IE) { 
    tempX = event.clientX;
	tempY = event.clientY;
	if(document.body) {
		tempX += document.body.scrollLeft;
		tempY += document.body.scrollTop;
	}
  } else {  
    tempX = e.pageX
    tempY = e.pageY
  }  

  if (tempX < 0) tempX = 0;
  if (tempY < 0) tempY = 0;  

  return true;
}

function showHint(text) {
	var hint = document.getElementById('hintDiv');
	if ((hint.animation == false) || (!hint.animation)) fadeIn('hintDiv');

	hint.animation = true;
	hint.innerHTML = text;

	hint.style.display = 'block';
	hint.style.left = (tempX + 4 - Math.round(hint.offsetWidth / 2))+'px';
	hint.style.top = (tempY + 20)+'px';
}

function hideHint() {
	var hint = document.getElementById('hintDiv');
	hint.style.left = '0px';
	hint.style.top = '0px';
	hint.style.display = 'none';
	hint.animation = false;
}

function fadeIn(id) {
	var e = document.getElementById(id);
	if (e.fade) window.clearInterval(e.fade);

	e.alpha = fMin;
	e.style.opacity = '0.'+e.alpha;
	e.style.filter = 'alpha(opacity='+e.alpha+')';		

	e.fade = window.setInterval(
		function() {
			e.alpha += 10;
			e.style.opacity = '0.'+e.alpha;
			e.style.filter = 'alpha(opacity='+e.alpha+')';	
			if (e.alpha >= fMax) {
				e.style.opacity = '0.'+fMax;
				e.style.filter = 'alpha(opacity='+fMax+')';
				window.clearInterval(e.fade);
			}
		}, 20);
}
