/*
	Slimbox v1.62 - The ultimate lightweight Lightbox clone
	(c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
var Slimbox;(function(){var G={},H=0,F,N,B,Q,E,O,L=new Image(),M=new Image(),X,a,R,I,J,W,Z,K,Y,C;window.addEvent("domready",function(){$(document.body).adopt($$([X=new Element("div",{id:"lbOverlay"}).addEvent("click",P),a=new Element("div",{id:"lbCenter"}),Z=new Element("div",{id:"lbBottomContainer"})]).setStyle("display","none"));I=new Element("div",{id:"lbAds",align:"center",styles:{background:"#FFFFFF"}}).injectInside(a);R=new Element("div",{id:"lbImage"}).injectInside(a).adopt(J=new Element("a",{id:"lbPrevLink",href:"#"}).addEvent("click",D),W=new Element("a",{id:"lbNextLink",href:"#"}).addEvent("click",T));K=new Element("div",{id:"lbBottom"}).injectInside(Z).adopt(new Element("a",{id:"lbCloseLink",href:"#"}).addEvent("click",P),Y=new Element("div",{id:"lbCaption"}),C=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}));E={overlay:new Fx.Tween(X,{property:"opacity",duration:500}).set(0),image:new Fx.Tween(R,{property:"opacity",duration:500,onComplete:A}),ads:new Fx.Tween(I,{property:"opacity",duration:500,onComplete:A}),bottom:new Fx.Tween(K,{property:"margin-top",duration:400})}});Slimbox={open:function(e,d,c){F=$extend({overlayOpacity:0.8,resizeDuration:400,resizeTransition:false,initialWidth:250,initialHeight:250,animateCaption:true,showCounter:true,counterText:"Image {x} of {y}"},c||{});if(typeof e=="string"){e=[[e,d]];d=0}N=e;b();S(true);$("othergalleries").setStyle("visibility","hidden");Q=window.getScrollTop();E.resize=new Fx.Morph(a,$extend({duration:F.resizeDuration,onComplete:A},F.resizeTransition?{transition:F.resizeTransition}:{}));a.setStyles({top:Q,width:F.initialWidth,height:F.initialHeight,marginLeft:-(F.initialWidth/2),display:""});E.overlay.start(F.overlayOpacity);return U(d)}};Element.implement({slimbox:function(c,d){$$(this).slimbox(c,d)}});Elements.implement({slimbox:function(c,f,e){f=f||function(g){return[g.href,g.title]};e=e||function(){return true};var d=this;d.removeEvents("click").addEvent("click",function(){var g=d.filter(e,this);return Slimbox.open(g.map(f),g.indexOf(this),c)})}});function b(){X.setStyles({top:window.getScrollTop(),height:window.getHeight()})}function S(c){["object",window.ie?"select":"embed","iframe"].forEach(function(e){Array.forEach(document.getElementsByTagName(e),function(f){if(c){G[f]=f.style.visibility}f.style.visibility=c?"hidden":G[f]})});X.style.display=c?"":"none";var d=c?"addEvent":"removeEvent";window[d]("scroll",b)[d]("resize",b);document[d]("keydown",V)}function V(c){switch(c.code){case 27:case 88:case 67:P();break;case 37:case 80:D();break;case 39:case 78:T()}return false}function D(){return U(B-1)}function T(){return U(B+1)}function U(c){if((H>1)||(c<0)||(c>=N.length)){return false}H=2;B=c;$$(J,W,R,Z).setStyle("display","none");E.bottom.cancel().set(0);E.image.set(0);a.className="lbLoading";O=new Image();O.onload=A;O.src=N[c][0];return false}function A(){switch(H++){case 2:a.className="";I.set("html","");R.setStyles({backgroundImage:"url("+N[B][0]+")",display:""});$$(R,K).setStyle("width",O.width);$$(R,J,W).setStyle("height",O.height);Y.set("html",N[B][1]||"");C.set("html",(F.showCounter&&(N.length>1))?F.counterText.replace(/{x}/,B+1).replace(/{y}/,N.length):"");if(B){L.src=N[B-1][0]}if(B!=(N.length-1)){M.src=N[B+1][0]}if(a.clientHeight!=R.offsetHeight){E.resize.start({height:R.offsetHeight});break}H++;case 3:if(a.clientWidth!=R.offsetWidth){E.resize.start({width:R.offsetWidth,marginLeft:-R.offsetWidth/2});break}H++;case 4:Z.setStyles({top:Q+a.clientHeight,height:0,marginLeft:a.style.marginLeft,display:""});E.image.start(1);break;case 5:if(B){J.style.display=""}if(B<(N.length-1)){W.style.display=""}if(F.animateCaption){E.bottom.set(-K.offsetHeight).start(0)}Z.style.height="";H=1}}function P(){if(!H){return false}H=0;O.onload=$empty;for(var c in E){E[c].cancel()}$$(a,Z).setStyle("display","none");$("othergalleries").setStyle("visibility","visible");E.overlay.chain(S).start(0);return false}})();



// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)

Slimbox.scanPage = function() {

	var links = $$("a").filter(function(el) {

		return el.rel && el.rel.test(/^cfi/i);

	});

	// PUT YOUR CUSTOM OPTIONS INSIDE THE FOLLOWING {}

	$$(links).slimbox({}, null, function(el) {

		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));

	});
};
window.addEvent("domready", Slimbox.scanPage);
