/*
	Slimbox v1.66 - The ultimate lightweight Lightbox clone
	(c) 2007-2008 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
var Slimbox;(function(){var B=window,J=0,q,g,C,s,A,r,u,I,o,m,p=new Image(),G=new Image(),E,a,h,F,e,D,c,w,H,t,i,d,y;B.addEvent("domready",function(){$(document.body).adopt($$(E=new Element("div",{id:"lbOverlay"}).addEvent("click",z),a=new Element("div",{id:"lbCenter"}),D=new Element("div",{id:"lbBottomContainer"})).setStyle("display","none"));h=new Element("div",{id:"lbImage"}).injectInside(a).adopt(F=new Element("a",{id:"lbPrevLink",href:"#"}).addEvent("click",x),e=new Element("a",{id:"lbNextLink",href:"#"}).addEvent("click",f));c=new Element("div",{id:"lbBottom"}).injectInside(D).adopt(new Element("a",{id:"lbCloseLink",href:"#"}).addEvent("click",z),w=new Element("div",{id:"lbCaption"}),H=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}))});Slimbox={open:function(M,L,K){q=$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}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},K||{});t=new Fx.Tween(E,{property:"opacity",duration:q.overlayFadeDuration});i=new Fx.Morph(a,$extend({duration:q.resizeDuration,link:"chain"},q.resizeTransition?{transition:q.resizeTransition}:{}));d=new Fx.Tween(h,{property:"opacity",duration:q.imageFadeDuration,onComplete:j});y=new Fx.Tween(c,{property:"margin-top",duration:q.captionAnimationDuration});if(typeof M=="string"){M=[[M,L]];L=0}u=B.getScrollTop()+(B.getHeight()/2);I=q.initialWidth;o=q.initialHeight;a.setStyles({top:Math.max(0,u-(o/2)),width:I,height:o,marginLeft:-I/2,display:""});r=!B.XMLHttpRequest||(E.currentStyle&&(E.currentStyle.position!="fixed"));if(r){E.style.position="absolute"}t.set(0).start(q.overlayOpacity);v();l(true);J=1;g=M;q.loop=q.loop&&(g.length>1);return b(L)}};Element.implement({slimbox:function(K,L){$$(this).slimbox(K,L);return this}});Elements.implement({slimbox:function(K,N,M){N=N||function(O){return[O.href,O.title]};M=M||function(){return true};var L=this;L.removeEvents("click").addEvent("click",function(){var O=L.filter(M,this);return Slimbox.open(O.map(N),O.indexOf(this),K)});return L}});function v(){var K=B.getScroll(),L=B.getSize();$$(a,D).setStyle("left",K.x+(L.x/2));if(r){E.setStyles({left:K.x,top:K.y,width:L.x,height:L.y})}}function l(K){["object",Browser.Engine.trident?"select":"embed"].forEach(function(M){Array.forEach(document.getElementsByTagName(M),function(N){if(K){N._slimbox=N.style.visibility}N.style.visibility=K?"hidden":N._slimbox})});E.style.display=K?"":"none";var L=K?"addEvent":"removeEvent";B[L]("scroll",v)[L]("resize",v);document[L]("keydown",n)}function n(L){var K=L.code;return q.closeKeys.contains(K)?z():q.nextKeys.contains(K)?f():q.previousKeys.contains(K)?x():false}function x(){return b(s)}function f(){return b(A)}function b(K){if((J==1)&&(K>=0)){J=2;C=K;s=(C||(q.loop?g.length:0))-1;A=((C+1)%g.length)||(q.loop?0:-1);y.cancel();$$(F,e,h,D).setStyle("display","none");a.className="lbLoading";m=new Image();m.onload=k;m.src=g[K][0]}return false}function k(){a.className="";d.set(0);h.setStyles({width:m.width,backgroundImage:"url("+g[C][0]+")",display:""});$$(h,F,e).setStyle("height",m.height);w.set("html",g[C][1]||"");H.set("html",(((g.length>1)&&q.counterText)||"").replace(/{x}/,C+1).replace(/{y}/,g.length));if(s>=0){p.src=g[s][0]}if(A>=0){G.src=g[A][0]}I=h.offsetWidth;o=h.offsetHeight;var L=Math.max(0,u-(o/2)),K;if(a.clientHeight!=o){i.start({height:o,top:L})}if(a.clientWidth!=I){i.start({width:I,marginLeft:-I/2})}K=function(){D.setStyles({width:I,top:L+o,marginLeft:-I/2,visibility:"hidden",display:""});d.start(1)};if(i.check(K)){K()}}function j(){if(s>=0){F.style.display=""}if(A>=0){e.style.display=""}y.set(-c.offsetHeight).start(0);D.style.visibility="";J=1}function z(){if(J){J=0;m.onload=$empty;[t,i,d,y].forEach(function(K){K.cancel()});$$(a,D).setStyle("display","none");t.chain(l).start(0)}return false}})();

// 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({/* Put custom options here */}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
};
window.addEvent("domready", Slimbox.scanPage);
