
function CaricaFoto(img,title){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img,title);
}
function Controlla(img,title){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img,title);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img,title){
  largh=foto1.width;
  altez=foto1.height;
  stringa="width="+largh+",height="+altez;
  finestra=showimg(img,largh,altez,title);
}

var showWinimg 
function showimg(a, b, c, d) {
	    var left = (screen.width  - b)  / 2;
		var top = (screen.height - c) / 3;
    if (showWinimg) showWinimg.close() 
    showWinimg = window.open( "", "", "top="+top+",left="+left+",width="+b+",height="+c); 
    showWinimg.document.write( 
        '<head><title>mreestr.ru  '+ d +'</title><style> img {border:0} </style></head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>'+ 		'<a href="#" onclick="window.close()">'+
        '<img src='+ a +' title="Закрыть окно">'+
		'</a></body>'
    ) 
    showWinimg.document.close() 
}






var showWinimg 
function printt(a, d) {
		var b = 200;
		var c = 100;
	    var left = (screen.width  - b)  / 2;
		var top = (screen.height - c) / 3;
    if (showWinimg) showWinimg.close() 
    showWinimg = window.open( "", "", "top="+top+",left="+left+",width="+b+",height="+c); 
    showWinimg.document.write( 
        '<head><title>mreestr.ru  '+ d +'</title><style> img {border:0} </style>'+
		 '<style type="text/css" media="screen"> '+
 'body {'+
 'background-color: #f0f0f0;'+
 'font: 0.8em Verdana, Tahoma, Arial, Helvetica, sans-serif;'+
 '}'+
 '#pr {display:none}'+
 '</style>'+
 '<style type="text/css" media="print">'+
 '* {'+
 'font-family: "Times New Roman", Times, serif;'+
 'background-color: #fff;'+
 'color: #000;'+
 '}'+
 '#nopr {display:none}'+
' </style>'+
		'</head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0 onload="window.print(); window.close()">'+
        '<span id="nopr">Подготовка к печати</span><img id="pr" src='+ a +'>'+
		'</body>'
    ) 
    showWinimg.document.close() 
}
