function getMouseXY(e) 
{
  // browser specific 
  if(window.ActiveXObject)
  {
    var mouseX = window.event.x + document.body.scrollLeft;
    var mouseY = window.event.y + document.body.scrollTop;    
  }
  else
  {
    var mouseX = e.pageX;
    var mouseY = e.pageY;
  }
  var result = [mouseX, mouseY];
  return result; 
}

function hint_move(e)
{
	var interval = 10;

	var pos = getMouseXY(e);
	var mx = pos[0];
	var my = pos[1];

	var hintDiv = document.getElementById('hint');
	var container = document.getElementById('container');


	if (mx + hintDiv.offsetWidth + interval >= container.offsetWidth) {
		hintDiv.style.left = (mx - hintDiv.offsetWidth - interval) +'px';
	} else {
		hintDiv.style.left = (mx + interval) +'px';
	}

	if (my + hintDiv.offsetHeight + interval >= container.offsetHeight) {
		hintDiv.style.top = (my - hintDiv.offsetHeight - interval) +'px';
	} else {
		hintDiv.style.top = (my + interval) +'px';
	}
}

function hint_show(e, text, width, height)
{
	var hintDiv = document.getElementById('hint');

	if (typeof width != "undefined") {
		hintDiv.style.width = width + "px";
	}
	if (typeof height != "undefined") {
		hintDiv.style.height = height + "px";
	}

	hintDiv.innerHTML = text;
	hint_move(e);
	hintDiv.style.visibility = 'visible';
}

function hint_hide()
{
	var hintDiv = document.getElementById('hint');
	hintDiv.style.visibility = 'hidden';
}


