
var index = 0;
var altern = "";
function CambiaFoto(x , idClient,isBig)
	{
	 if(x < 0 ){ x = index = 0; }
	 if(x > photos.length - 1){x = index = photos.length - 1; }
	 if(x >= 0 && x <= photos.length)
	 {
	  document.images[idClient + 'Foto'].src = photos[x];
	  document.images[idClient + 'Foto'].alt = alternate[x];
	  //altern = alternate[x];
	 
	  fotogrande = bigLinks[x];
	  var titoloFoto = new getElementId(document,idClient + 'start');
	  titoloFoto.element.innerText = x + 1;
	 }
	}
	
	
function apri(bigLinks,page,format)
	{
	//if(fotogrande=="#") return false;
	var queryString = "?";
	var isFormat = false;
	var totBigLinks = 0;
	for (var i = 0;i < bigLinks.length ; i++)
	{
	   if(bigLinks[i] != "#")
	   {
	    isFormat = true;
		isLast = (i == (bigLinks.length - 1));
		and = isLast ? "" : "&";
		queryString += "foto" + (i+1) + "=" + bigLinks[i] + "$" + bigAlternate[i]  +  and;
	    totBigLinks++;
	   }
	}
	if(isFormat)
	{
		queryString += "&formato=" + format;
		queryString += "&index=" + index;
	}
   
	if (queryString.length > 1 && index+1 <= totBigLinks)
	{
		window.open('http://' + page + queryString  ,'Dettaglio','width=450,height=370,top=100,left=100,resizable=no,location=no,toolbar=no,menubar=no,status=no');
	}
		return false;
	}

function changeTitle(y)
{
  
   if (y <0) y = 0;
   if (y > 5) y = alternate.length - 1;
   if(y >= 0 && y < alternate.length)
   {
		title = new getElementId(document,"titolo");
		title.element.innerText = alternate[y] ;
   }
}

