var pop = document.getElementById('popup');

var xoffset = -200;
var yoffset = -40;

var IE = document.all?true:false

if (!IE) document.captureEvents(Event.MOUSEMOVE)

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}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  document.Show.MouseX.value = tempX
  document.Show.MouseY.value = tempY
  return true
}

document.onmousemove = function(e) {
  var x, y, right, bottom;
  
/*  try { x = e.pageX; y = e.pageY; } // FF
  catch(e) { x = event.x; y = event.y; } // IE
  */
  if (IE) { // grab the x-y pos.s if browser is IE
    x = event.clientX + document.body.scrollLeft
    y = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    x = e.pageX
    y = e.pageY
  }  

  right = (document.documentElement.clientWidth || document.body.clientWidth || document.body.scrollWidth);
  bottom = (window.scrollY || document.documentElement.scrollTop || document.body.scrollTop) + (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight || document.body.scrollHeight);

  x += xoffset;
  y += yoffset;

//  if(x > right-pop.offsetWidth)
//    x = right-pop.offsetWidth;
 
//  if(y > bottom-pop.offsetHeight)
//    y = bottom-pop.offsetHeight;
  
  pop.style.top = y+'px';
  pop.style.left = x+'px';

}

function popup(text) {
  pop.innerHTML = text;
  pop.style.display = 'block';
}

function popout() {
  pop.style.display = 'none';
}
