image = 0;

function POpenImage(imagefile, imagedate, w, h, nav_bar)
{
 	if (nav_bar){
		wHeight = h+100;
		var hImageWnd = window.open('/image.php?image='+imagefile+'&date='+imagedate, 'PreviewImage', 'status=no,toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,width='+w+',height='+wHeight+',resizable=1,left=30,top=30');
    //alert(wHeight);
	}
	else{
		wHeight = h+100;
		var hImageWnd = window.open('', 'PreviewImage', 'status=no,toolbar=0,location=0,directories=0,menubar=0,scrollbars=0,width='+w+',height='+wHeight+',resizable=0,left=30,top=30');

		strHTML = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><title>Новый жилой комплекс на фонтане, Новостройка Одессы</title><style type="text/css">body{margin: 0px 0px 0px 0px;padding: 0px 0px 0px 0px;}</style><script language="javascript" type="text/javascript" src="/_js/images.js"></script></head><body><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="100%" align="center" valign="middle"><img id="mainImage" src="'+imagefile+'" width="'+w+'" alt="Новый жилой комплекс на фонтане, Новостройка Одессы" /></td></tr>';

		strHTML += '</table></body></html>';

	hImageWnd.document.write(strHTML);
		}
	hImageWnd.document.close();
	hImageWnd.focus();
}

function open_image(imgPath,title,alt,width,height) {
		var doc_width = width+30;
		var doc_height = height+30;
    var win = window.open('','preview',
    'width='+doc_width+',height='+doc_height+',left=0,top=0,resizable=0,scrollbars=0,status=0,location=0');
 
    var winDoc = win.document;
    if (title == undefined) title = 'Click to Close';
    if (alt   == undefined) alt   = 'Click to Close';
    var content = '<html><head><title>' + title + '</title>' +
    			  '<style>body{overflow: hidden;margin:0;}img{border:0;}</style>' +
    			  '</head><body><a href="javascript:self.close()">' +
    			  '<img alt="' + alt + '" id="image" src="' + imgPath + '" /></a></body></html>'
    win.document.write(content);
 
    winDoc.body.onload = function() {
    	var obj = winDoc.getElementById('image');
    	var w = obj.width, h = obj.height;
    	var iHeight= document.body.clientHeight, iWidth = self.innerWidth;
 
    	var left = (self.opera ? iWidth : screen.availWidth)/2 - w/2;
    	var top =  (self.opera ? iHeight : screen.availHeight)/2 - h/2;
    	win.resizeTo(w+10, h+26);
    	win.moveTo(left, top);
    }
 
    win.onload = winDoc.body.onload; // special for Mozilla
 
    // !!! Important statement: popup onload won't execute without it!
    win.document.close();
    win.focus();
} 
