window.onload=function(){
if(!document.getElementById || !document.getElementsByTagName) return;
attivaGallery();
attivaFade();
}

function attivaGallery(){ //gestisce gli eventi per gli ingrandimenti
var links=document.getElementById("minipics").getElementsByTagName("a");
for(var i=0;i<links.length;i++)
    links[i].onclick=function(){Show(this);return(false)};
}

function Show(obj){    //mostra gli ingrandimenti
var bigimg=document.getElementById("bigimage");
var imagepath=obj.getAttribute("href");
var smallimg=obj.getElementsByTagName("img")[0];
bigimg.style.visibility="hidden";
bigimg.src=imagepath;
bigimg.title=smallimg.title;
bigimg.alt=smallimg.alt;
preloadimg=new Image();        //precarica l' immagine prima dell' effetto fade
preloadimg.src=imagepath;
Controlla();
bigimg.style.visibility="visible";
fadeIn("bigimage",0); //aggiunta rispetto alla versione originale
}

function attivaFade(){  //cambia l' opacitý sulle miniature
var imgs=document.getElementById("minipics").getElementsByTagName("img");
for(var i=0;i<imgs.length;i++){
    imgs[i].onmouseover=function(){setOpacity(this,40)};
    imgs[i].onmouseout=function(){setOpacity(this,100)};
    }
}

function setOpacity(obj,opacity){
opacity=(opacity==100) ? 99.999 : opacity;
obj.style.filter = "alpha(opacity:"+opacity+")";  // IE/Win
obj.style.KHTMLOpacity = opacity/100; // Safari<1.2, Konqueror
obj.style.MozOpacity = opacity/100;   // Older Mozilla and Firefox
obj.style.opacity = opacity/100;      // Safari 1.2, newer Firefox and Mozilla, CSS3
}

function fadeIn(objId,opacity) {
obj = document.getElementById(objId);
if(opacity <= 100){
  setOpacity(obj,opacity);
  opacity += 10;
  window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
  }
}