var Galerie=new Class({Implements:Options,zIndex:9000,currentIndex:0,ui:{},photos:new Array(),options:{article:"",startIndex:0},initialize:function(a){this.setOptions(a);if(this.options.startIndex){this.currentIndex=this.options.startIndex-1}new Request.JSON({url:"sys.galerie.asp?ACTION=GET_PHOTOS&ARTICLE="+this.options.article,onSuccess:this.buildInterface.bind(this)}).send()},buildInterface:function(a){this.photos=a;this.ui.fondNoir=new Element("div",{"class":"fondNoir"});this.ui.fondNoir.setStyle("z-index",this.zIndex);this.ui.screen=new Element("div",{"class":"galerieScreen"});this.zIndex++;this.ui.screen.setStyle("z-index",this.zIndex);this.ui.img=new Element("img");this.ui.screen.adopt(this.ui.img);this.zIndex++;this.ui.legend=new Element("div",{style:"color:white; font:normal 10pt sans-serif; text-align:center; z-index:"+this.zIndex+";"});this.ui.legendNavig=new Element("div");this.ui.legendPhoto=new Element("div",{style:"font-weight:bold;margin-top:10px;"});this.ui.legend.adopt(this.ui.legendNavig,this.ui.legendPhoto);this.ui.close=new Element("img",{src:"js/galerie/close.png",width:30,height:30,style:"cursor:pointer;z-index:"+this.zIndex+";"});this.ui.close.addEvent("click",this.close.bind(this));this.ui.fondNoir.addEvent("click",this.close.bind(this));this.ui.previous=new Element("img",{src:"js/galerie/previous.png",width:35,height:35,style:"cursor:pointer;z-index:"+this.zIndex+";"});this.ui.previous.addEvent("click",this.previous.bind(this));this.ui.next=new Element("img",{src:"js/galerie/next.png",width:35,height:35,style:"cursor:pointer;z-index:"+this.zIndex+";"});this.ui.next.addEvent("click",this.next.bind(this));$(document.body).adopt(this.ui.fondNoir,this.ui.screen,this.ui.close,this.ui.legend,this.ui.previous,this.ui.next);this.ui.screen.fade("hide");this.ui.screen.fade("in");this.ui.previous.fade("hide");this.ui.next.fade("hide");this.displayPhoto(this.currentIndex)},displayPhoto:function(b){this.currentIndex=b;var a=this.photos[b];this.ui.screen.setStyles({width:Math.max(a.width,300)+"px",height:a.height+"px"});this.ui.img.fade("hide");new Asset.image(this.photos[b].url,{onload:this.imageReady.bind(this)});this.ui.screen.position();this.ui.close.position({relativeTo:this.ui.screen,position:"topRight",edge:"center"});this.ui.legendNavig.set("text","Photo "+(b+1)+" / "+this.photos.length);this.ui.legendPhoto.set("html",a.libelle);this.ui.legend.position({relativeTo:this.ui.screen,position:"bottomCenter",edge:"topCenter",offset:{x:0,y:12}});this.ui.previous.position({relativeTo:this.ui.screen,position:"bottomCenter",edge:"topRight",offset:{x:-100,y:2}});this.ui.next.position({relativeTo:this.ui.screen,position:"bottomCenter",edge:"topLeft",offset:{x:100,y:2}});this.ui.previous.fade(this.currentIndex>0?"in":"out");this.ui.next.fade(this.currentIndex<this.photos.length-1?"in":"out")},imageReady:function(){this.ui.img.src=this.photos[this.currentIndex].url;this.ui.img.fade("in");if(this.currentIndex>0){new Asset.image(this.photos[this.currentIndex-1].url)}if(this.currentIndex<this.photos.length-1){new Asset.image(this.photos[this.currentIndex+1].url)}},previous:function(){if(this.currentIndex>0){this.displayPhoto(this.currentIndex-1)}},next:function(){if(this.currentIndex<this.photos.length-1){this.displayPhoto(this.currentIndex+1)}},close:function(){this.ui.fondNoir.destroy();new Fx.Tween(this.ui.screen,{duration:"short",onComplete:this.closeHandler.bind(this)}).start("opacity",0)},closeHandler:function(){this.ui.screen.destroy();this.ui.close.destroy();this.ui.legend.destroy();this.ui.previous.destroy();this.ui.next.destroy()}});var GalerieZoom=new Class({Implements:Options,zIndex:9000,ui:{},options:{imgSrc:""},initialize:function(a){this.setOptions(a);this.options.imgSrc="sys.image.asp?image="+this.options.imgSrc;this.buildInterface()},buildInterface:function(){this.ui.fondNoir=new Element("div",{"class":"fondNoir"});this.ui.fondNoir.setStyle("z-index",this.zIndex);this.ui.screen=new Element("div",{"class":"galerieScreen"});this.zIndex++;this.ui.screen.setStyle("z-index",this.zIndex);this.ui.img=new Element("img");this.ui.screen.adopt(this.ui.img);this.zIndex++;this.ui.close=new Element("img",{src:"js/galerie/close.png",width:30,height:30,style:"cursor:pointer;z-index:"+this.zIndex+";"});this.ui.close.addEvent("click",this.close.bind(this));this.ui.fondNoir.addEvent("click",this.close.bind(this));this.ui.screen.addEvent("click",this.close.bind(this));$(document.body).adopt(this.ui.fondNoir,this.ui.screen,this.ui.close);this.ui.screen.setStyle("opacity",0);this.displayPhoto()},displayPhoto:function(){this.ui.img.src=this.options.imgSrc;new Asset.image(this.options.imgSrc,{onLoad:this.imageReady.bind(this)})},imageReady:function(){this.ui.screen.position();this.ui.close.position({relativeTo:this.ui.screen,position:"topRight",edge:"center"});new Fx.Tween(this.ui.screen,{duration:"normal"}).start("opacity",1)},close:function(){this.ui.fondNoir.destroy();new Fx.Tween(this.ui.screen,{duration:"short",onComplete:this.closeHandler.bind(this)}).start("opacity",0)},closeHandler:function(){this.ui.screen.destroy();this.ui.close.destroy()}});var GalerieDiaporama=new Class({Implements:Options,photos:new Array(),timer:null,currentIndex:0,options:{article:"",showmini:true,pId:"",delai:0,infiniteLoop:true},initialize:function(a){this.setOptions(a);new Request.JSON({url:"sys.galerie.asp?ACTION=GET_PHOTOS&ARTICLE="+this.options.article+"&SHOWMINI="+this.options.showmini,onSuccess:this.loadedHandler.bind(this)}).send()},loadedHandler:function(a){var b=this.options.delai;if(!b){b=1}this.photos=a;this.timer=this.nextPhoto.periodical(b*1000,this)},next:function(){var a=this.currentIndex+1;if(a>=this.photos.length){a=0;if(!this.options.infiniteLoop){clearInterval(this.timer);this.timer=null}}return a},nextPhoto:function(){this.currentIndex=this.next();var a=this.photos[this.currentIndex];this.Elt("img").fade("hide");var b=new Asset.image(this.photos[this.currentIndex].url,{onload:this.imageReady.bind(this)})},imageReady:function(b){this.Elt("img").src=this.photos[this.currentIndex].url;this.Elt("img").fade("hide");this.Elt("img").fade("in");this.Elt("cite").set("text",this.photos[this.currentIndex].libelle);var a=new Asset.image(this.photos[this.next()].url)},Elt:function(a){return $$("p#"+this.options.pId+" "+a)[0]}});var GalerieSlider=new Class({Implements:Options,photos:new Array(),currentIndex:0,ui:{},options:{article:"",showmini:true,pId:""},initialize:function(a){this.setOptions(a);new Request.JSON({url:"sys.galerie.asp?ACTION=GET_PHOTOS&ARTICLE="+this.options.article+"&SHOWMINI="+this.options.showmini,onSuccess:this.loadedHandler.bind(this)}).send()},loadedHandler:function(a){this.photos=a;this.ui.img=this.Elt("img");this.ui.prev=new Element("img",{src:"js/galerie/previous.png",width:35,height:35,style:"cursor:pointer;"});this.ui.next=new Element("img",{src:"js/galerie/next.png",width:35,height:35,style:"cursor:pointer;"});this.ui.prev.addEvent("click",this.previous.bind(this));this.ui.next.addEvent("click",this.next.bind(this));this.ui.prev.inject(this.ui.img,"before");this.ui.next.inject(this.ui.img,"after");this.ui.prev.fade("hide");this.ui.next.fade("show")},previous:function(){if(this.currentIndex>0){this.displayPhoto(this.currentIndex-1)}},next:function(){if(this.currentIndex<this.photos.length-1){this.displayPhoto(this.currentIndex+1)}},displayPhoto:function(b){this.currentIndex=b;var a=this.photos[this.currentIndex];this.ui.img.fade("hide");var c=new Asset.image(this.photos[this.currentIndex].url,{onload:this.imageReady.bind(this)});this.ui.prev.fade(this.currentIndex>0?"in":"out");this.ui.next.fade(this.currentIndex<this.photos.length-1?"in":"out")},imageReady:function(){this.ui.img.src=this.photos[this.currentIndex].url;this.ui.img.fade("hide");this.ui.img.fade("in");this.Elt("cite").set("text",this.photos[this.currentIndex].libelle);if(this.currentIndex>0){var a=new Asset.image(this.photos[this.currentIndex-1].url)}if(this.currentIndex<this.photos.length-1){var a=new Asset.image(this.photos[this.currentIndex+1].url)}},Elt:function(a){return $$("p#"+this.options.pId+" "+a)[0]}});
