/*
	Slimbox v1.69 - The ultimate lightweight Lightbox clone
	(c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
var Slimbox=(function(){var G=window,n=Browser.Engine.trident4,u,g,H=-1,o,x,F,v,z,N,s,m={},t=new Image(),L=new Image(),J,b,h,q,K,e,I,c,w,B,M,y,i,d,D;G.addEvent("domready",function(){$(document.body).adopt($$(J=new Element("div",{id:"lbOverlay",events:{click:E}}),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:C}}),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:E}}),w=new Element("a",{id:"lbFlickrLink",href:"#"}),B=new Element("div",{id:"lbCaption"}),M=new Element("div",{id:"lbNumber"}),new Element("div",{styles:{clear:"both"}}))});function A(){var O=G.getScroll(),P=G.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";G[P]("scroll",A)[P]("resize",A);document[P]("keydown",p)}function p(P){var O=P.code;return u.closeKeys.contains(O)?E():u.nextKeys.contains(O)?f():u.previousKeys.contains(O)?C():false}function C(){return a(x)}function f(){return a(F)}function a(O){if(O>=0){H=O;o=g[O][0];x=(H||(u.loop?g.length:0))-1;F=((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);B.set("html",g[H][1]||"");M.set("html",(((g.length>1)&&u.counterText)||"").replace(/{x}/,H+1).replace(/{y}/,g.length));var Q=g[H][0].match(/flickr\.com\/\d+\/(\d+)_/);if(Q){w.href="http://www.flickr.com/photos/"+u.flickrUser+"/"+Q[1]+"/";w.setStyle("display","block")}else{w.setStyle("display","none")}if(x>=0){t.src=g[x][0]}if(F>=0){L.src=g[F][0]}N=h.offsetWidth;s=h.offsetHeight;var P=Math.max(0,z-(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(x>=0){K.style.display=""}if(F>=0){e.style.display=""}D.set(-c.offsetHeight).start(0);I.style.visibility=""}function r(){m.onload=$empty;m.src=t.src=L.src=o;i.cancel();d.cancel();D.cancel();$$(K,e,h,I).setStyle("display","none")}function E(){if(H>=0){r();H=x=F=-1;b.style.display="none";y.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]};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}",flickrUser:"Please Set It Below",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},O||{});y=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});D=new Fx.Tween(c,{property:"margin-top",duration:u.captionAnimationDuration});if(typeof Q=="string"){Q=[[Q,P]];P=0}z=G.getScrollTop()+(G.getHeight()/2);N=u.initialWidth;s=u.initialHeight;b.setStyles({top:Math.max(0,z-(s/2)),width:N,height:s,marginLeft:-N/2,display:""});v=n||(J.currentStyle&&(J.currentStyle.position!="fixed"));if(v){J.style.position="absolute"}y.set(0).start(u.overlayOpacity);A();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() {
	var options = {
		/* Put custom options here. 
		   Format: (separate each with comma)
			option: value, */ 
		/* please set flickrUser to getting correct flickr url. */
	};

	$$(document.links).filter(function(el) {
		return el.rel && el.rel.test(/^lightbox/i);
	}).slimbox(options, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
};
window.addEvent("domready", Slimbox.scanPage);
