function preview_image(img_src) {
	pic = new Image();
	pic.src = img_src;
	setTimeout("preload_image(pic)",100);
}

function preload_image(pic){
	if (pic.width==0 || pic.height==0) {
		setTimeout("preload_image(pic)",100);  
	} else {
		view_image(pic.src, pic.width, pic.height);
	}
}

function view_image(img_src, img_width, img_height){
    if (img_width>screen.availWidth-150 || img_width==0) {
        win_width = screen.availWidth-150;
    } else {
        win_width = img_width+40;
    }
    if (img_height>screen.availHeight-150 || img_height==0) {
        win_height = screen.availHeight-150;
    } else {
        win_height = img_height+20;
    }
    win_top  = Math.abs((screen.availHeight-win_height)/3);
    win_left = Math.abs((screen.availWidth-win_width)/3);
    photoWindow = window.open('', '', 'top='+win_top+',left='+win_left+',width='+win_width+',height='+win_height+',resizable,scrollbars');
    photoWindow.document.write('<html><head><title>ÍÒÒ Ýíåðãèÿ</title>');
    photoWindow.document.write('<scr'+'ipt type=text/javascript>document.onkeypress = function CloseOnEsc(key) { if(document.all) { var keyCode = window.event.keyCode; } else { if (key.which == 0) {window.close();return;}   }  if (keyCode == 27) {window.close();return;} }</scr'+'ipt>');
    photoWindow.document.write('</head><body style="margin: 0; padding: 0; background: #fff;">');
    photoWindow.document.write('<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%"><tr><td align="center">');
    photoWindow.document.write('<img src="'+img_src+'" ');
    if ( (img_width>1) && (img_height>1) ) {
        photoWindow.document.write('width="'+img_width+'" height="'+img_height+'"');
    }
    photoWindow.document.write(' alt="Ùåë÷åê çàêðîåò îêíî" title="Ùåë÷åê çàêðîåò îêíî" onclick="window.close();">');
    photoWindow.document.write('</td></tr></table>');
    photoWindow.document.write('</body></html>');
    photoWindow.document.close();
}

function pop(obj, width, height) {
    if (!width) {
        width = 400;
    }
    if (!height) {
        height = 600;
    }
    popupWin = window.open(obj.href, 'view', 'width='+width+',height='+height+',scrollbars');
    popupWin.focus();
}