var menuTimerID = null;
var mouseOverTimerID = null;
var infoDiv = null;
var boxNum = '';
var boxHolder = '';
var boxName = '';
var infoVisible = false;
//document.onMouseMove = trackMouse;
onload = init;
function init()
{
  infoDiv = createInfoBox("infobox");
  document.body.appendChild(infoDiv);
  a = document.getElementsByTagName("area");
  alen = a.length;
  for (i = 0;i < alen; i++)
  {
    if (a[i].getAttribute("alt")) a[i].removeAttribute("alt");
  }
}
function trackMouse(e)
{
//  if(!infoVisible) return;
//alert("zzz");
  om = infoDiv;
  if (window.event)
  {
  om.style.left = parseInt(window.event.clientX) + parseInt(document.body.scrollLeft) + 8 + "px";
  om.style.top  = parseInt(window.event.clientY) + parseInt(document.body.scrollTop) + 8 + "px";
  }
  else
  {
  om.style.left = parseInt(e.pageX) + 8 + "px";
  om.style.top  = parseInt(e.pageY) + 8 + "px";
  }

}
function createInfoBox(divName)
{
  obj = document.createElement("div");
  obj.id = divName;
  return obj;
}

function displayInfo()
{
  mouseOverTimerID = null;
  infoDiv.innerHTML = createInfoText();
  if (infoDiv.style.visibility != "visible")
  {
    infoDiv.style.visibility = "visible";
  }
//  alert('displayInfo()');
}

function showInfo(num,holder,name)
{
  if (infoDiv == null) return;
//  var om = infoDiv;

//  alert("here");
//  t = window.event ? window.event.srcElement : evt.currentTarget;
//  if (t.getAttribute("alt")) t.removeAttribute("alt");
//  calcPosition(om,evt,up)

  boxNum = num;
  boxHolder = holder;
  boxName = name;
//  alert("zzz");
//  if (menuTimerID != null) {
//    window.clearTimeout(menuTimerID);
//    menuTimerID = null;
//  }
//  om.onmouseover = infoOver;
//  om.onmouseout = infoOut;
//  if (om.style.visibility == "hidden")
//  {
//    om.style.visibility = "visible";
//    infoDiv = om;
    mouseOverTimerID = window.setTimeout("displayInfo()",300);
    document.onmousemove = trackMouse;
    window.onscroll = hideInfo;
//  }
}

function infoOut()
{
  if (mouseOverTimerID != null)
  {
    window.clearTimeout(mouseOverTimerID);
    mouseOverTimerID = null;
//    infoDiv = null;
  }
  else
    menuTimerID = window.setTimeout("hideInfo()", 200 );
}

function infoOver(o)
{
  if (menuTimerID!=null)
  {
    window.clearTimeout(menuTimerID);
    menuTimerID = null;
  }
}

function hideInfo()
{
  if (mouseOverTimerID != null)
  {
    window.clearTimeout(mouseOverTimerID);
    mouseOverTimerID = null;
  }
  if (infoDiv == null) return;
  infoDiv.style.visibility = "hidden";
  infoDiv.style.left = "0";
  infoDiv.style.top = "0";
  document.onmousemove = null;
  window.onscroll = null;
//  infoDiv = null;
}
function createInfoText()
{
  var infohtml = "";
  infohtml += boxNum + "<br/>";
  infohtml += "<b>" + boxHolder + "</b><br/>";
  infohtml += boxName;
  return infohtml;
}

function enlarge(photo,width,height)
{
    var win_options = 'width='+(width+20)+',height='+(height+20);
    window.open(photo,'_blank',win_options)
    return false;
}

