// Original:  Anders Jennerberg (anders@katedral.se)
// This script and many more are available free online at
// The JavaScript Source!! http://javascript.internet.com
//
function ViewImage(ifile,ix,iy,ititle) { 
  var win;
  var sWidth;
  var sHeight;
// Decide browser version
  var ns4 = (document.layers)? true:false;
  var ns6 = (document.getElementById)? true:false;
  var ie4 = (document.all)? true:false;
  var ie5 = false;
// Microsoft Stupidity Check(tm).
  if (ie4) {
    if ((navigator.userAgent.indexOf('MSIE 5') > 0) || (navigator.userAgent.indexOf('MSIE 6') > 0)) {
      ie5 = true;
    }
	if (ns6) {
      ns6 = false;
    }
  }
  win = window.open("","imageviewer","width="+ix+",height="+iy+",menubar=no,toolbar=no");

  if ( (ns4) || (ns6)) {
    sWidth = win.innerWidth
    sHeight = win.innerHeight
  } else {
    sWidth = win.document.body.clientWidth
    sHeight = win.document.body.clientHeight
  }
    
  if(sWidth!=ix || sHeight!=iy) {
    if ( (ns4) || (ns6)) {
      win.close()
      setTimeout('ViewImage("'+ifile+'",'+ix+','+iy+',"'+ititle+'")',250)
      return
    } else {
      win.window.resizeBy(ix-sWidth,iy-sHeight)
    }
  }
  win.document.open()
  win.document.write("<html><head><title>"+ititle+"</title>")
  win.document.write("</head><body>")
  win.document.write('<div style="position:absolute;width:'+ix+'px;height:'+iy+'px;left:0px;top:0px">')
  win.document.write("<img src="+ifile+"></div></body></html>")
  win.document.close()
  win.focus()
}
//
