
// General Item Centering Code


function centerElement(referenceID, theID) {
  infohost = document.getElementById(referenceID);
  infobox = document.getElementById(theID);

  // Find the location of where we should position the pop-up box
  // "referenceID" is the document element near where the pop-up box should appear.
  // This is passed in as a variable (openHere) from the caller.


  var infohostY = 0;
  var infohostX = 0;
  var count = 0;
  var infohostFind = infohost;


  // Iterate through the target item's many potential parents to calculate position X and Y values


  do {
    infohostY += infohostFind.offsetTop;
    infohostX += infohostFind.offsetLeft;
  } while ( infohostFind = infohostFind.offsetParent )

  // Now position the pop-up box, based on the parent element's location and height.

  // alert(infohostX + " - " + infobox.offsetWidth + " - " + infohost.offsetWidth);

  infobox.style.left = infohostX + infohost.offsetWidth -20 + "px";
  infobox.style.top = infohostY - 40 + "px";


  return;
}

// Function to make a box appear...
// This positions the box, too.

function showBox(openHere, box, textHere, text) {


  // doFade. 1 = Yes, fade it in. 0 = Leave it how it is, assuming it's open

  infohost = document.getElementById(openHere);
  infobox = document.getElementById(box);
  textArea = document.getElementById(textHere);
  
  textArea.innerHTML = text;

  // Center the Element
  
  centerElement(openHere, box);

  // Now do the fade

    Effect.Appear(infobox, {duration: 0.1});
}

// And to make a box dissapear.

function hideBox(box) {
	Effect.Fade(box, {duration: 0.0});
}
