/*
	Slimbox v1.64 - The ultimate lightweight Lightbox clone
	(c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
var Slimbox;(function(){var i=0,h,n,b,x,y,r,g,o,l=new Image(),m=new Image(),D,G,t,j,C,F,k,E,d,p,s,z,f,c,v;window.addEvent("domready",function(){$(document.body).adopt($$([D=new Element("div",{id:"lbOverlay"}).addEvent("click",q),G=new Element("div",{id:"lbCenter"}),F=new Element("div",{id:"lbBottomContainer"})]).setStyle("display","none"));t=new Element("div",{id:"lbImage"}).injectInside(G).adopt(j=new Element("a",{id:"lbPrevLink",href:"#"}).addEvent("click",e),C=new Element("a",{id:"lbNextLink",href:"#"}).addEvent("click",w));k=new Element("div",{id:"lbBottom"}).injectInside(F).adopt(p=new Element("a",{id:"lbPrevLink2",href:"#"}).addEvent("click",e),s=new Element("a",{id:"lbNextLink2",href:"#"}).addEvent("click",w),d=new Element("div",{id:"lbNumber"}),E=new Element("div",{id:"lbCaption"}),f=new Element("div",{id:"lbDate"}),c=new Element("div",{id:"lbcredit"}),v=new Element("div",{id:"lbcreditURL"}),z=new Element("div",{id:"lbDescription"}),new Element("a",{id:"lbCloseLink",href:"#"}).addEvent("click",q),new Element("div",{styles:{clear:"both"}}));g={overlay:new Fx.Tween(D,{property:"opacity",duration:500}).set(0),image:new Fx.Tween(t,{property:"opacity",duration:500,onComplete:a}),bottom:new Fx.Tween(k,{property:"margin-top",duration:400})}});Slimbox={open:function(K,J,I){h=$extend({loop:false,overlayOpacity:0.8,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,animateCaption:true,showCounter:true,counterText:"Image {x} of {y}"},I||{});if(typeof K=="string"){K=[[K,J]];J=0}n=K;h.loop=h.loop&&(n.length>1);H();u(true);r=window.getScrollTop()+(window.getHeight()/15);g.resize=new Fx.Morph(G,$extend({duration:h.resizeDuration,onComplete:a},h.resizeTransition?{transition:h.resizeTransition}:{}));G.setStyles({top:r,width:h.initialWidth,height:h.initialHeight,marginLeft:-(h.initialWidth/2),display:""});g.overlay.start(h.overlayOpacity);i=1;return A(J)}};Element.implement({slimbox:function(I,J){$$(this).slimbox(I,J);return this}});Elements.implement({slimbox:function(I,L,K){L=L||function(M){return[M.href,M.title,M.name.substring(13)]};K=K||function(){return true};var J=this;J.removeEvents("click").addEvent("click",function(){var M=J.filter(K,this);return Slimbox.open(M.map(L),M.indexOf(this),I)});return J}});function H(){D.setStyles({top:window.getScrollTop(),height:window.getHeight()})}function u(I){["object",window.ie?"select":"embed"].forEach(function(K){Array.forEach(document.getElementsByTagName(K),function(L){if(I){L._slimbox=L.style.visibility}L.style.visibility=I?"hidden":L._slimbox})});D.style.display=I?"":"none";var J=I?"addEvent":"removeEvent";window[J]("scroll",H)[J]("resize",H);document[J]("keydown",B)}function B(I){switch(I.code){case 27:case 88:case 67:q();break;case 37:case 80:e();break;case 39:case 78:w()}return false}function e(){return A(x)}function w(){return A(y)}function A(I){if((i==1)&&(I>=0)){i=2;b=I;x=((b||!h.loop)?b:n.length)-1;y=b+1;if(y==n.length){y=h.loop?0:-1}$$(j,C,t,F).setStyle("display","none");$$(p,s).setStyle("display","none");g.bottom.cancel().set(0);g.image.set(0);G.className="lbLoading";o=new Image();o.onload=a;o.src=n[I][0]}return false}function a(){switch(i++){case 2:G.className="";t.setStyles({backgroundImage:"url("+n[b][0]+")",display:""});$$(t,k).setStyle("width",o.width);$$(t,j,C).setStyle("height",o.height);var J=n[b][2];E.set("html",n[b][1]||"");var I=document.getElementById("LightboxCaption"+J);if(I){z.set("html",I.innerHTML);z.style.display=""}else{z.set("html","");z.style.display="none"}var K=document.getElementById("LightboxDate"+J);if(K){f.set("html",K.innerHTML);f.style.display=""}else{f.set("html","");f.style.display="none"}var L=document.getElementById("Lightboxcredit"+J);if(L){c.set("html",L.innerHTML);c.style.display=""}else{c.set("html","");c.style.display="none"}var M=document.getElementById("LightboxcreditURL"+J);if(M){v.set("html",M.innerHTML);v.style.display=""}else{v.set("html","");v.style.display="none"}d.set("html",(h.showCounter&&(n.length>1))?h.counterText.replace(/{x}/,b+1).replace(/{y}/,n.length):"");if(x>=0){l.src=n[x][0]}if(y>=0){m.src=n[y][0]}if(G.clientHeight!=t.offsetHeight){g.resize.start({height:t.offsetHeight});break}i++;case 3:if(G.clientWidth!=t.offsetWidth){g.resize.start({width:t.offsetWidth,marginLeft:-t.offsetWidth/2});break}i++;case 4:F.setStyles({top:r+G.clientHeight,marginLeft:G.style.marginLeft,visibility:"hidden",display:""});g.image.start(1);break;case 5:if(x>=0){j.style.display=""}if(y>=0){C.style.display=""}if(x>=0){p.style.display=""}if(y>=0){s.style.display=""}if(h.animateCaption){g.bottom.set(-k.offsetHeight).start(0)}F.style.visibility="";i=1}}function q(){if(i){i=0;o.onload=$empty;for(var I in g){g[I].cancel()}$$(G,F).setStyle("display","none");g.overlay.chain(u).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);