// Global variables
var popupWin = null

// Open a little window.
function openWindow(location, w, h)
{
    if (popupWin != null && !popupWin.closed)
    {
      popupWin.close()
      popupWin = null
    }

    if (screen != null)
    {
      //scrollNeeded = ((h > screen.availHeight) || (w > screen.availWidth)) ? 1 : 0
      wd = (w > screen.availWidth) ? eval(screen.availWidth - 15) : w
      ht = (h > screen.availHeight) ? eval(screen.availHeight - 15) : h
    }
    else
    {
      wd = w
      ht = h
    }

    popupWin = window.open("", "display", "width="+wd+
               ",height="+ht+",scrollbars=1,resizable=1,menubar=1,toolbar=1,status=1,location=1")
    popupWin.focus()
    popupWin.location.href = location

    return false

  return true
}

// Open a little window, allowing for customization.
function openCustomWindow(location, w, h, addressbar, resizable, scrollbars, menubar, toolbar, status)
{
    if (popupWin != null && !popupWin.closed)
    {
      popupWin.close()
      popupWin = null
    }

    if (screen != null)
    {
      //scrollNeeded = ((h > screen.availHeight) || (w > screen.availWidth)) ? 1 : 0
      wd = (w > screen.availWidth) ? eval(screen.availWidth - 15) : w
      ht = (h > screen.availHeight) ? eval(screen.availHeight - 15) : h
    }
    else
    {
      wd = w
      ht = h
    }

    popupWin = window.open("", "display", "width=" + wd +
               ",height=" + ht + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",menubar=" + menubar + ",toolbar=" + toolbar + ",status=" + status + ",location=" + addressbar)
    popupWin.focus()
    popupWin.location.href = location

    return false

  return true
}
