var Slimbox;(function(){var g=0,h,i,j,k,l,m,n,o,p=new Image(),q=new Image(),r,s,t,u,v,w,x,y,z,A,B,C;window.addEvent("domready",function(){$(document.body).adopt($$([r=new Element("div",{id:"lbOverlay"}).addEvent("click",K),s=new Element("div",{id:"lbCenter"}),x=new Element("div",{id:"lbBottomContainer"})]).setStyle("display","none"));t=new Element("div",{id:"lbImage"}).injectInside(s).adopt(v=new Element("a",{id:"lbPrevLink",href:"#"}).addEvent("click",G),w=new Element("a",{id:"lbNextLink",href:"#"}).addEvent("click",H));u=new Element("iframe",{id:"lbImage"}).addEvent("load",J).injectInside(t);y=new Element("div",{id:"lbBottom"}).injectInside(x).adopt(new Element("a",{id:"lbCloseLink",href:"#"}).addEvent("click",K),B=new Element("a",{id:'lbPrintLink',href:'#'}).addEvent("click",M),C=new Element("a",{id:'lbSaveLink',href:'#'}).addEvent("click",N),z=new Element("div",{id:"lbCaption"}),A=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}));n={overlay:new Fx.Tween(r,{property:"opacity",duration:500}).set(0),image:new Fx.Tween(t,{property:"opacity",duration:500,onComplete:J}),bottom:new Fx.Tween(y,{property:"margin-top",duration:400})}});Slimbox={open:function(a,b,c){h=$extend({loop:false,overlayOpacity:0.8,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,psScriptPath:'',enablePrintButton:0,enableSaveButton:0,animateCaption:true,showCounter:true,counterText:"Item {x} of {y}",defaultIframeWidth:850,defaultIframeHeight:500},c||{});if(typeof a=="string"){a=[[a,b]];b=0}i=a;h.loop=h.loop&&(i.length>1);D();E(true);m=window.getScrollTop()+(window.getHeight()/15);n.resize=new Fx.Morph(s,$extend({duration:h.resizeDuration,onComplete:J},h.resizeTransition?{transition:h.resizeTransition}:{}));s.setStyles({top:m,width:h.initialWidth,height:h.initialHeight,marginLeft:-(h.initialWidth/2),display:""});n.overlay.start(h.overlayOpacity);g=1;return I(b)}};Element.implement({slimbox:function(a,b){$$(this).slimbox(a,b);return this}});Elements.implement({slimbox:function(b,c,d){c=c||function(a){return[a.href,a.title,a.rev]};d=d||function(){return true};var e=this;e.removeEvents("click").addEvent("click",function(){var a=e.filter(d,this);return Slimbox.open(a.map(c),a.indexOf(this),b)});return e}});function D(){r.setStyles({top:window.getScrollTop(),height:window.getHeight()})}function E(c){["object",window.ie?"select":"embed"].forEach(function(b){Array.forEach(document.getElementsByTagName(b),function(a){if(c)a._slimbox=a.style.visibility;a.style.visibility=c?"hidden":a._slimbox})});r.style.display=c?"":"none";var d=c?"addEvent":"removeEvent";window[d]("scroll",D)[d]("resize",D);document[d]("keydown",F)}function F(a){switch(a.code){case 27:case 88:case 67:K();break;case 37:case 80:G();break;case 39:case 78:H()}return false}function G(){return I(k)}function H(){return I(l)}function I(a){if((g==1)&&(a>=0)){g=2;j=a;k=((j||!h.loop)?j:i.length)-1;l=j+1;if(l==i.length)l=h.loop?0:-1;$$(v,w,t,u,x).setStyle("display","none");n.bottom.cancel().set(0);n.image.set(0);s.className="lbLoading";var b=i[j][0];var c=/\.(jpe?g|png|gif|bmp)/i;if(b.match(c)){if(!h.enablePrintButton||!psScriptPath){B.setStyle('display','none')};if(!h.enableSaveButton||!psScriptPath){C.setStyle('display','none')};o=new Image();o.datatype='image';o.onload=J;o.src=b}else{$$(B,C).setStyle("display","none");o=new Object();o.datatype='iframe';rev=i[j][2];o.w=L(rev,new RegExp("width=(\\d+)","i"),h.defaultIframeWidth);o.h=L(rev,new RegExp("height=(\\d+)","i"),h.defaultIframeHeight);u.setProperties({id:"lbFrame_"+new Date().getTime(),width:o.w,height:o.h,scrolling:'yes',frameBorder:0,src:b})}}return false}function J(){switch(g++){case 2:s.className="";if(o.datatype=='image'){t.setStyles({backgroundImage:"url("+o.src+")",display:""});$$(t,y).setStyle("width",o.width);$$(t,v,w).setStyle("height",o.height);$$(v,w).setStyle("width","50%")}else{t.setStyles({backgroundImage:"",display:""});$$(t,y).setStyle("width",o.w);$$(t).setStyle("height",o.h);$$(v,w).setStyle("height","35px");$$(v,w).setStyle("width","65px");u.setStyles({display:""})}z.set('html',i[j][1]||"");A.set('html',(h.showCounter&&(i.length>1))?h.counterText.replace(/{x}/,j+1).replace(/{y}/,i.length):"");if(k>=0)p.src=i[k][0];if(l>=0)q.src=i[l][0];if(s.clientHeight!=t.offsetHeight){n.resize.start({height:t.offsetHeight});break}g++;case 3:if(s.clientWidth!=t.offsetWidth){n.resize.start({width:t.offsetWidth,marginLeft:-t.offsetWidth/2});break}g++;case 4:x.setStyles({top:m+s.clientHeight,marginLeft:s.style.marginLeft,visibility:"hidden",display:""});n.image.start(1);break;case 5:if(k>=0)v.style.display="";if(l>=0)w.style.display="";if(h.animateCaption){n.bottom.set(-y.offsetHeight).start(0)}x.style.visibility="";g=1}}function K(){if(g){g=0;o.onload=$empty;for(var f in n)n[f].cancel();$$(s,x).setStyle("display","none");n.overlay.chain(E).start(0)}return false}function L(a,b,c){var d=a.match(b);return d?d[1]:c}function M(){return O('print')}function N(){return O('save')}function O(a){if(h.psScriptPath){var b=window.open(h.psScriptPath+'?mode='+a+'&image='+i[j][0],'printsave','left=0,top=0,width='+(parseInt(t.style.width))+',height='+(parseInt(t.style.height))+',toolbar=0,resizable=1');return false}return true}})();