// window handle
var remote = null;

// window handle, n = window name, u = url, w = width, h = height, x = return
// handle if non-zero.
//
// Usage: <a href="javascript:rs('text', 'http:://some.domain.com/file.txt',
// 200, 200)>Text File Popup Window</a>
//
function rs(n,u,w,h,x)
{
  // Spaces aren't allowed in 3rd argument to window.open.
  args = "width=" + w + ",height=" + h
    + ",titlebar,resizable,scrollbars,status=0";
  remote = window.open(u,n,args);
  if (remote != null)
  {
    // Make window "independent" so that when it is closed it can be garbaged
    // collected.
    if (remote.opener == null)
    {
      remote.opener = self;
    }
  }
  if (x == 1)
  {
    return remote;
  }
}

// Based on a script from http://javascript.internet.com

var max_width = 1024 ;
var max_height = 768 ;
var image ;

// si -> show_image

// Usage: <a href="javascript:si('text', 'http:://some.domain.com/image.jpg')>
// An auto sizing image file popup window</a>

function si(target, img_url) 
{
  image = new Image() ;
  // For some reason I need to copy the argument in order make this work in
  // Netscape 4.
  img = img_url ;
  image.src = img ;
  do_image(target, img) ;
}

function do_image(target,img)
{
  if ((image.width != 0) && (image.height != 0))
  {
    view_image(target,img) ;
  }
  else
  {
    func_call = 'do_image("'+target+'","'+img+'")' ;
    interval = setTimeout(func_call, 20) ;
  }
}

function view_image(target,img)
{
  img_width = Math.min(max_width, image.width+20) ;
  img_height = Math.min(max_height, image.height+20) ;
  rs(target,img,img_width,img_height,0) ;
}
