function largeImg(imgsrc, title)
{
  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=no, resizable=yes");
  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';
      wnd.moveTo((screen.availWidth - img.width - 16) / 2, (screen.availHeight - img.height - 16) / 2);
      wnd.resizeTo(img.width, img.height);
      oCanvas = wnd.document.getElementsByTagName(
        (wnd.document.compatMode && wnd.document.compatMode == "CSS1Compat") ? "HTML" : "BODY"
      )[0];
      c_width = oCanvas.clientWidth ? oCanvas.clientWidth : wnd.innerWidth;
      c_height = wnd.innerHeight ? wnd.innerHeight : oCanvas.clientHeight; // should be vice verca since Opera 7 is crazy!
      o_width = img.width - c_width;
      if(o_width < 0) o_width = 0;
      o_height = img.height - c_height;
      if(o_height < 0) o_height = 0;
      wnd.resizeBy(o_width, o_height);
      wnd.moveTo((screen.availWidth - img.width - o_width) / 2, (screen.availHeight - img.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;*/
  }
}
