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