/*!
	Slimbox v2.05 - The ultimate lightweight Lightbox clone for jQuery
	(c) 2007-2013 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
!function(i){var e,t,n,o,a,r,l,s,c,d,u,h,f,p,g,y,m,v,b,x=i(window),w=-1,D=!window.XMLHttpRequest,k=[],I=(document.documentElement,{}),T=new Image,z=new Image;function L(){var e=x.scrollLeft(),t=x.width();i([u,y]).css("left",e+t/2),r&&i(d).css({left:e,top:x.scrollTop(),width:t,height:x.height()})}function F(e){e?i("object").add(D?"select":"embed").each((function(i,e){k[i]=[e,e.style.visibility],e.style.visibility="hidden"})):(i.each(k,(function(i,e){e[0].style.visibility=e[1]})),k=[]);var t=e?"bind":"unbind";x[t]("scroll resize",L),i(document)[t]("keydown",H)}function H(t){var n=t.which,o=i.inArray;return o(n,e.closeKeys)>=0?E():o(n,e.nextKeys)>=0?j():o(n,e.previousKeys)>=0?S():null}function S(){return q(o)}function j(){return q(a)}function q(i){return i>=0&&(n=t[w=i][0],o=(w||(e.loop?t.length:0))-1,a=(w+1)%t.length||(e.loop?0:-1),C(),u.className="lbLoading",(I=new Image).onload=A,I.src=n),!1}function A(){u.className="",i(h).css({backgroundImage:"url("+n+")",visibility:"hidden",display:""}),i(f).width(I.width),i([f,p,g]).height(I.height),i(v).html(t[w][1]||""),i(b).html((t.length>1&&e.counterText||"").replace(/{x}/,w+1).replace(/{y}/,t.length)),o>=0&&(T.src=t[o][0]),a>=0&&(z.src=t[a][0]),s=h.offsetWidth,c=h.offsetHeight;var r=Math.max(0,l-c/2);u.offsetHeight!=c&&i(u).animate({height:c,top:r},e.resizeDuration,e.resizeEasing),u.offsetWidth!=s&&i(u).animate({width:s,marginLeft:-s/2},e.resizeDuration,e.resizeEasing),i(u).queue((function(){i(y).css({width:s,top:r+c,marginLeft:-s/2,visibility:"hidden",display:""}),i(h).css({display:"none",visibility:"",opacity:""}).fadeIn(e.imageFadeDuration,K)}))}function K(){o>=0&&i(p).show(),a>=0&&i(g).show(),i(m).css("marginTop",-m.offsetHeight).animate({marginTop:0},e.captionAnimationDuration),y.style.visibility=""}function C(){I.onload=null,I.src=T.src=z.src=n,i([u,h,m]).stop(!0),i([p,g,h,y]).hide()}function E(){return w>=0&&(C(),w=o=a=-1,i(u).hide(),i(d).stop().fadeOut(e.overlayFadeDuration,F)),!1}i((function(){i("body").append(i([d=i('<div id="lbOverlay" />').click(E)[0],u=i('<div id="lbCenter" />')[0],y=i('<div id="lbBottomContainer" />')[0]]).css("display","none")),h=i('<div id="lbImage" />').appendTo(u).append(f=i('<div style="position: relative;" />').append([p=i('<a id="lbPrevLink" href="#" />').click(S)[0],g=i('<a id="lbNextLink" href="#" />').click(j)[0]])[0])[0],m=i('<div id="lbBottom" />').appendTo(y).append([i('<a id="lbCloseLink" href="#" />').click(E)[0],v=i('<div id="lbCaption" />')[0],b=i('<div id="lbNumber" />')[0],i('<div style="clear: both;" />')[0]])[0]})),i.slimbox=function(n,o,a){return e=i.extend({loop:!1,overlayOpacity:.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},a),"string"==typeof n&&(n=[[n,o]],o=0),l=x.scrollTop()+x.height()/2,s=e.initialWidth,c=e.initialHeight,i(u).css({top:Math.max(0,l-c/2),width:s,height:c,marginLeft:-s/2}).show(),(r=D||d.currentStyle&&"fixed"!=d.currentStyle.position)&&(d.style.position="absolute"),i(d).css("opacity",e.overlayOpacity).fadeIn(e.overlayFadeDuration),L(),F(1),t=n,e.loop=e.loop&&t.length>1,q(o)},i.fn.slimbox=function(e,t,n){t=t||function(i){return[i.href,i.title]},n=n||function(){return!0};var o=this;return o.unbind("click").click((function(){var a,r,l=this,s=0,c=0;for(a=i.grep(o,(function(i,e){return n.call(l,i,e)})),r=a.length;c<r;++c)a[c]==l&&(s=c),a[c]=t(a[c],c);return i.slimbox(a,s,e)}))}}(jQuery),jQuery((function(i){var e={loop:!1,overlayOpacity:.8,overlayFadeDuration:400,resizeDuration:300,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:300,captionAnimationDuration:200,counterText:"Image {x} of {y}",itemSelector:"a[href]",titleAttr:"title"};i((function(){var i=foswiki.getPreference("ImagePlugin.counterText");i&&(e.counterText=i)})),i(".jqSlimbox:not(.jqInitedSlimbox)").livequery((function(){var t=i(this);t.addClass("jqInitedSlimbox");var n=i.extend({},e,t.data()),o="lightbox-"+Math.floor(100*Math.random());t.find(n.itemSelector).attr("rel",o).slimbox(n,(function(e){var t=i(e),o=i.extend({},t.data()),a=o.origUrl||e.href,r=o.title||t.attr(n.titleAttr)||"";return r=r.replace(/\..*?$/,"").replace(/[\-_]/g," "),[e.href,'<a href="'+a+'">'+r+"</a>"]}),(function(i){return this==i||this.rel.length>8&&this.rel==i.rel}))}))}));
