/*
	Slimbox v1.71 - The ultimate lightweight Lightbox clone
 (c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
 MIT-style license.
*/
var Slimbox=function(){function d(){var a=l.getScroll(),b=l.getSize();$$(e,m).setStyle("left",a.x+b.x/2);C&&j.setStyles({left:a.x,top:a.y,width:b.x,height:b.y})}function D(a){["object",E?"select":"embed"].forEach(function(b){Array.forEach(document.getElementsByTagName(b),function(b){if(a)b._slimbox=b.style.visibility;b.style.visibility=a?"hidden":b._slimbox})});j.style.display=a?"":"none";var b=a?"addEvent":"removeEvent";l[b]("scroll",d)[b]("resize",d);document[b]("keydown",M)}function M(a){a=a.code;
return c.closeKeys.contains(a)?v():c.nextKeys.contains(a)?F():c.previousKeys.contains(a)?G():!1}function G(){return w(n)}function F(){return w(o)}function w(a){if(a>=0)g=a,r=f[a][0],n=(g||(c.loop?f.length:0))-1,o=(g+1)%f.length||(c.loop?0:-1),H(),e.className="lbLoading",k=new Image,k.onload=N,k.src=r;return!1}function N(){e.className="";s.set(0);p.setStyles({backgroundImage:"url("+r+")",display:""});x.setStyle("width",k.width);$$(x,t,u).setStyle("height",k.height);I.set("html",f[g][1]||"");J.set("html",
(f.length>1&&c.counterText||"").replace(/{x}/,g+1).replace(/{y}/,f.length));if(n>=0)K.src=f[n][0];if(o>=0)L.src=f[o][0];h=p.offsetWidth;i=p.offsetHeight;var a=Math.max(0,y-i/2),b=0,d;e.offsetHeight!=i&&(b=q.start({height:i,top:a}));e.offsetWidth!=h&&(b=q.start({width:h,marginLeft:-h/2}));d=function(){m.setStyles({width:h,top:a+i,marginLeft:-h/2,visibility:"hidden",display:""});s.start(1)};b?q.chain(d):d()}function O(){if(n>=0)t.style.display="";if(o>=0)u.style.display="";z.set(-A.offsetHeight).start(0);
m.style.visibility=""}function H(){k.onload=$empty;k.src=K.src=L.src=r;q.cancel();s.cancel();z.cancel();$$(t,u,p,m).setStyle("display","none")}function v(){if(g>=0)H(),g=n=o=-1,e.style.display="none",B.cancel().chain(D).start(0);return!1}var l=window,E=Browser.Engine.trident4,c,f,g=-1,r,n,o,C,y,h,i,k={},K=new Image,L=new Image,j,e,p,x,t,u,m,A,I,J,B,q,s,z;l.addEvent("domready",function(){$(document.body).adopt($$(j=new Element("div",{id:"lbOverlay",events:{click:v}}),e=new Element("div",{id:"lbCenter"}),
m=new Element("div",{id:"lbBottomContainer"})).setStyle("display","none"));p=(new Element("div",{id:"lbImage"})).injectInside(e).adopt(x=(new Element("div",{styles:{position:"relative"}})).adopt(t=new Element("a",{id:"lbPrevLink",href:"#",events:{click:G}}),u=new Element("a",{id:"lbNextLink",href:"#",events:{click:F}})));A=(new Element("div",{id:"lbBottom"})).injectInside(m).adopt(new Element("a",{id:"lbCloseLink",href:"#",events:{click:v}}),I=new Element("div",{id:"lbCaption"}),J=new Element("div",
{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}))});Element.implement({slimbox:function(a,b){$$(this).slimbox(a,b);return this}});Elements.implement({slimbox:function(a,b,c){var b=b||function(a){return[a.href,a.title]},c=c||function(){return!0},d=this;d.removeEvents("click").addEvent("click",function(){var e=d.filter(c,this);return Slimbox.open(e.map(b),e.indexOf(this),a)});return d}});return{open:function(a,b,g){c=$extend({loop:!1,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,
resizeTransition:!1,initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},g||{});B=new Fx.Tween(j,{property:"opacity",duration:c.overlayFadeDuration});q=new Fx.Morph(e,$extend({duration:c.resizeDuration,link:"chain"},c.resizeTransition?{transition:c.resizeTransition}:{}));s=new Fx.Tween(p,{property:"opacity",duration:c.imageFadeDuration,onComplete:O});z=new Fx.Tween(A,{property:"margin-top",
duration:c.captionAnimationDuration});typeof a=="string"&&(a=[[a,b]],b=0);y=l.getScrollTop()+l.getHeight()/2;h=c.initialWidth;i=c.initialHeight;e.setStyles({top:Math.max(0,y-i/2),width:h,height:i,marginLeft:-h/2,display:""});if(C=E||j.currentStyle&&j.currentStyle.position!="fixed")j.style.position="absolute";B.set(0).start(c.overlayOpacity);d();D(1);f=a;c.loop=c.loop&&f.length>1;return w(b)}}}();
Slimbox.scanPage=function(){$$("a").filter(function(d){return d.rel&&d.rel.test(/^lightbox/i)}).slimbox({},null,function(d){return this==d||this.rel.length>8&&this.rel==d.rel})};/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)||window.addEvent("domready",Slimbox.scanPage);
