function foto(s,i){
	//var w=open(s+"foto.html","popupfoto","toolbar=no,status=no,menubar=no,scrollbars=yes"
	//+",resizable=no,location=no,directories=no,width=500,height=400");
	
	if (!i) i = 0;
	
	var p = i -1;
	var n = i + 1;
	var m = 6; //numero max di foto
	if (s=='757' || s=='607open' || s=='dolphin21') m=6;
		else if (s=='607wa' || s=='737wa') m=4;
		else if (s=='647open') m=3;
			else m=5; 
	var foto = 'foto_'+s+'_'+i+'.jpg';
	var wy = 400;
	var wx = 700;
	var w = window.open("",s,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,copyhistory=0,width="+wx+",height="+wy+",screenX=10,screenY=10"); 
		
		w.focus();
		w.document.write(
			"<html><head>" +
			"<title>"+s+"</title><style>body{ " +
			"background-image:url(../images/fondopopup.jpg);" + 
			"background-repeat:no-repeat;" +
			"background-color:#E4E8EF; " +
			"margin:0px; " +
			"padding:0px; " +
			"font-family:verdana; " +
			"font-size:8pt; " +
			"color:#072067; " +
			"line-height:12pt; text-align:center;" +
			"} a { color:#072067; font-size:18pt; text-decoration:none;} a:hover {color: #ffffff;}" + 
			"#foto { border:1px solid #072067; position:relative; top:10px;}" +
			"#bottoni { position:absolute; top:350px; width:100px; left:300px; text-align:center;}" +
			"</style>" + 
			"</head><body></body></html>"
			);

		html = "" +
			"<img id='foto' src='../fotomodelli/"+ foto +"' alt='foto "+ s +"'/>" +
			"<div id='bottoni'>" +
			(p >= 0 ? "<a href=\"javascript:window.opener.foto('"+s+"'," + p +");\">&lt;</a> &nbsp; " : "&nbsp;&nbsp;&nbsp;&nbsp;") +
			(n <= m ? "<a href=\"javascript:window.opener.foto('"+s+"'," + n +");\">&gt;</a>" : "&nbsp;&nbsp;&nbsp;") +
			"</div></body></html>";
			
		w.document.body.innerHTML=html;

}