var Slimbox;(function(){var x={},w=0,y,r,AC,k,j,o,AF,z,q,t=new Image(),s=new Image(),f,AG,n,v,g,AH,u,e,AB;window.addEvent("domready",function(){AF=h.bindWithEvent();$(document.body).adopt($$([f=new Element("div",{id:"lbOverlay"}),AG=new Element("div",{id:"lbCenter"}),AH=new Element("div",{id:"lbBottomContainer"})]).setStyle("display","none"));n=new Element("div",{id:"lbImage"}).injectInside(AG).adopt(v=new Element("a",{id:"lbPrevLink",href:"#"}),g=new Element("a",{id:"lbNextLink",href:"#"}));v.onclick=AA;g.onclick=l;var A;u=new Element("div",{id:"lbBottom"}).injectInside(AH).adopt(A=new Element("a",{id:"lbCloseLink",href:"#"}),e=new Element("div",{id:"lbCaption"}),AB=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}));A.onclick=f.onclick=p;z={overlay:f.effect("opacity",{duration:500}).set(0),image:n.effect("opacity",{duration:500,onComplete:AD}),bottom:u.effect("margin-top",{duration:400})}});Slimbox={open:function(A,B,C){y=$extend({loop:false,overlayOpacity:0.8,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,animateCaption:true,showCounter:true,counterText:"Image {x} of {y}"},C||{});if(typeof A=="string"){A=[[A,B]];B=0}r=A;y.loop=y.loop&&(r.length>1);AE();m(true);o=window.getScrollTop()+(window.getHeight()/15);z.resize=AG.effects($extend({duration:y.resizeDuration,onComplete:AD},y.resizeTransition?{transition:y.resizeTransition}:{}));AG.setStyles({top:o,width:y.initialWidth,height:y.initialHeight,marginLeft:-(y.initialWidth/2),display:""});z.overlay.start(y.overlayOpacity);w=1;return i(B)}};Element.extend({slimbox:function(B,A){$$(this).slimbox(B,A);return this}});Elements.extend({slimbox:function(D,A,B){A=A||function(E){return[E.href,E.title]};B=B||function(){return true};var C=this;C.forEach(function(E){E.onclick=function(){var F=C.filter(B,this);return Slimbox.open(F.map(A),F.indexOf(this),D)}});return C}});function AE(){f.setStyles({top:window.getScrollTop(),height:window.getHeight()})}function m(B){["object",window.ie?"select":"embed"].forEach(function(C){$each(document.getElementsByTagName(C),function(D){if(B){x[D]=D.style.visibility}D.style.visibility=B?"hidden":x[D]})});f.style.display=B?"":"none";var A=B?"addEvent":"removeEvent";window[A]("scroll",AE)[A]("resize",AE);document[A]("keydown",AF)}function h(A){switch(A.code){case 27:case 88:case 67:p();break;case 37:case 80:AA();break;case 39:case 78:l()}A.preventDefault()}function AA(){return i(k)}function l(){return i(j)}function i(A){if((w==1)&&(A>=0)){w=2;AC=A;k=((AC||!y.loop)?AC:r.length)-1;j=AC+1;if(j==r.length){j=y.loop?0:-1}$$(v,g,n,AH).setStyle("display","none");z.bottom.stop().set(0);z.image.set(0);AG.className="lbLoading";q=new Image();q.onload=AD;q.src=r[A][0]}return false}function AD(){switch(w++){case 2:AG.className="";n.setStyles({backgroundImage:"url("+r[AC][0]+")",display:""});$$(n,u).setStyle("width",q.width);$$(n,v,g).setStyle("height",q.height);e.setHTML(r[AC][1]||"");AB.setHTML((y.showCounter&&(r.length>1))?y.counterText.replace(/{x}/,AC+1).replace(/{y}/,r.length):"");if(k>=0){t.src=r[k][0]}if(j>=0){s.src=r[j][0]}if(AG.clientHeight!=n.offsetHeight){z.resize.start({height:n.offsetHeight});break}w++;case 3:if(AG.clientWidth!=n.offsetWidth){z.resize.start({width:n.offsetWidth,marginLeft:-n.offsetWidth/2});break}w++;case 4:AH.setStyles({top:o+AG.clientHeight,marginLeft:AG.style.marginLeft,visibility:"hidden",display:""});z.image.start(1);break;case 5:if(k>=0){v.style.display=""}if(j>=0){g.style.display=""}if(y.animateCaption){z.bottom.set(-u.offsetHeight).start(0)}AH.style.visibility="";w=1}}function p(){if(w){w=0;q.onload=Class.empty;for(var A in z){z[A].stop()}$$(AG,AH).setStyle("display","none");z.overlay.chain(m).start(0)}return false}})();Slimbox.scanPage=function(){var A=$$("a").filter(function(B){return B.rel&&B.rel.test(/^lightbox/i)});$$(A).slimbox({},null,function(B){return(this==B)||((this.rel.length>8)&&(this.rel==B.rel))})};window.addEvent("domready",Slimbox.scanPage);