/*
[Program]
	Open an new window
[Language]
	JavaScript
[Purpose]
	This function provides the ability to open a new window without having 
	to know the various specific options available to the JavaScript 
	function.
[Requirements]
	A browser that supports JavaScript.
[Parameters]
	The script uses predefined parameters for the options that can be set 
	on JavaScript pop-up windows. The parameters should be entered without 
	quotes. Parameter definitions indicate whether or not a paired value 
	needs to be entered by defining the value type (INTEGER or STRING). 
	An example of how to call the openWin() function can be found in the 
	samples section.
		HEIGHT [OPTIONAL, VALUE=INTEGER, DEFAULT=300] The height of the 
			window
		MENUBAR [OPTIONAL] Show the menu bar
		NAME [OPTIONAL, VALUE=STRING, DEFAULT="popup"] Name of the new window
		PAGE [OPTIONAL, VALUE=STRING, DEFAULT="/"] the destination address 
		for the new window, relative and absolute URLs are acceptable.
		RESIZE [OPTIONAL] Allow the window to be resized
		SCROLL [OPTIONAL] Allow the user to scroll the document, show the 
			scroll bars (if necessary)
		STATUS [OPTIONAL] Show the status bar
		TOOLBAR [OPTIONAL] Show the tool bar (icons)
		WIDTH [OPTIONAL, VALUE=INTEGER, DEFAULT=450] the width of the window
[Usage]
	Attach this function to an element's event listener through old-style 
	html on[EVENT]="" syntax. Be sure to include a "return false;" statement 
	after the function call if you don't want the default action to occur 
	(navigating to a new page in the case of an onclick event on a link).
	
	Paramaters should be entered without any kind of quotation (as they are 
	variables and not strings). Paramaters that require a value should be 
	followed by a comma and the value (see sample).All other parameters are 
	singular entities, meaning that specifying them turns on the related option 
	for the resulting pop-up window.
	
	The function should be called with a minimum of the height, width, and 
	destination (though this is not necessary as default values are provided 
	for all variables).
[Sample]
	<a href="newpage.htm" onclick="openWin(PAGE, 'otherpage.htm', HEIGHT, 350, WIDTH, 200, STATUS); return false;">linktext</a>
	<a href="newpage.htm" onclick="openWin(PAGE, this.href); return false;">linktext</a>
[Notes]
	All of the predefined parameters match their javascript window object parameters except 
	for "URL" which conflicts with document.URL in some browsers (depending on inheritence, 
	default objects, and object search order).
[To do]
	* Make the default height and width be proportional to the current screen size.

-----------------------------------------------------------------
Ver    Date    Description of modification
--- ---------- --------------------------------------------------
1.1 2006/02/23 Documentation added
1.0 2003/01/01 Original write
-----------------------------------------------------------------
*/

// Initialize openWin function variables.
var HEIGHT = 'HEIGHT';
var MENUBAR = 'MENUBAR';
var NAME = 'NAME';
var RESIZE = 'RESIZE';
var SCROLL = 'SCROLL';
var STATUS = 'STATUS';
var TOOLBAR = 'TOOLBAR';
var WIDTH = 'WIDTH';
var PAGE = 'URL';

function openWin() {
	// Set default values for the pop-up window options 
   var strParam;
   var location = '/';
   var winName = 'popup';
   var w = 450;
   var h = 300;
   var bolMenu = 0;
   var bolResize = 'no';
   var bolScroll = 'no';
   var bolStatus = 0;
   var bolTool = 0;
	
	// Since the user can specify a variable number of arguments for this function 
	// we need to step through the function's arguments array to determine which 
	// parameters were specified. The switch statement will match on the value of 
	// the specified parameters and modify the default values of the pop-up window 
	// options. If a parameter requires a value to be specified the script will 
	// check the next argument for that value.
   for (i = 0; i <= openWin.arguments.length; i++) {
      switch (openWin.arguments[i]) {
         case 'HEIGHT':
            h = openWin.arguments[i+1];
            i++;
            break;
         case 'MENUBAR':
            bolMenu = 1;
            break;
         case 'NAME':
            winName = openWin.arguments[i+1];
            i++;
            break;
         case 'RESIZE':
            bolResize = 1;
            break;
         case 'SCROLL':
            bolScroll = 1;
            break;
         case 'STATUS':
            bolStatus = 1;
            break;
         case 'TOOLBAR':
            bolTool = 1;
            break;
         case 'WIDTH':
            w = openWin.arguments[i+1];
            i++;
            break;
         case 'URL':
            location = openWin.arguments[i+1];
            i++;
            break;
      }
   }
   eval(winName+"=window.open(location, winName, 'toolbar='+bolTool+',location=0,directories=0,status='+bolStatus+',menubar='+bolMenu+',scrollbars='+bolScroll+',resizable='+bolResize+',width='+w+',height='+h)");
   eval(winName+".focus()");
}
