Fuic.Slideshow=function(a){this._createSimpleFadingSlideshow=function(c){this.box=c.box;this.delay=c.delay||3000;this.elts=this.box.getChildren();this.autoplay=c.autoplay||false;var b=0;this.next=c.next||false;this.previous=c.previous||false;this.elts.each(function(d){if(b!=0){d.setStyle("display","none")}d.setStyles({position:"absolute",top:"0"});b++},this);this.cI=0;this.showPrevious=function(){var f=this.elts[this.cI];var d=(this.cI-1)%this.elts.length;var e=this.elts[d];f.smoothSwitch(500);e.smoothSwitch(500);this.cI=d};this.showNext=function(){var f=this.elts[this.cI];var d=(this.cI+1)%this.elts.length;var e=this.elts[d];f.smoothSwitch(500);e.smoothSwitch(500);this.cI=d};this.play=function(){this.showNext.periodical(this.delay,this)};if(this.autoplay){this.play()}if(this.next){this.next.addEvent("click",this.showNext.bind(this))
}if(this.previous){this.previous.addEvent("click",this.showNext.bind(this))}};this._createAdvancedSlideshow=function(b,d,c){this.content=b.div||null;this.inject=b.inject||"bottom";this.name=b.name||null;this.baseEvent="feC_slideshow_"+this.name+"_";this.events=b.events||null;this.optionsXml=d||null;this.options=c;window.addEvent(this.baseEvent+"error",($defined(this.events.error)?this.events.error:function(){}));window.addEvent(this.baseEvent+"complete",($defined(this.events.complete)?this.events.complete:function(){}));this.options.onComplete=this.events.complete;window.addEvent(this.baseEvent+"first",($defined(this.events.first)?this.events.first:function(){}));window.addEvent(this.baseEvent+"previous",($defined(this.events.previous)?this.events.previous:function(){}));window.addEvent(this.baseEvent+"pause",($defined(this.events.pause)?this.events.pause:function(){}));
window.addEvent(this.baseEvent+"next",($defined(this.events.next)?this.events.next:function(){}));window.addEvent(this.baseEvent+"last",($defined(this.events.last)?this.events.last:function(){}));if(!$(this.name)){var e=new Element("div",{id:this.name,"class":"slideshow"}).inject(this.content,this.inject)}this.treatOptions();this.loadXml();this.slideshow=null};if(a.type==="simplefading"){this._createSimpleFadingSlideshow(a)}else{if(a.type==="advanced"){this._createAdvancedSlideshow({div:a.box,inject:a.inject,name:a.name,events:a.events},a.xml,a.options)}}};Fuic.Slideshow.prototype.destroy=function(){if(this.slideshow){this.slideshow.destroy("empty");window.removeEvent(this.baseEvent+"error",this.events.error);window.removeEvent(this.baseEvent+"complete",this.events.complete)}};Fuic.Slideshow.prototype.treatOptions=function(){this.optionsXml={template:feC.backendUrl+"?a=rssreader&life=0&tpl="+this.optionsXml.template||null,flux:this.optionsXml.flux||null,nbItems:this.optionsXml.nbItems||-1,root:this.optionsXml.root||null,items:this.optionsXml.items||null,title:this.optionsXml.title||null,enclosure:this.optionsXml.enclosure||null,link:this.optionsXml.link||null,extend:JSON.encode(this.optionsXml.extend)||JSON.encode({})};
this.optionsXml.template+="&url="+this.optionsXml.flux;this.optionsXml.template+="&name="+this.name;this.optionsXml.template+="&nbitem="+this.optionsXml.nbItems;this.optionsXml.template+="&root="+encodeURIComponent(this.optionsXml.root);this.optionsXml.template+="&items="+encodeURIComponent(this.optionsXml.items);this.optionsXml.template+="&title="+encodeURIComponent(this.optionsXml.title);if(this.optionsXml.enclosure==null){return false}this.optionsXml.template+="&enclosure="+encodeURIComponent(this.optionsXml.enclosure);this.optionsXml.template+="&link="+encodeURIComponent(this.optionsXml.link);this.optionsXml.template+="&extend="+encodeURIComponent(this.optionsXml.extend)};Fuic.Slideshow.prototype.loadXml=function(){feC.callAjax(this.optionsXml.template,(function(a){this.xml=a;if(this.xml.getElements("empty").length!=1){this.treatXml();
this.createSlideshow()}else{window.fireEvent(this.baseEvent+"error")}}).bind(this),{xml:true})};Fuic.Slideshow.prototype.treatXml=function(){this.images={};this.xml.getElements("item").each((function(b,a){this.images[a]={image:b.getElement("enclosure").textContent,caption:b.getElement("title").textContent,href:b.getElement("link").textContent};var c=JSON.decode(this.optionsXml.extend);for(j in c){this.images[a][j]=b.getElement(j).textContent}}).bind(this));this.nbimages=this.xml.getElements("item").length};Fuic.Slideshow.prototype.createSlideshow=function(){this.slideshow=new Slideshow(this.name,this.images,this.options)};