/*
	Slimbox v1.56 - The ultimate lightweight Lightbox clone
	(c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.

	ADDON thumbnails gallery
	(c) 2009 Intern1 Aps <http://intern1.dk>
*/
var Slimbox=(function(){var H=window,v,h,I,y,G,w,A,O,t,m=r.bindWithEvent(),f=window.opera&&(navigator.appVersion>="9.3"),q=document.documentElement,p={},u=new Image(),M=new Image(),K,a,j,L,e,J,c,C,N,z,k,d,E;H.addEvent("domready",function(){$(document.body).adopt($$(K=new Element("div",{id:"lbOverlay"}),a=new Element("div",{id:"lbCenter"}),J=new Element("div",{id:"lbBottomContainer"})).setStyle("display","none"));j=new Element("div",{id:"lbImage"}).injectInside(a).adopt(L=new Element("a",{id:"lbPrevLink",href:"#"}),e=new Element("a",{id:"lbNextLink",href:"#"}));L.onclick=D;e.onclick=g;var P;c=new Element("div",{id:"lbBottom"}).injectInside(J).adopt(P=new Element("a",{id:"lbCloseLink",href:"#"}),C=new Element("div",{id:"lbCaption"}),N=new Element("div",{id:"lbNumber"}),thumbsLink=new Element("div",{id:"lbThumbsLink"}),new Element("div",{styles:{clear:"both"}}));P.onclick=K.onclick=F});function B(){var Q=H.getScrollLeft(),P=f?q.clientWidth:H.getWidth();$$(a,J).setStyle("left",Q+(P/2));if(w){K.setStyles({left:Q,top:H.getScrollTop(),width:P,height:H.getHeight()})}}function o(P){["object",H.ie6?"select":"embed"].forEach(function(R){$each(document.getElementsByTagName(R),function(S){if(P){S._slimbox=S.style.visibility}S.style.visibility=P?"hidden":S._slimbox})});K.style.display=P?"":"none";var Q=P?"addEvent":"removeEvent";H[Q]("scroll",B)[Q]("resize",B);document[Q]("keydown",m)}function r(Q){var P=Q.code;if(v.closeKeys.contains(P)){F()}else{if(v.nextKeys.contains(P)){g()}else{if(v.previousKeys.contains(P)){D()}}}Q.stop()}function D(){return b(y)}function g(){return b(G)}function b(P){if(P>=0){I=P;y=(I||(v.loop?h.length:0))-1;G=((I+1)%h.length)||(v.loop?0:-1);s();a.className="lbLoading";p=new Image();p.onload=n;p.src=h[P][0]}return false}function n(){if(h.length>1){if($("lbThumbnails")){j.adopt(L=new Element("a",{id:"lbPrevLink",href:"#"}),e=new Element("a",{id:"lbNextLink",href:"#"}));L.onclick=D;e.onclick=g;thumbsLink=new Element("div",{id:"lbThumbsLink"}).injectAfter($("lbCloseLink"));N=new Element("div",{id:"lbNumber"}).injectAfter($("lbCloseLink"));C=new Element("div",{id:"lbCaption"}).injectAfter($("lbCloseLink"));$("lbThumbnails").remove()}else{if($("lbThumbsLink")===null){thumbsLink=new Element("div",{id:"lbThumbsLink"}).injectAfter(N)}}thumbsLink.setHTML('<a href="#">'+v.galleryText+"</a> &rsaquo;&rsaquo; ");thumbsLink.getFirst().addEvent("click",x.bindWithEvent(thumbsLink.getFirst()))}else{thumbsLink.remove()}a.className="";d.set(0);j.setStyles({width:p.width,backgroundImage:"url("+p.src+")",display:""});$$(j,L,e).setStyle("height",p.height);C.setHTML(h[I][1]||"");N.setHTML((((h.length>1)&&v.counterText)||"").replace(/{x}/,I+1).replace(/{y}/,h.length));if(y>=0){u.src=h[y][0]}if(G>=0){M.src=h[G][0]}O=j.offsetWidth;t=j.offsetHeight;var P=Math.max(0,A-(t/2));if(a.offsetHeight!=t){k.chain(k.start.pass({height:t,top:P},k))}if(a.offsetWidth!=O){k.chain(k.start.pass({width:O,marginLeft:-O/2},k))}k.chain(function(){J.setStyles({width:O,top:P+t,marginLeft:-O/2,visibility:"hidden",display:""});d.start(1)});k.callChain()}function l(){if(y>=0){L.style.display=""}if(G>=0){e.style.display=""}E.set(-c.offsetHeight).start(0);J.style.visibility=""}function x(Q){new Event(Q).stop();j.empty().setStyles({backgroundImage:"none"});J.setStyle("display","none");$("lbCaption").remove();$("lbNumber").remove();$("lbThumbsLink").remove();div=new Element("div",{id:"lbThumbnails",styles:{"float":"left"}}).injectInside(j);for(i=0;i<h.length;i++){new Element("div").setProperty("class","lbThumb").injectInside(div).adopt(new Element("a",{href:"#",id:"tb"+i}).addEvent("click",function(R){new Event(R).stop();b(this.getProperty("id").replace("tb","").toInt())}).adopt(new Element("img",{src:h[i][0].replace(v.replaceImgSrcFind,v.replaceImgSrcNew)})))}j.setStyles({width:div.getStyle("width").toInt(),height:div.getStyle("height").toInt()});O=j.offsetWidth;t=j.offsetHeight;var P=Math.max(0,A-(t/2));if(a.offsetHeight!=t){k.chain(k.start.pass({height:t,top:P},k))}if(a.offsetWidth!=O){k.chain(k.start.pass({width:O,marginLeft:-O/2},k))}k.chain(function(){J.setStyles({width:O,top:P+t,marginLeft:-O/2,visibility:"hidden",display:""});d.start(1)});k.callChain()}function s(){p.onload=Class.empty;p.src=u.src=M.src="";k.clearChain();k.stop();d.stop();E.stop();$$(L,e,j,J).setStyle("display","none")}function F(){if(I>=0){s();I=y=G=-1;a.style.display="none";z.stop().chain(o).start(0)}return false}Element.extend({slimbox:function(P,Q){$$(this).slimbox(P,Q);return this}});Elements.extend({slimbox:function(P,S,R){S=S||function(T){return[T.href,T.title]};R=R||function(){return true};var Q=this;Q.forEach(function(T){T.removeEvents("click").addEvent("click",function(U){var V=Q.filter(R,this);Slimbox.open(V.map(S),V.indexOf(this),P);U.stop()}.bindWithEvent(T))});return Q}});return{open:function(R,Q,P){v=$extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",galleryText:"View thumbnails gallery",replaceImgSrcFind:".jpg",replaceImgSrcNew:"_lille.jpg",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},P||{});z=K.effect("opacity",{duration:v.overlayFadeDuration});k=a.effects($extend({duration:v.resizeDuration},v.resizeTransition?{transition:v.resizeTransition}:{}));d=j.effect("opacity",{duration:v.imageFadeDuration,onComplete:l});E=c.effect("margin-top",{duration:v.captionAnimationDuration});if(typeof R=="string"){R=[[R,Q]];Q=0}A=H.getScrollTop()+((f?q.clientHeight:H.getHeight())/2);O=v.initialWidth;t=v.initialHeight;a.setStyles({top:Math.max(0,A-(t/2)),width:O,height:t,marginLeft:-O/2,display:""});w=H.ie6||(K.currentStyle&&(K.currentStyle.position!="fixed"));if(w){K.style.position="absolute"}z.set(0).start(v.overlayOpacity);B();o(1);h=R;v.loop=v.loop&&(h.length>1);return b(Q)}}})();

if (lang == 'dk') {
	ctxt = 'Billede {x} af {y}';
	gtxt = 'Se billede oversigt';
}
if (lang == 'de') {
	ctxt = 'Bild {x} von {y}';
	gtxt = 'Siehe Bild Übersicht';
}
if (lang == 'nl') {
	ctxt = 'Image {x} van {y}';
	gtxt = 'Zie fotoalbum';
}

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
Slimbox.scanPage = function() {
	$$($$(document.links).filter(function(el) {
		return el.rel && el.rel.test(/^lightbox/i);
	})).slimbox({
		counterText: ctxt,
		galleryText: gtxt
	}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
};
window.addEvent("domready", Slimbox.scanPage);