// Open a little window.

var popupWin = null

/*------------------------------------------------------------------------------
  Function openWindow() opens a pop-up window.  If the size specified can be
  determined to be larger than the user's available space, it adjusts the window 
  size.
  
  inputs:  location    - the URL to display in the window
           w           - the desired width of the window
           h           - the desired height of the window
           showToolBar - boolean; whether you want the toolbar to show in the
                         window
------------------------------------------------------------------------------*/
function openWindow(location, w, h, showToolBar)
{
    // Close the window if it is already open.
    if (popupWin != null && !popupWin.closed)
    {
      popupWin.close()
      popupWin = null
    }

    // Detect screen resolution. Only works in 4+ browsers. If resolution is
    // smaller than the desired window size, adjust the window size.
    if (screen) 
    {
      wd = (w > screen.availWidth) ? eval(screen.availWidth - 15) : w
      ht = (h > screen.availHeight) ? eval(screen.availHeight - 15) : h
    }
    
    // If we can't detect screen size, assume 640x480.
    else 
    {
      wd = (w > 600) ? 600 : w
      ht = (h > 380) ? 380 : h
    }
    
    // Open a resizable popup window with scrollbars, the toolbar (buttons),
    // no status bar, in the top left corner of the screen (window positioning
    // only works in IE 4+).
    if (location.toLowerCase().indexOf(".pdf") < 0)
    {
      popupWin = window.open("", "display", "scrollbars=1,resizable=1,width=" + wd + 
                 ",height=" + ht + ",left=0,top=0,toolbar=" + (showToolBar ? "1" : "0") + ",menubar=0,status=0")
      popupWin.focus()
      popupWin.location.href = location
    }
    else
    {
      popupWin = window.open(location, "display", "scrollbars=1,resizable=1,width=" + wd + 
                 ",height=" + ht + ",left=0,top=0,toolbar=" + (showToolBar ? "1" : "0") + ",menubar=0,status=0")
      popupWin.focus()
    }

    return true
}

function openNewWindow(URLtoOpen, windowName, windowFeatures) {
	newWindow=window.open(URLtoOpen, windowName, windowFeatures); 
	if (window.focus) {
		newWindow.focus()
	}
}