
var DHTML = (document.getElementById || document.all || document.layers);


function getObj(name) {
  if (document.getElementById) {
    return document.getElementById(name);
  }
  else if (document.all) {
    return document.all[name];
  }
  else if (document.layers) {
    return document.layers[name];
  }
}


function windowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return new Array(myWidth, myHeight);
}


function mousePos(e) {
  var posX, posY;
  if( !e ) { e = window.event; }
  if( !e || ( typeof( e.pageX ) != 'number' && typeof( e.clientX ) != 'number' ) ) { return; }
  if( typeof( e.pageX ) == 'number' ) {
	var posX = e.pageX;
    var posY = e.pageY;
  } else {
    var posX = e.clientX;
	var posY = e.clientY;
    if( !( ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) || ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) || window.navigator.vendor == 'KDE' ) ) {
      if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) ) {
        posX += document.documentElement.scrollLeft;
	    posY += document.documentElement.scrollTop;
      } else if( document.body && ( document.body.scrollTop || document.body.scrollLeft ) ) {
        posX += document.body.scrollLeft;
		posY += document.body.scrollTop;
      }
    }
  }
  return new Array(posX, posY);
}


function show(id, e) {
  if (!DHTML) return;
  var x = getObj(id);
  x.style.textDecoration="underline";

  var pop = getObj("Popup");
  pop.innerHTML = eval(id);

  var pos = mousePos(e);
  var window = windowSize();

  // Move the popup over to the left if it overflows the screen to the right
  if (pos[0] + 300 > window[0]) {
	pos[0] = window[0] - 300; // 270 = width of popup
  }
  
  // Move the popup up if it overflows the screen on the bottom
  if (pos[1] + 100 > window[1]) {
    pos[1] = pos[1] - 100; // 80 = height of popup
  }

  // The popup div is nested inside an absolute positioned div, so the positioning
  // of the popup div, although absolute, is relative to it's parent.
  // Subtract the left window margin off the mouse position.
  pos[0] = pos[0] - (window[0] - 760) / 2;
  
  pop.style.visibility = "visible";
  pop.style.left = (pos[0] + 5) + "px";
  pop.style.top = (pos[1] + 5) + "px";
}


function show2(id, e) {
  if (!DHTML) return;

  var pop = getObj("Popup");
  pop.innerHTML = eval(id);

  var pos = mousePos(e);
  var window = windowSize();

  // Move the popup over to the left if it overflows the screen to the right
  if (pos[0] + 300 > window[0]) {
	pos[0] = window[0] - 300; // 270 = width of popup
  }
  
  // Move the popup up if it overflows the screen on the bottom
  if (pos[1] + 100 > window[1]) {
    pos[1] = pos[1] - 100; // 80 = height of popup
  }

  // The popup div is nested inside an absolute positioned div, so the positioning
  // of the popup div, although absolute, is relative to it's parent.
  // Subtract the left window margin off the mouse position.
  pos[0] = pos[0] - (window[0] - 760) / 2;
  
  pop.style.visibility = "visible";
  pop.style.left = (pos[0] + 5) + "px";
  pop.style.top = (pos[1] + 5) + "px";
}


function hide(id, e) {
  if (!DHTML) return;
  var x = getObj(id);
  x.style.textDecoration="none";
  hidePopup();
}


function hide2(id, e) {
  if (!DHTML) return;
  hidePopup();
}


function hidePopup() {
  if (!DHTML) return;
  var pop = getObj("Popup");
  pop.style.visibility = "hidden";
}

function showHelp() {
  if (!DHTML) return;

  var pop = getObj("Popup");
  pop.innerHTML = "<div class='popuptop'><b>Map Instructions</b></div><div class='popupbottom'>Move your mouse over a number for info<br/>Click the number for details</div>";

  pop.style.position = "absolute";
  pop.style.left = "0px";
  pop.style.top = "190px";
  pop.style.visibility = "visible";
}
  