
var img=new Array();
var galindex=0;


function FillArrayImages()
{

   for (var  i=0; i<arguments.length; i++)
   {
    img[i]=new Image();
    img[i].src=arguments[i];
    } 
}

function Next()
{
    if (((galindex+1) % img.length)==0)
        galindex=0;
    else
        galindex++;
     
    PhotoGallery(galindex);          
}

function Zoom()
{
  

// Ho dovuto usare un trucchetto per togliere le [] Xchè firefox fa le bizze.
   var re = new RegExp('\\d+x\\d+','g');
   var Match=img[galindex].src.match(re);
  
   if (Match)
   {
     var image=img[galindex].src.replace(Match,'').replace(/i_/g,'z_').replace(/%5B/g,'').replace(/%5D/g,'').replace(/\[|\]/g,'');   
    
      re=/\d+/g;
      size=Match.toString().match(/\d+/g,'');
    
      var zoom=window.open('','zoom','width='+size[0]+ ', height='+size[1]+', status=0');
      zoom.resizeTo(size[0],size[1]);
      
      immagine= zoom.document.getElementById("image");
      
      if (immagine)
        immagine.src=image; 
      else
         zoom.document.write('<html><title>Ingrandimento</title><body style="margin:0px; padding:0px"><img id="image" alt="ingrandimento" src="' + image + '"></body></html>'); 
      
    
  } 
  else
     alert ("Siamo spiacenti,\nl'ingrandimento non e' disponibile");

}

function PhotoGallery(index)
{

if (img.length>0)
{
//var preview=document.getElementById("preview");
//preview.visibility='show';
//preview.style.display='block';

    var photoGallery=document.getElementById("photogallery");
    var imagepreview=document.getElementById("imagepreview");
    photoGallery.innerHTML="Photogallery&nbsp;&nbsp;&nbsp;&nbsp;";
    imagepreview.src=img[index].src;

    for( var i=0;i<img.length;i++)
    {
        if (i==index)
         photoGallery.innerHTML+= (i+1)  ; 
       else 
         photoGallery.innerHTML+='<font color="#aad8f5">' + (i+1) + '</font>'; 
       
       if (i<img.length-1)
       photoGallery.innerHTML+=" / ";
    }
}

}
