
var popup = null;
var mouse_x, mouse_y;
var scroll_x, scroll_y;


if (document.layers) {
  // Netscape special handling
  document.captureEvents(Event.MOUSEMOVE);
}
document.onmousemove = mouse_handler;


function mouse_handler(e)
{
  var e = (e) ? e : event;
  
  if (e.pageX) {
    mouse_x = e.pageX;
    mouse_y = e.pageY;
    scroll_x = window.pageXOffset;
    scroll_y = window.pageYOffset;
    if ((!document.documentElement) && (popup)) {
      if ((mouse_x < popup.style.left) || (mouse_x > popup.style.left + popup.style.offsetWidth) ||
          (mouse_y < popup.style.top) || (mouse_y > popup.style.top + popup.style.offsetHeight)) {
        out();
      }
    }
  }
  else if (e.clientX) {
    if (document.compatMode == "CSS1Compat") {
      scroll_x = document.body.parentNode.scrollLeft;
      scroll_y = document.body.parentNode.scrollTop;
    }
    else {
      scroll_x = document.body.scrollLeft;
      scroll_y = document.body.scrollTop;
    }
    mouse_x = e.clientX + scroll_x;
    mouse_y = e.clientY + scroll_y;
  }
}


function over(text, do_popup, do_status)
{
  var range, x, y;
  var width, width_fix = 16, height, height_fix = 8;
  
  if (typeof(window.innerWidth) == 'number') {
    // Non-IE
    width = window.innerWidth;
    height = window.innerHeight;
    width_fix = Math.ceil(3.5 * (window.outerWidth - window.innerWidth));
  }
  else if (document.documentElement &&
      (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    // IE 6+ in 'standards compliant mode'
    width = document.documentElement.clientWidth;
    height = document.documentElement.clientHeight;
  }
  else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
    // IE 4 compatible
    width = document.body.clientWidth;
    height = document.body.clientHeight;
  }

  if (do_popup) {
    if (!popup) {
      popup = document.getElementById("popup");
      if (typeof popup.innerHTML != 'undefined') {
        popup.innerHTML = '';
        popup.innerHTML = text;
      }
      else {
        range = document.createRange();
        range.setStartAfter(popup);
        fragment = range.createContextualFragment(text);
        while (popup.hasChildNodes()) {
          popup.removeChild(popup.lastChild);
        }
        popup.appendChild(fragment);
      }
    }
    
    x = mouse_x + 16;
    if (x + popup.offsetWidth > scroll_x + width - width_fix)
      x = scroll_x + width - popup.offsetWidth - width_fix;
    y = mouse_y + 16;
    if (y + popup.offsetHeight > scroll_y + height - height_fix)
      y = mouse_y - 28;
    
    popup.style.position = "absolute";
    popup.style.left = x + "px";
    popup.style.top = y + "px";
    popup.style.visibility = "visible";
    popup.style.display = "block";
  }
  if (do_status) {
    window.status = text;
  }
  return true;
}


function out()
{
  if (popup)
    popup.style.visibility = "hidden";
  window.status = "";
  popup = null;
  return true;
}


function jump_on_select(select_object)
{
  eval("location.href='" + select_object.options[select_object.selectedIndex].value + "'");
}
