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