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