/*
Restriction: Browser windows have minimum dimensions of 100x100 so the code below will not 
  work with an image smaller than that.
Compatibility: NN4, IE4+
*/

// Set autoClose true to have the window close automatically
// Set autoClose false to allow multiple popup windows
var autoClose = false;

// Set toolbars true to show the toolbars
var toolbars = false;

var winOptions1 = 'resizable=yes,scrollbars=no,menubar=no,location=no,toolbar=yes,statusbar=no';
var winOptions2 = 'resizable=yes,scrollbars=no,menubar=no,location=no,toolbar=no,statusbar=no';

function popImage(imgURL) {
  if (window.opera || ! window.Image) {
    open(imgURL, '_blank', winOptions);
  }
  else {
    var img = new Image();
    img.onload = openImageWindow;
    img.src = imgURL;
  }
}

function openImageWindow(evt) {
  var w = this.width;
  var h = this.height;
  if (toolbars) {
    var win = open('about:blank', '_blank', 'innerWidth=' + w + ',innerHeight=' + h + ',' + winOptions1);
  }
  else {
    var win = open('about:blank', '_blank', 'innerWidth=' + w + ',innerHeight=' + h + ',' + winOptions2);
  }
  win.document.open();
  var html = '';
  html += '<html><head><title>Multipro - Image<\/title>';
  html += '<style type="text/css">#pic { position: absolute; left: 0px; top: 0px; }<\/style><\/head>';
  if (autoClose) {
    html += '<body onblur="self.close()"><span id="pic"><img src="'+ this.src +'" alt="Multipro - Image"\/><\/span><\/body><\/html>';
  }
  else {
    html += '<body><span id="pic"><img src="'+ this.src +'" alt="Multipro - Image"\/><\/span><\/body><\/html>';
  }
  win.document.write(html);
  win.document.close();
  if (window.innerWidth) {
      // Do nothing
  }
  else if (document.all) {
    win.resizeBy(w - win.document.body.clientWidth, h - win.document.body.clientHeight);
    win.document.body.scroll = 'no';
  }
}

