var string2;
var img_type=3;

function Enlarge(img,title,n)
{
  foto1= new Image();
  foto1.src=(img);
	img_type=n;
	string2 = (title);
  Control(img);
}
function Control(img)
{
  if((foto1.width!=0)&&(foto1.height!=0))
	{
    viewFoto(img);
  }
  else
	{
    funzione= "Control('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}




function viewFoto(img)
{
  largh=foto1.width+20;
  altez=foto1.height+55;
	r1= (screen) ? (largh/(screen.availWidth-10)) : largh/(800-10);
	r2= (screen) ? (altez/(screen.availHeight-95)) : altez/(600-95);
	r=Math.max(r1,r2);
	if (r<0.98) sc=1
	else sc=0.98/r;
	newPhotoWidth=Math.floor(foto1.width*sc);
	newPhotoHeight=Math.floor(foto1.height*sc);
  largh=newPhotoWidth+20;
  altez=newPhotoHeight+55;

  	LeftPosition = (screen.width) ? (screen.availWidth-largh)/2 : 0;
	TopPosition =  (screen.height) ? (screen.availHeight-altez-95)/2 : 0;
	stringa= 'width='+largh+',height='+altez+',top='+TopPosition+',left='+LeftPosition+',directories=no,location=no,scrollbars=no,resizable=yes';
if (img_type==1)
	{  finestra= window.open('photo.htm','',stringa);
		var tmp=finestra.document;
		tmp.writeln('<html><head><title>'+string2+'</title>'); 
		tmp.writeln('<link rel="stylesheet" href="lowerway.css">'); 
		tmp.writeln('</head><body class="photo_popup">'); 
		tmp.writeln('<img src="'+img+'" width="'+newPhotoWidth+'" >'); 
		tmp.writeln('<p class="photo_caption">'+string2+'</p>'); 
		tmp.writeln('</body></html>'); 
		tmp.close(); 
	}
else
	{  finestra= window.open('art.htm','',stringa);
		var tmp=finestra.document;
		tmp.writeln('<html><head><title>'+string2+'</title>'); 
		tmp.writeln('<link rel="stylesheet" href="lowerway.css">'); 
		tmp.writeln('</head><body class="art_popup">'); 
		tmp.writeln('<img src="'+img+'" width="'+newPhotoWidth+'" >'); 
		tmp.writeln('<p class="art_caption">'+string2+'</p>'); 
		tmp.writeln('</body></html>'); 
		tmp.close(); 
	}
}
