/*------------------------------------------------------------------------
  File:        lookupWindow.js
  Author:      RJM
  Description: JS functions to view, position, focus, and close 
               a popup window
------------------------------------------------------------------------*/

var lookupWindow;
var lookupNameRunning = "";
var lookupWidth = "600";
var lookupHeight = "300";

setLookupPosition();

function setLookupPosition() {
   if (lookupWidth > screen.width) {lookupLeft = 0;}
   else {lookupLeft = (screen.width - lookupWidth) / 2;}

   if (lookupHeight > screen.height) {lookupTop = 0;}
   else {lookupTop = (screen.height - lookupHeight) / 2;}
}

function viewLookup(lookupName,lookupURL) {
   if (!lookupWindow || lookupWindow.closed) {
      lookupWindow = open('','LookupWindow','width=' + lookupWidth + ',height=' + lookupHeight + ',directories=no,toolbar=no,menubar=no,scrollbars=yes,location=no,resizable=yes,left=' + lookupLeft + ',top=' + lookupTop);
      lookupNameRunning = "";
   }
   if (lookupName != lookupNameRunning) {
      lookupNameRunning = lookupName;
      lookupWindow.location.href = lookupURL;
   }
   lookupWindow.focus();
}

function closeLookup() {
   if (lookupWindow && !lookupWindow.closed) {
      lookupWindow.close();
   }
}
