/*! Slimbox v1.8 - The ultimate lightweight Lightbox clone (c) 2007-2011 Christophe Beyls MIT-style license. modified by JoomGallery team - automatic resizing - use of language constants - dynamically ignore of doublets */ var Slimbox=(function(){var L=window,s=Browser.ie6,z,g,M=-1,t,C,K,A,E,T,x,r={},y=new Image(),R=new Image(),O,a,h,v,P,e,N,c,G,S,D,j,d,I;L.addEvent("domready",function(){$(document.body).adopt($$(O=new Element("div#lbOverlay",{events:{click:J}}),a=new Element("div#lbCenter"),N=new Element("div#lbBottomContainer")).setStyle("display","none"));h=new Element("div#lbImage").inject(a).adopt(v=new Element("div",{styles:{position:"relative"}}).adopt(P=new Element("a#lbPrevLink[href=#]",{events:{click:H}}),e=new Element("a#lbNextLink[href=#]",{events:{click:f}})));c=new Element("div#lbBottom").inject(N).adopt(new Element("a#lbCloseLink[href=#]",{events:{click:J}}),G=new Element("div#lbCaption"),S=new Element("div#lbNumber"),new Element("div",{styles:{clear:"both"}}))});function F(){var U=L.getScroll(),V=L.getSize();$$(a,N).setStyle("left",U.x+(V.x/2));if(A){O.setStyles({left:U.x,top:U.y,width:V.x,height:V.y})}}function n(U){["object",s?"select":"embed"].forEach(function(W){Array.forEach(document.getElementsByTagName(W),function(X){if(U){X._slimbox=X.style.visibility}X.style.visibility=U?"hidden":X._slimbox})});O.style.display=U?"":"none";var V=U?"addEvent":"removeEvent";L[V]("scroll",F)[V]("resize",F);document[V]("keydown",u)}function u(V){var U=V.code;return z.closeKeys.contains(U)?J():z.nextKeys.contains(U)?f():z.previousKeys.contains(U)?H():false}function H(){return b(C)}function f(){return b(K)}function b(U){if(U>=0){M=U;t=g[U][0];C=(M||(z.loop?g.length:0))-1;K=((M+1)%g.length)||(z.loop?0:-1);w();a.className="lbLoading";r=new Image();r.onload=l;r.src=t}return false}function B(U){o={};ilength=U.length;for(i=0;i(z.winWidth*0.99)){r.height=(r.height*(z.winWidth*0.99))/r.width;r.width=z.winWidth*0.99}if(r.height>(z.winHeight*0.88)){r.width=(r.width*(z.winHeight*0.88))/r.height;r.height=z.winHeight*0.88}imgelem=h.getElementById("sbimg");if(!imgelem){imgelem=new Element("img",{id:"sbimg"});imgelem.inject(h)}imgelem.setProperty("src",g[M][0]);imgelem.setProperty("width",r.width);imgelem.setProperty("height",r.height)}else{h.style.backgroundImage="url("+g[M][0]+")"}h.setStyles({width:r.width,display:""});v.setStyle("width",r.width);h.setStyle("height",r.height);$$(P,e).setStyle("height",r.height);G.set("html",g[M][1]||"");uniquearr=new Array();uniquearr=B(g);uniquecount=Q(uniquearr);uniquemaxid=m(uniquearr,g.length);changed=false;while(!uniquearr[M]){M++;changed=true;K++}while(!uniquearr[C]&&C>=0){C--}if(changed){while(!uniquearr[K]&&K<=uniquemaxid){K++}if(K>uniquemaxid){K=-1}}if(C<0){imageactcounter=1}else{imageactcounter=q(uniquearr,g.length,M)}S.set("html",(z.showCounter&&(g.length>1))?z.counterText.replace(/{x}/,imageactcounter).replace(/{y}/,uniquecount):"");if(C>=0){y.src=g[C][0]}if(K>=0){R.src=g[K][0]}T=h.offsetWidth;x=h.offsetHeight;var W=Math.max(0,E-(x/2)),U=0,V;if(a.offsetHeight!=x){U=j.start({height:x,top:W})}if(a.offsetWidth!=T){U=j.start({width:T,marginLeft:-T/2})}V=function(){N.setStyles({width:T,top:W+x,marginLeft:-T/2,visibility:"hidden",display:""});d.start(1)};if(U){j.chain(V)}else{V()}}function k(){if(C>=0){P.style.display=""}if(K>=0){e.style.display=""}I.set(-c.offsetHeight).start(0);N.style.visibility=""}function w(){r.onload=null;r.src=y.src=R.src=t;j.cancel();d.cancel();I.cancel();$$(P,e,h,N).setStyle("display","none")}function J(){if(M>=0){w();M=C=K=-1;a.style.display="none";D.cancel().chain(n).start(0)}return false}Element.implement({slimbox:function(U,V){$$(this).slimbox(U,V);return this}});Elements.implement({slimbox:function(U,X,W){X=X||function(Y){return[Y.href,Y.title]};W=W||function(){return true};var V=this;V.removeEvents("click").addEvent("click",function(){var Y=V.filter(W,this);return Slimbox.open(Y.map(X),Y.indexOf(this),U)});return V}});return{open:function(W,V,U){resizeduration=(11-resizeSpeed)*150;z=Object.append({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:resizeduration,resizeTransition:false,initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:joomgallery_image+" {x} "+joomgallery_of+" {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78],winWidth:(getWidth()>0)?getWidth():1024,winHeight:(getHeight()>0)?getHeight():800,showCounter:true},U||{});D=new Fx.Tween(O,{property:"opacity",duration:z.overlayFadeDuration});j=new Fx.Morph(a,Object.append({duration:z.resizeDuration,link:"chain"},z.resizeTransition?{transition:z.resizeTransition}:{}));d=new Fx.Tween(h,{property:"opacity",duration:z.imageFadeDuration,onComplete:k});I=new Fx.Tween(c,{property:"margin-top",duration:z.captionAnimationDuration});if(typeof W=="string"){W=[[W,V]];V=0}E=L.getScrollTop()+(L.getHeight()/2);T=z.initialWidth;x=z.initialHeight;a.setStyles({top:Math.max(0,E-(x/2)),width:T,height:x,marginLeft:-T/2,display:""});A=s||(O.currentStyle&&(O.currentStyle.position!="fixed"));if(A){O.style.position="absolute"}D.set(0).start(z.overlayOpacity);F();n(1);g=W;z.loop=z.loop&&(g.length>1);return b(V)}}})();Slimbox.scanPage=function(){$$("a").filter(function(a){return a.rel&&a.rel.test(/^lightbox/i)}).slimbox({},null,function(a){return(this==a)||((this.rel.length>8)&&(this.rel==a.rel))})};if(!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)){window.addEvent("domready",Slimbox.scanPage)};