﻿
var newwindow = '';

function popitup(url, name, width, height)
{
  var fullScreen = false;
  var screenWidth = 0;
  var screenHeight = 0;

  // extra space needed for ttitlebar, scroolbars, etc.
  var extraWidth = 50;
  var extraHeight = 70;

  // try to get the dimensions of the screen
  // v4 browsers support the screen object
  // otherwise check for a java-enabled system
  // and use java to set the screen dimensions
  if ( screen )
  {
    screenWidth = screen.availWidth;
    screenHeight = screen.availHeight;
  }
  else if ( navigator.javaEnabled() )
  {
    var toolkit = java.awt.Toolkit.getDefaultToolkit ();
    var screen_size = toolkit.getScreenSize ();
    screenWidth = screen_size.width;
    screenHeight = screen_size.height;
  }

  // if we got the screen size - verify our width and height
  // and if we are too big to fit on screen, resize to fit the screen.
  if ( screenWidth && screenHeight )
  {
    if ( screenWidth < (width + extraWidth) )
    {
      width = screenWidth;
      fullScreen = true;
    }
    if ( screenHeight <  (height + extraHeight) )
    {
      height = screenHeight;
      fullScreen = true;
    }
  }

  // finally, create the new window and position it accordingly
  var output = 'toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1';
  output += ',width=' + width;
  output += ',height=' + height ;

  newwindow=window.open( '', 'name', output );
  if ( fullScreen )
  {
    newwindow.resizeTo( width, height );
    newwindow.moveTo( 0, 0 );
  }
  else
  {
    newwindow.resizeTo( width + extraWidth, height + extraHeight );
    newwindow.moveTo( 0, 0 );
  }
  newwindow.document.write('<HTML><META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=Windows-1252"><HEAD><TITLE>' + url + '</TITLE>');
  newwindow.document.write('</HEAD>')
  newwindow.document.write('<BODY>');
  newwindow.document.write('<IMG SRC="' + url + '">');
  newwindow.document.write('</BODY></HTML>');
  newwindow.document.close();
  newwindow.focus();
}

