  // UTILITY SCRIPT FOR ADDRESS SELECTION POPUP
  function initPopup(sLayerName, sIframeName, iHeight) {
    var layerObj  = document.getElementById(sLayerName);
    var iframeObj = document.getElementById(sIframeName);
		
    layerObj.style.height  = iHeight + "px";
    iframeObj.style.height = iHeight + "px";
	
    var windowW = 750; //module width
    var windowH = 0;
    var windowX = 0;
    var windowY = 0;
    if (window.innerHeight && pageXOffset && pageYOffset) {
      windowW = (window.innerWidth < windowW) ? window.innerWidth : windowW;
      windowH = window.innerHeight;
      windowX = pageXOffset;
      windowY = pageYOffset;
    } else {
      windowW = (document.body.clientWidth && 
                (document.body.clientWidth < windowW)) ? 
        document.body.clientWidth : windowW;
      windowH = (document.body.clientHeight) ? document.body.clientHeight : 0;
      windowX = (document.body.scrollLeft) ? document.body.scrollLeft : 0;
      windowY = (document.body.scrollTop) ? document.body.scrollTop : 0;
    }

    if (windowW && windowH) {
      var prefX = windowX + 
        Math.floor((windowW - parseInt(layerObj.style.width)) / 2);
      var prefY = windowY + 
        Math.floor((windowH - parseInt(layerObj.style.height)) / 2);
      layerObj.style.left = (prefX > (windowX + 10)) ? 
        prefX + "px" : (windowX + 10) + "px";
      layerObj.style.top = (prefY > (windowY + 10)) ? 
        prefY + "px" : (windowY + 10) + "px";
    }
		
    repaintMacJS();

  }
  function positionCL(x, y, iYOffset, iXOffset) {
    layerObj            = document.getElementById('contentLayer');		
    var anchorHeight    = 23;
    var popupHeight     = 400;
    var yOffset         = (iYOffset) ? iYOffset : 0;
    var xOffset         = (iXOffset) ? iXOffset : 0;
    layerObj.style.top  = (y - (anchorHeight + popupHeight) + yOffset) + "px";	
    layerObj.style.left = (x + xOffset) + "px";
  }

  function showCL() {
    document.getElementById('contentLayer').style.visibility = 'visible';
    repaintMacJS();
  }
	
  function hideCL() {
    document.getElementById('contentLayer').style.visibility = 'hidden';
  }

  function toggleCL(oAnchor, sContentPath, iYOffset, iXOffset) {
    var anchorCoords = getAnchorPosition(oAnchor.name);
    positionCL(anchorCoords.x, anchorCoords.y, iYOffset, iXOffset);
		
    var isHidden = (document.getElementById('contentLayer').style.visibility == 'hidden');
    var isNewSrc = (sContentPath && ((document.getElementById('contentFrame').src).indexOf(sContentPath) == -1));

    if (isNewSrc) {

      document.getElementById('contentFrame').src = sContentPath;
      showCL();

    } else {

      if (!isHidden) {
        showCL();
      } else {
        showCL();
      }
    }
  }
	
  function reloadPage() {
    window.reload();
  }
