/*Slimbox v2.02 - (c) 2007-2009 Christophe Beyls <http://www.digitalia.be> MIT-style license.*/
(function(e){var A=e(window),q,z,t=-1,B,J,h,C,F,p,f,k=!window.XMLHttpRequest,E=window.opera&&(document.compatMode=="CSS1Compat")&&(e.browser.version>=9.3),y=document.documentElement,j={},w=new Image(),r=new Image(),G,n,i,g,u,v,m,H,a,I;e(function(){e("body").append(e([G=e('<div id="lbOverlay" />')[0],n=e('<div id="lbCenter" />')[0],m=e('<div id="lbBottomContainer" />')[0]]).css("display","none"));i=e('<div id="lbImage" />').appendTo(n).append(g=e('<div style="position: relative;" />'))[0];H=e('<div id="lbBottom" />').appendTo(m).append([e('<div id="lbNavigation" />').append([u=e('<a id="lbPrevLink" href="#" />').click(x)[0],v=e('<a id="lbNextLink" href="#" />').click(s)[0]])[0],e('<a id="lbCloseLink" href="#" />').add(G).click(o)[0],a=e('<div id="lbCaption" />')[0],I=e('<div id="lbNumber" />')[0],e('<div style="clear: both;" />')[0]])[0]});e.slimbox=function(O,M,N){q=e.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:200,resizeDuration:200,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:200,captionAnimationDuration:150,counterText:"Image {x} of {y}",closeKeys:[27,88,67],closeClass:"",previousKeys:[37,80],nextKeys:[39,78]},N);if(typeof O=="string"){O=[[O,M]];M=0}e("#lbCloseLink",H).addClass(q.closeClass);F=A.scrollTop()+((E?y.clientHeight:A.height())/2);p=q.initialWidth;f=q.initialHeight;e(n).css({top:Math.max(0,F-(f/2)),width:p,height:f,marginLeft:-p/2}).show();C=k||(G.currentStyle&&(G.currentStyle.position!="fixed"));if(C){G.style.position="absolute"}e(G).css("opacity",q.overlayOpacity).fadeIn(q.overlayFadeDuration);L();l(1);z=O;q.loop=q.loop&&(z.length>1);return c(M)};e.fn.slimbox=function(O,M,P){M=M||function(Q){return[Q.href,Q.title]};P=P||function(){return true};var N=this;return N.unbind("click").click(function(){var S=this,Q=0,R,U=0,T;R=e.grep(N,function(V,W){return P.call(S,V,W)});for(T=R.length;U<T;++U){if(R[U]==S){Q=U}R[U]=M(R[U],U)}return e.slimbox(R,Q,O)})};function L(){var M=A.scrollLeft(),N=E?y.clientWidth:A.width();e([n,m]).css("left",M+(N/2));if(C){e(G).css({left:M,top:A.scrollTop(),width:N,height:A.height()})}}function l(N){e("object").add(k?"select":"embed").each(function(P,O){if(N){e.data(O,"slimbox",O.style.visibility)}O.style.visibility=N?"hidden":e.data(O,"slimbox")});var M=N?"bind":"unbind";A[M]("scroll resize",L);e(document)[M]("keydown",b)}function b(N){var M=N.keyCode,O=e.inArray;return(O(M,q.closeKeys)>=0)?o():(O(M,q.nextKeys)>=0)?s():(O(M,q.previousKeys)>=0)?x():false}function x(){return c(J)}function s(){return c(h)}function c(M){if(M>=0){t=M;B=z[t][0];J=(t||(q.loop?z.length:0))-1;h=((t+1)%z.length)||(q.loop?0:-1);D();n.className="lbLoading";j=new Image();j.onload=K;j.src=B}return false}function K(){n.className="";e(i).css({backgroundImage:"url("+B+")",visibility:"hidden",display:""});e(g).width(j.width);e(g).height(j.height);e(a).html(z[t][1]||"");e(I).html((((z.length>1)&&q.counterText)||"").replace(/{x}/,t+1).replace(/{y}/,z.length));if(J>=0){w.src=z[J][0]}if(h>=0){r.src=z[h][0]}p=i.offsetWidth;f=i.offsetHeight;var M=Math.max(0,F-(f/2));if(n.offsetHeight!=f){e(n).animate({height:f,top:M},q.resizeDuration,q.resizeEasing)}if(n.offsetWidth!=p){e(n).animate({width:p,marginLeft:-p/2},q.resizeDuration,q.resizeEasing)}e(n).queue(function(){e(m).css({width:p,top:M+f,marginLeft:-p/2,visibility:"hidden",display:""});e(i).css({display:"none",visibility:"",opacity:""}).fadeIn(q.imageFadeDuration,d)})}function d(){if(J>=0){e(u).show()}if(h>=0){e(v).show()}e(H).css("marginTop",-H.offsetHeight).animate({marginTop:0},q.captionAnimationDuration);m.style.visibility=""}function D(){j.onload=null;j.src=w.src=r.src=B;e([n,i,H]).stop(true);e([u,v,i,m]).hide()}function o(){if(t>=0){D();t=J=h=-1;e(n).hide();e(G).stop().fadeOut(q.overlayFadeDuration,l)}return false}})(jQuery);jQuery(function(d){var b="",c="Bild {x} av {y}",a=location.host.toLowerCase();if(a.indexOf(".no")>-1){b="no";c="Bilde {x} av {y}"}else{if(a.indexOf(".dk")>-1){b="dk";c="Billed {x} af {y}"}}d("a[rel^='lightbox']").slimbox({counterText:c,closeClass:b},null,function(e){return(this==e)||((this.rel.length>8)&&(this.rel==e.rel))})});
