function openWindow(url,width,height,wleft,wtop)
{
   if ((width > screen.width) || (height+25>screen.height)){
       scrollbars = 'yes';
       width = screen.width - 12;
       height = screen.height - 68;
       wleft = wtop = 0;
   } else {
       scrollbars = 'no';
       wleft = wleft?wleft:(screen.width-width)/2;
       wtop = wtop?wtop:(screen.height-height)/4;
   }
   return window.open(url,'wnd'+Math.floor( Math.random()*1000000 ),'width='+width+',height='+height+',status=no,menubar=no,resizable=yes,scrollbars='+scrollbars+',left='+wleft+',top='+wtop);
}

function showImage(url,width,height,title)
{
  var wnd = openWindow('',width,height);
  
  var html = '<html><head>';
  if (title) html += '<title>'+title+'</title>';
  html += '</head><body style="margin:0px;padding:0px"><center>';
  html += '<a href="javascript:window.close()" title="Щёлкните, чтобы закрыть окно">';
  html += '<img border="0" src="'+url+'" width="'+width+'" height="'+height+'"></a></center></body></html>';
  
  wnd.document.open();  
  wnd.document.write(html);
  wnd.document.close();
}


