function textOverlayClose()
{
    var popup = document.getElementById("textOverlay");
    popup.style.display = "none";
}
/*
 * Find inner 'div' from item that fired the event and display
 * it in a "popup" (overlay).
 */
function textOverlayShow(event)
{
    var popup = document.getElementById("textOverlay");
    if (!event) event = window.event;
    if (!popup) {
        // Create popup.
        var closeDiv, closeImage, popupBody, title;
        popup = document.createElement("div");
        closeImage = document.createElement("img");
        popupBody = document.createElement("div");
        popupClose = document.createElement("div");
        title = document.createElement("span");

        closeImage.src="images/close_icon.gif";
        closeImage.title = "Close";

        title.className = "textOverlayClose";
        title.innerHTML = "details";

        popupClose.className = "textOverlayClose";
        popupClose.id = "textOverlayClose";
        popupClose.appendChild(closeImage);
        popupClose.appendChild(title);

        popupBody.className = "body";
        popup.appendChild(popupClose);
        popup.appendChild(popupBody);

        popup.className = "textOverlay";
        popup.id = "textOverlay";
        popup.onclick = textOverlayClose;

        popup.popupBody = popupBody;
        popup.popupClose = popupClose;
        popup.popupTitle = title;

        document.body.appendChild(popup);
    }
      var element = event.currentTarget || event.srcElement;
      if (element.nodeName == "A") {
        element = element.parentNode;
    }
      
    var target = element.getElementsByTagName("div");
    var label = element.getElementsByTagName("a");
    if (target && target.length > 0) {
        popup.popupBody.innerHTML = target[0].innerHTML;
        popup.style.display = "block";
        if (label && label.length == 1) {
            popup.popupTitle.innerHTML = label[0].innerHTML;
            if (label[0].className.indexOf("textOverlayVisited") === -1) {
                label[0].className += " textOverlayVisited";
            }
        }
        var anchor = document.getElementById("textOverlayAnchor");
        if (anchor == null) {
            anchor = element.parentNode;
        }
        var width = anchor.parentNode.clientWidth - 400;
        if (width < 400) {
            width = 400;
        }
        // Note this may be wrong depending on browser, but I don't care much for width.
        // Height is more likely to be an issue, but that's not important here.
        if (width + 32 > document.body.clientWidth) {
            width = document.body.clientWidth - 32;
        }
        var offsetWidth = 0;
        if (navigator.userAgent.toLowerCase().indexOf("msie ") > 0) {
          offsetWidth = 8; // border width.
        }
        width += offsetWidth;
        popup.style.width = width + "px";
        // Height remains auto.
        // Get absolute position of parent node.
        var left = 0, top = 0;
        var obj = anchor;
        if (obj.offsetParent) {
            do {
                left += obj.offsetLeft;
                top += obj.offsetTop;
            } while ( obj = obj.offsetParent);  // this is an assignment, not ==
        }
        popup.style.left = left + "px";
        popup.style.top = top + "px";
    }
    return false;
}

