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