
var k=0;
var rWin,rImg;

function rWindow(win,img){
	if (img.width > 30 && img.height > 30) {  // размер дефольтной незагруженной картинки обычно менее чем 30x30 
		w = win.innerWidth || win.document.body.clientWidth;
		h = win.innerHeight || win.document.body.clientHeight;
		win.resizeBy(img.width - w, img.height - h);
		win.moveTo((screen.availWidth-img.width)/2,(screen.availHeight-img.height)/2);
	} else {
		k++
		rWin = win
		rImg = img
		setTimeout('rWindow(rWin,rImg)',100);
	}
}

var r_id = Math.random();
r_id = Math.round(r_id*10000);

function imgOpen(url){
  try {
	mywin.close();
  } catch (e){
	// none
  } finally {
	mywin = window.open("","bigPhoto"+r_id,'width=250,height=110,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=0');
	mywin.document.open();
	mywin.document.write("<HTML><body style=overflow:hidden;margin:0px;border:0px;padding:0px;background:#cccccc>");
	mywin.document.write("<table width=100% height=100% border=0 cellspacing=0 cellpadding=0><tr><td align=center>");
	mywin.document.write("<a href='#' title='чръЁvЄ№ юъэю' style='cursor:hand'><img id=myImg src="+url+" onClick='window.close()' border=0></a><br>");
	mywin.document.write("</td></tr></table>");
	mywin.document.write("<scr"+"ipt>window.focus();resizeWindow();function resizeWindow(){window.opener.rWindow(window,document.images.myImg);}</scr"+"ipt>");
	mywin.document.write("</body></HTML>");
	mywin.document.close();
  }
//  return false;
}       
