function header(scriptdir, title) {
  return '<html><head><title>' + title + '</title>'
    + '<script src="'
    + scriptdir + '../mango.js" type="text/javascript"></script>'
    + '</head>'; }

function footer() { return '</body></html>'; }

function popupimage(scriptdir, imagetag, description) {
  w = window.open (
      '',
      '',
      'width=400,height=50,menubar=no,resizable=yes,status=no,toolbar=no');
  w.document.write (
    header(scriptdir, description)
    + '<body onclick="window.close();" onload="resize_window_for_image();">'
    + imagetag
    + footer());
  w.document.close(); }

function resize_window_for_image() {
  image = document.images[0];
  window.resizeTo(image.width + 10, image.height + 10); }
