/**********************************************************************
  BEGIN MODAL DIALOG CODE (can also be loaded as external .js file)
***********************************************************************/
// Global for brower version branching.
var Nav4 = ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4))

// 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
//    windowName -- name for the dialog window
//    width -- pixel width of the dialog window
//    height -- pixel height of the dialog window
//    args -- [optional] any data you need to pass to the dialog
//            if this argument is "scrollbars" (in quotes), then scrollbars
//            will be included in the dialog box.
function openDialog(url, windowName, width, height, args) {
        if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {
                // Initialize properties of the modal dialog object.
                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 = windowName;
                // Assemble window attributes and try to center the dialog.
                if (Nav4) {
                        // 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 + ",resizable=no,width=" + 
                           dialogWin.width + ",height=" + dialogWin.height
						if (args)
							{
							if (args.charAt(0) != ',')
								attr = attr + ",";
							attr = attr + args;
							}
//						if( (args) && (dialogWin.args.indexOf("scrollbars") != -1))
//							{
//							attr = attr + ",scrollbars"
//							}
//						if( (args) && (dialogWin.args.indexOf("resizable") != -1))
//							{
//							attr = attr + ",resizable"
//							}
                } else {
                        // The best we can do is center in screen.
                        dialogWin.left = (screen.width - dialogWin.width) / 2
                        dialogWin.top = (screen.height - dialogWin.height) / 2
                        var attr = "left=" + dialogWin.left + ",top=" + 
                           dialogWin.top + ",width=" + dialogWin.width + 
                           ",height=" + dialogWin.height;
						if (args)
							{
							if (args.charAt(0) != ',')
								attr = attr + ",";
							attr = attr + args;
							}

                }
                
                // Generate the dialog and make sure it has focus.
                dialogWin.win=window.open(dialogWin.url, dialogWin.name, attr)
                dialogWin.win.focus()
        } else {
                dialogWin.win.focus()
        }
}
