function largeImg(imgsrc, title, set_scrollbars)
{
  var initWidth = 300; // начальная ширина окна
  var initHeight = 50; // начальная высота окна
  var wnd = window.open(imgsrc, 'enlarge', "directories=no, width="+initWidth+", height="+initHeight+", location=no, menubar=no, toolbar=no, status=no, scrollbars="+(set_scrollbars ? 'yes' : 'no')+", resizable=yes");
  var title = title ? title : '';
  wnd.document.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><title>'+title+'</title></head><body style="margin: 0; padding: 0; background-color: white"><div id="wait" style="text-align: center">Идет загрузка...<br>[<a href="javascript:window.close()">отменить</a>]</div><a href="javascript:window.close()"><img src="'+imgsrc+'" title="закрыть" alt="закрыть" border="0" onload="opener.imgLoaded(this, window)"></body></html>');
  wnd.document.close();
  wnd.moveTo((screen.availWidth - initWidth) / 2, (screen.availHeight - initHeight) / 2);
  wnd.focus();
  //<a href="javascript:window.close()"><img src="'+this.src+'" title="закрыть" alt="закрыть" border="0"></a>
}
function imgLoaded(img, wnd) {
  if(!wnd.closed) {
      wnd.document.getElementById('wait').style.display = 'none';
      // ограничиваем размер окна размерами экрана
      var s_width = screen.availWidth - 100; 
      var s_height = screen.availHeight - 100;
      // ограничиваем размер картинки размерами окна
      var i_width = img.width > s_width ? s_width : img.width;
      var i_height = img.height > s_height ? s_height : img.height;
      wnd.moveTo((screen.availWidth - i_width - 16) / 2, (screen.availHeight - i_height - 16) / 2);
      wnd.resizeTo(i_width, i_height);
      var oCanvas = wnd.document.getElementsByTagName(
        (wnd.document.compatMode && wnd.document.compatMode == "CSS1Compat") ? "HTML" : "BODY"
      )[0];
      var c_width = oCanvas.clientWidth ? oCanvas.clientWidth : wnd.innerWidth;
      var c_height = wnd.innerHeight ? wnd.innerHeight : oCanvas.clientHeight; // should be vice verca since Opera 7 is crazy!
      var o_width = i_width - c_width;
      if(o_width < 0) o_width = 0;
      var o_height = i_height - c_height;
      if(o_height < 0) o_height = 0;
      wnd.resizeBy(o_width, o_height);
      wnd.moveTo((screen.availWidth - i_width - o_width) / 2, (screen.availHeight - i_height - o_height) / 2);
      /*wnd.document.title = img.width+' x '+img.height;
      wnd.document.title += ' / '+c_width+' x '+c_height;
      wnd.document.title += ' / '+o_width+' x '+o_height;*/
  }
}
