﻿// Management of the green menu marker thingy on all of the pages
var theThingyWidth = 46;
function SetMenuThingy( aPageName) {
    var theNavbar = document.getElementById("navbar");
    var theAnchors = theNavbar.getElementsByTagName("a");
    for( var i=0; i< theAnchors.length; ++i) {
      var theText = theAnchors[i].firstChild;
      if( theText.data.toLowerCase() == aPageName)
        break;
    }
    if (i == theAnchors.length) return;

    var thePtr = theAnchors[i];
    var x = y = 0;
    while (thePtr != null) {
      x += thePtr.offsetLeft;
      y += thePtr.offsetTop;
      thePtr = thePtr.offsetParent;
      if( thePtr.id == "container")
        break;
    } 
    var theContainer = document.getElementById("container");
    var theThingy = document.createElement("img");
    var theAnchor = theAnchors[i];
    theContainer.appendChild(theThingy);    
    theThingy.style.position = "absolute";
    theThingy.src = "images/green_thingy.gif";
    theThingy.style.left = (x + (theAnchor.offsetWidth - theThingyWidth)/2 - 1) + "px";
    theThingy.style.top = y + theAnchor.offsetHeight + "px";
}

function MyRolloverHandler( theImage, theEventType) {
  switch (theEventType) {
    case "mouseover":
      //theImage.parentNode.style.backgroundColor = "#A8B001";
      theImage.parentNode.style.backgroundImage = "url(images/thumb_thingy.png)";
      break;
    case "mouseout":
      //theImage.parentNode.style.backgroundColor = "#FEFDED";
      theImage.parentNode.style.backgroundImage = "none";
      break;
  }
}
