cWin = null;

function ShowImage(pic, w, h){
	if(cWin && !cWin.closed) cWin.close();
	
	if (w > 650) var nw = 650;
	else var nw = w;
	
	var nh = Math.round(h/w*nw);

  pic = '<img onclick="window.close()" src="'+path+'image.php?f='+pic +'&w='+nw+'&h='+nh+'" border="0" style="cursor:hand" alt="Close window" onclick="self.close()">';
  cWin = window.open("", "ImageWindow", "width="+ nw+", height="+nh+", location=no,status=no,resizable=no,toolbar=no,scrollbars=no,menubar=no,top=100,left=100");
  with(cWin.document){
    open();// Для порядку - сначала откроем документ на запись
    write('<html><head><title>3dArt</title></head><body style="margin:0px;padding:0px">');
    write(pic+'</body></html>');
    close();
  }
  cWin.focus();	
}

var nWin = null;
function OpenWindow(link, w, h){
	if(nWin && !nWin.closed) nWin.close();
	var url = link;

	//--------------
	
 	if (self.screen) { // for NN4 and IE4
		width = screen.width
		height = screen.height
	}else if (self.java){ // for NN3 with enabled Java
		var jkit = java.awt.Toolkit.getDefaultToolkit();
		var scrsize = jkit.getScreenSize();
		width = scrsize.width;
		height = scrsize.height;
	}
	//--------------
	
	var top = (height - h) / 2;
	var left = (width - w) / 2;
	
  nWin = window.open(url, "OpenWindow", "width="+ w+", height="+h+", location=no,status=no,resizable=no,toolbar=no,scrollbars=yes,menubar=no,top="+top+",left="+left+"");
  nWin.focus();	
}
