popupBox = new Object();

// --- Start CONFIGURATION ---

popupBox.width = 125;
popupBox.bgColor = '#ffffff';
popupBox.borderColor = '#000000';
popupBox.borderWidth = 1;
popupBox.fontColor = '#000000';
popupBox.fontFace = 'verdana';
popupBox.fontSize = 1;
popupBox.padding = 2;
popupBox.cursorOffsetX = 20;
popupBox.cursorOffsetY = -80;
popupBox.showDelay = 10;
popupBox.windowPadding = 2;

// --- End CONFIGURATION ---

popupBox.isLoaded = false;
popupBox.isActive = false;
popupBox.showTimeout = null;

function loadPopupBox() {
   if (!popupBox.isLoaded) {
      captureCursor();
      popupBox.layerObj = addLayer('popupLayer');
      popupBox.isLoaded = true;
      }
   }

function hidePopupBox() {
   if (popupBox.isLoaded) {
      clearTimeout(popupBox.showTimeout);
      popupBox.isActive = false;
      hideLayer(popupBox.layerObj);
      }
   }

function displayPopupBox() {
   var winWidth = document.body.clientWidth;
   var winHeight = document.body.clientHeight;
   var tempLayerWidth = getLayerWidth(popupBox.layerObj);
   var tempLayerHeight = getLayerHeight(popupBox.layerObj);
   var tempPosX = cursorWinX + popupBox.cursorOffsetX;
   //tempPosX = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
   if (tempPosX + tempLayerWidth > winWidth - popupBox.windowPadding) tempPosX = cursorWinX - tempLayerWidth - popupBox.cursorOffsetX;
   if (tempPosX < popupBox.windowPadding) tempPosX = popupBox.windowPadding;
   tempPosX += document.body.scrollLeft;
   tempPosY = cursorWinY + popupBox.cursorOffsetY;
   tempPosY += Math.max(document.body.scrollTop,document.documentElement.scrollTop);
   //if (tempPosY + tempLayerHeight > winHeight - popupBox.windowPadding) tempPosY = winHeight - popupBox.windowPadding - tempLayerHeight;
   //if (tempPosY < popupBox.windowPadding) tempPosY = popupBox.windowPadding;
   //tempPosY += document.body.scrollTop;
   moveLayerTo(popupBox.layerObj,tempPosX,tempPosY);
   
   popupBox.isActive = true;
   showLayer(popupBox.layerObj);
   setLayerOnTop(popupBox.layerObj);
   setLayerOnTop(popupBox.layerObj);
   setLayerOnTop(popupBox.layerObj);
}
   
function getLayerHeight(LAYEROBJ) { return LAYEROBJ.clientHeight; }
function getLayerWidth(LAYEROBJ) { return LAYEROBJ.clientWidth; }