
var PopupWindow = null; // global variable

function Popup(theURL,winName,features)
{
  if(PopupWindow == null || PopupWindow.closed)
  /* if the pointer to the window object in memory does not exist
     or if such pointer exists but the window was closed */

  {
    PopupWindow = window.open(theURL,winName,features);
    /* then create it. The new window will be created and
       will be brought on top of any other window. */
  }
  else
  {
    PopupWindow.focus();
    /* else the window reference must exist and the window
       is not closed; therefore, we can bring it back on top of any other
       window with the focus() method. There would be no need to re-create
       the window or to reload the referenced resource. */
  };
}

function PopupRefresh(theURL,winName,features) // always refreshes window and brings focus to front.
{
    PopupWindow = window.open(theURL,winName,features);
    PopupWindow.focus();
}