function imgPopup(imageURL,imageTitle,w,h) {
  
  var ratio = w/h;
  if (ratio > 1) {
    w = 800;
    h = 600;
  } else {
    w = 600;
    h = 800;
  }
  
  maxHeight = screen.height - 50;
  maxWidth = Math.round(maxHeight*ratio);
  if (maxWidth > screen.width-50) {
    maxWidth = screen.width - 50;
    maxHeight = Math.round(maxWidth/ratio);
  }

  var winWidth = w+40;
  var winHeight = h;

  var PositionX = Math.round(screen.width/2 - (winWidth)/2);
  var PositionY = Math.round(screen.height/2 - (winHeight+100)/2);
  var opt='width='+winWidth+',height='+winHeight+',left='+PositionX+',top='+PositionY+',status=0,toolbar=0,menubar=0,location=0';
  imgWin=window.open('about:blank','null',opt);
  with (imgWin.document) {
    writeln('<html><head><title>Loading...</title><style>body{margin:0px;background:#fff;}</style>');
    writeln('<sc'+'ript type="text/javascript">');
    writeln('function doTitle(){document.title="'+imageTitle+'";}');
    writeln('</sc'+'ript>');
    writeln('</head><body onload="doTitle();self.focus()">');
    writeln('<div style="text-align:center;"><img alt="'+imageTitle+'" title="'+imageTitle+'" src="'+imageURL+'" style="display:block;margin:0 auto;width:'+w+'px;height:'+h+'px;" onclick="window.close(); window.opener.focus();" /></div></body></html>');
    close();
  }
}

function el(id) {
  return document.getElementById(id);
}