<!--
/***
Revision History:
No.  Date         Modified by     Remarks
1    Oct 10, 2001 Spenson Shih    Set focus to window to ensure UnBlockEvents to be called
2    Jan 02, 2002 Spenson Shih    Added code to handle reloading of parent window even if 
                                  modal window is open.
***/

// One object tracks the current modal dialog opened from this window.
var dialogWin = new Object();

// Generate a modal dialog.
// Parameters:
//    url -- URL of the page/frameset to be loaded into dialog
//    width -- pixel width of the dialog window
//    height -- pixel height of the dialog window
//    returnFunc -- reference to the function (on this page)
//                  that is to act on the data returned from the dialog
//    args -- [optional] any data you need to pass to the dialog
function openDialog(url, width, height, returnFunc, args) {
  // Initialize properties of the modal dialog object.
  dialogWin.owner = window;
  dialogWin.returnFunc = returnFunc;
  dialogWin.returnedValue = '';
  dialogWin.args = args;
  dialogWin.url = url;
  dialogWin.width = width;
  dialogWin.height = height;
  // Keep name unique so Navigator doesn't overwrite an existing dialog.
  dialogWin.name = (new Date()).getSeconds().toString();
  // Assemble window attributes and try to center the dialog.
  // Center on the main window.
  dialogWin.left = window.screenX + 
     ((window.outerWidth - dialogWin.width) / 2);
  dialogWin.top = window.screenY + 
     ((window.outerHeight - dialogWin.height) / 2);
  var attr = "screenX=" + dialogWin.left + 
     ",screenY=" + dialogWin.top + ",toolbar=yes, modal=yes,scrollbars=yes,resizable=no,width=" + 
     dialogWin.width + ",height=" + dialogWin.height;
  
  // Generate the dialog and make sure it has focus.
  window.focus();
  dialogWin.win = window.open(dialogWin.url, dialogWin.name, attr);

  if (dialogWin.MODAL_RESULT == 1) {
    dialogWin.returnFunc();
    dialogWin.MODAL_RESULT = 0;
  }
}

//-->