var Fading=function(){var that=this;this.elts=_$('catalogues-img-pt').getElementsByTagName('img');this.elt=this.elts[0];this.next=0;this.nextImg=new Image();this.lastChanged=0;this.nbElts=this.elts.length-1;this.coeff=this.elt.filters?1:100;this.allThumb=cat_imgs.length-1;this.courant=100;setTimeout(function(){that.suivant();},2000);};Fading.prototype.suivant=function(){var imgToChange,that=this;this.next=Math.round(Math.random()*this.allThumb);do{imgToChange=Math.round(Math.random()*this.nbElts);}while(imgToChange===this.lastChanged);this.nextImg.src='/CICEWEB9_WEB/catalogues/'+cat_imgs[this.next];this.elt=this.elts[imgToChange];this.lastChanged=imgToChange;if(this.elt.filters){this.elt.zoom=1;this.elt.style.filter='alpha(opacity=100)';this.elt.filters[0].opacity=100;this.propOp=this.elt.filters[0];}else{this.elt.style.opacity=1;this.propOp=this.elt.style;}this.changeOp(100,0,true);};Fading.prototype.changeOp=function(from,to,callback){var that=this;if(from==to){this.propOp.opacity=to/this.coeff;if(callback){this.elt.onload=function(){that.changeOp(0,100,false);};this.elt.src=this.nextImg.src;}else{setTimeout(function(){that.suivant();},2000);}}else{this.propOp.opacity=this.courant/this.coeff;var pas=from<to?5:-5;this.courant=Math.abs(from-to)<5?to:from+pas;this.timer=setTimeout(function(){that.changeOp(that.courant,to,callback);},25);}};addEvent(window,'load',function(){new Fading();});
