﻿//this moves the 'definition' box (which appears when mouse is hovered over a term) to the mouse coordinates
function showDefinition(e) {
  var xcoord, ycoord;
  if( !e ) { e = window.event; }
  if( !e ) { return; }
  if( typeof( e.pageX ) == 'number' ) {
    xcoord = e.pageX;
    ycoord = e.pageY;
  } else if( typeof( e.clientX ) == 'number' ) {
    xcoord = e.clientX;
    ycoord = e.clientY;
    if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
      xcoord += document.body.scrollLeft;
      ycoord += document.body.scrollTop;
    } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
      xcoord += document.documentElement.scrollLeft;
      ycoord += document.documentElement.scrollTop;
    }
  } else { return; }
  var definition = document.getElementById("definition");
  if (xcoord-150 < 0) xcoord = 150;
  else if (window.innerWidth && (xcoord + 150) > window.innerWidth) xcoord = window.innerWidth - 150;
  else if (document.body.offsetWidth && (xcoord + 150) > document.body.offsetWidth) xcoord = document.body.offsetWidth - 150;
  definition.style.left = (xcoord-150) + "px";
  definition.style.top = (ycoord+15) + "px";
  document.getElementById("definition").style.display = "block";
}



doList = function() {
	
//the next 3 blocks of code fix IE 6's incompetence of not understanding li:hover, div:hover, and ul:hover
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (j=0; j<navRoot.childNodes.length; j++) {
node = navRoot.childNodes[j];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
if (document.all&&document.getElementById) {
navRoot = document.getElementById("navdiv");
for (j=0; j<navRoot.childNodes.length; j++) {
node = navRoot.childNodes[j];
if (node.nodeName=="DIV") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
 if (document.all&&document.getElementById) {
navRoot = document.getElementById("navdiv");
for (j=0; j<navRoot.childNodes.length; j++) {
node = navRoot.childNodes[j];
if (node.nodeName=="UL") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
 	
	//this finds which span elements are terms and makes the definition box pop up when the term is hovered over
	var spans = document.getElementsByTagName('span');
		for (j=0; j<spans.length; j++) {
			var termspan = spans[j];
			//IE uses 'className' while others use 'class'
			if (termspan.getAttribute('class') == "term" || termspan.getAttribute('className') == "term") {
				termspan.onmousemove = showDefinition;
				termspan.onmouseover = function() {
					document.getElementById("definition2").innerHTML = defs[this.innerHTML.toLowerCase()];
				}
				termspan.onmouseout = function() {
				document.getElementById("definition").style.display = "none";
			}
		}
	}
 
}
window.onload=doList;