var fin=null;
var Immagine;
var fintemp;
var s;

function attendi()
	{
	var t, foto;
	if (Immagine.complete) 
		{
		clearTimeout(t);
		Dati="toolbar='no',location='no',status='no',menubar='no',resizable='no',directories='no'";
		x=Immagine.width;
		y=Immagine.height;
		ax=0;
		foto=Immagine.src;
		if (x>screen.width) 
			{
			s="yes";
			x=screen.width-50;
			offx=12;
			offy=17;
			}
		if (y>screen.height)
			{
			s="yes";
			y=screen.height-80;
			offy=17;
			offx=12;
			ax=1;
			}
		fintemp.close();
		sx=(screen.width-x-offx)/2;
		if (ax != 1)
			{
			ax=(screen.height-y-offy)/2;
			}
		if (fin !=null && fin.closed == false) fin.close(); 
		fin=window.open(foto,"popup",Dati+",scrollbars='"+s+"',width="+(x+offx)+",height="+(y+offy)+",top="+ax+",left="+sx);
		if (fin ==null || fin.closed == true)
			{
			window.alert("Devi abilitare i Popup altrimenti non vedrai nulla!");
			return;
			}
		fin.focus();
		fin.document.writeln("<HTML>");
		fin.document.writeln("<BODY>");
		fin.document.writeln("<DIV style=\"position:absolute; left:0px; top:0px\">");
		fin.document.writeln("<DIV><IMG SRC=\""+foto+"\"></DIV>");
		fin.document.writeln("<script language='Javascript'>");
		fin.document.writeln("var url='/cgi-bin/fixit-counter/stats.pl?count=yes&amp;pag="+foto+"';");
		fin.document.writeln("preloadOn = new Image(1, 1);");
		fin.document.writeln("preloadOn.src = url;");
		fin.document.writeln("</script>");
		fin.document.writeln("</BODY>");
		fin.document.writeln("</HTML>");
		}
	else t=setTimeout("attendi()",300);
	}

function creapopup(url)
{

	s="no";
	offx=0;
	offy=0;
	fintemp=window.open("about:blank","test","toolbar='no',location='no',status='no',menubar='no',resizable='no',directories='no',scrollbars='no',top="+(screen.width-300)/2+",left="+(screen.height-200)/2+",width=300,height=200");
	fintemp.focus();
	fintemp.document.writeln("<HTML>");
	fintemp.document.writeln("<BODY>");
	fintemp.document.writeln("<BR><BR><BR><H1 align=\"center\">Loading...</H1>");
	fintemp.document.writeln("</BODY>");
	fintemp.document.writeln("</HTML>");
	Immagine=new Image();
	Immagine.src=url;
	attendi();

}
