/**
 * jcPopup.js - Defines the jcPopUp function, which can be used to open a popup
 *              window.
 *
 * Copyright (c) 2004-2005 Owan Hunte. ALL RIGHTS RESERVED.
 *
 * The author of this software grants you a royalty free license to use,
 * copy, modify or redistribute this software provided that this copyright
 * notice appears on ALL copies. This software is provided "AS IS,"
 * without a warranty of any kind.
 */

/**
 * @function : jcPopUp()
 *
 * @input    : docUrl - String that specifies the Uniform Resource Location
 *                     (URL) of the document to be loaded.
 *             winName - String that identifies the name of the popup window.
 *             width - The width of the popup window.
 *             height - The height of the popup window.
 *             menuBarFlag - Set to 1 if window has a menu bar, 0 if not.
 *             toolBarFlag - Set to 1 if window has a toolbar bar, 0 if not.
 *             scrollBarFlag - Set to 1 if window has scroll bars, 0 if not.
 *             statusFlag - Set to 1 if window has a status bar, 0 if not.
 *             resizableFlag - Set to 1 if window is resizable, 0 if not.
 *
 * @purpose  : To open a new browser window that loads the document
 *             with url docUrl into the window's client area.
 *
 * @returns  : An object handle for the pop-ed up window or null if popup
 *             windows are not allowed.
 *
 * @note     : This function brings the window 'pop-ed' up into focus after
 *             it is opened.
 */
function jcPopUp (docUrl, winName, width, height, menuBarFlag, toolBarFlag,
                  scrollBarFlag, statusFlag, resizableFlag)
{
   var window_name = !winName ? "popupWin" : winName;   // window name
   var window_handle = null;
   var args = "";                  // window parameters

   // set the parameters
   args += "width=" + width;
   args += ",height=" + height;
   args += ",left=50,top=50,";
   args += "scrollbars=" + scrollBarFlag;
   args += ",toolbar=" + toolBarFlag;
   args += ",directories=0,fullscreen=0,";
   args += "location=0,status=" + statusFlag;
   args += ",menubar=" + menuBarFlag;
   args += ",resizable=" + resizableFlag;

   window_handle = window.open (docUrl, window_name, args);  // open the window

   if (window_handle)         // popup window allowed
      window_handle.focus();  // bring window into focus

   return window_handle;      // return window handle
} // jcPopUp
