var WidgetDiaporama=new Class({Implements:Options,options:{container:null,width:0,height:0,period:4,photos:[],urls:[],legends:[],controls:false,controlsSize:0},ui:{},timer:null,currentIndex:0,initialize:function(a){this.setOptions(a);this.ui.container=$(this.options.container);if(!this.options.photos||this.options.photos.length==0){return}this.buildUI();if(this.options.controls){this.buildControls();this.ui.container.addEvent("mouseover",this.stopTimer.bind(this));this.ui.container.addEvent("mouseout",this.startTimer.bind(this))}this.displayPhoto(0);this.startTimer()},startTimer:function(){if(this.timer){clearInterval(this.timer)}this.timer=this.nextPhoto.periodical(this.options.period*1000,this)},stopTimer:function(){if(this.timer){clearInterval(this.timer)}},setUrl:function(a,b){if(b){a.setStyle("cursor","pointer");a.addEvent("click",function(){window.location=b})}else{a.setStyle("cursor","");a.removeEvents("click")}},buildControls:function(){var d,a,b,c;if(this.options.controlsSize==0){d="Previous";a="Next";b=35;c=65}else{d="PreviousSmall";a="NextSmall";b=15;c=28}this.ui.previous=new Element("div."+d,{styles:{"margin-top":((-this.options.height-c)/2)+"px","margin-left":"-"+b+"px"},events:{click:this.previousPhoto.bind(this,e)}});this.ui.container.adopt(this.ui.previous);this.ui.next=new Element("div."+a,{styles:{"margin-top":((-this.options.height-c)/2)+"px","margin-left":(this.options.width)+"px"},events:{click:this.nextPhoto.bind(this,e)}});this.ui.container.adopt(this.ui.next);if(this.options.legends.length>0){this.ui.legend=new Element("div.Legend",{text:"Légende ..."});this.ui.legend.setStyles({width:(this.options.width-10)+"px","margin-top":"-25px"});this.ui.legend.hide();this.ui.container.adopt(this.ui.legend)}this.ui.bullets=new Element("ul.Bullets");var f;for(var e=0;e<this.options.photos.length;e++){this.ui.bullets.adopt(new Element("li",{events:{click:this.displayPhoto.bind(this,e)}}))}this.ui.bullets.getElements("li")[0].className="On";this.ui.container.adopt(this.ui.bullets);this.ui.bullets.position({relativeTo:this.ui.container,position:"bottomLeft",edge:"bottomLeft",offset:{x:2,y:-5}});if(this instanceof WidgetDiaporamaRotator&&Browser.ie&&Browser.version<=7){this.ui.previous.setStyle("margin-top",((this.options.height-c)/2)+"px");this.ui.next.setStyle("margin-top",((this.options.height-c)/2)+"px");this.ui.legend.setStyle("margin-top",(this.options.height-25)+"px");this.ui.legend.setStyle("opacity",0.5)}},previousPhoto:function(){var a=this.currentIndex-1;if(a<0){a=this.options.photos.length-1}this.displayPhoto(a)},nextPhoto:function(){this.displayPhoto((this.currentIndex+1)%this.options.photos.length)},displayPhoto:function(a){if(this.options.controls){this.ui.bullets.getElements("li")[this.currentIndex].className="";this.ui.bullets.getElements("li")[a].className="On"}if(this.options.legends.length>0){if(this.options.legends[a]){this.ui.legend.show();this.ui.legend.set("text",this.options.legends[a])}else{this.ui.legend.hide()}}this.displayPhotoAnimation(a);this.currentIndex=a},buildUI:function(a){},displayPhotoAnimation:function(a){}});var WidgetDiaporamaFade=new Class({Extends:WidgetDiaporama,buildUI:function(){this.ui.img=new Element("img",{src:this.options.photos[0],styles:{width:this.options.width,height:this.options.height,display:"block"}});this.setUrl(this.ui.img,this.options.urls[0]);this.ui.img.set("tween",{duration:"long"});this.ui.container.adopt(this.ui.img);new Asset.image(this.options.photos[(this.currentIndex+1)%this.options.photos.length])},displayPhotoAnimation:function(a){this.ui.img.fade("hide");this.ui.img.src=this.options.photos[a];this.setUrl(this.ui.img,this.options.urls[a]);this.ui.img.fade("in");new Asset.image(this.options.photos[(a+1)%this.options.photos.length])}});var WidgetDiaporamaRotator=new Class({Extends:WidgetDiaporama,fx:null,buildUI:function(){this.ui.div=new Element("div.Scroller",{styles:{width:(this.options.width*this.options.photos.length)+"px",height:this.options.height+"px"}});if(Browser.ie&&Browser.version<=7){var b=new Element("div",{styles:{width:this.options.width+"px",height:this.options.height+"px",position:"absolute",overflow:"hidden"}});this.ui.container.adopt(b);b.adopt(this.ui.div)}else{this.ui.container.adopt(this.ui.div)}this.fx=new Fx.Tween(this.ui.div,{duration:"long",link:"cancel",transition:Fx.Transitions.Expo.easeOut});var a;for(var c=0;c<this.options.photos.length;c++){a=new Element("img",{src:this.options.photos[c]});this.setUrl(a,this.options.urls[c]);this.ui.div.adopt(a);if(c>0){new Asset.image(this.options.photos[c])}}},displayPhotoAnimation:function(a){this.fx.start("margin-left",-this.options.width*this.currentIndex,-this.options.width*a)}});
