/*
	Slimbox v2.02 - The ultimate lightweight Lightbox clone for jQuery
	(c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
(function(x){var F=x(window),v,g,G=-1,p,y,E,w,z,N,I,t,i,o=!window.XMLHttpRequest,e=window.opera&&(document.compatMode=="CSS1Compat")&&(x.browser.version>=9.3),n=document.documentElement,m={},u=new Image(),L=new Image(),J,b,h,r,K,d,H,c,B,M;x(function(){x("body").append(x([J=x('<div id="lbOverlay" />')[0],b=x('<div id="lbCenter" />')[0],H=x('<div id="lbBottomContainer" />')[0]]).css("display","none"));h=x('<div id="lbImage" />').appendTo(b).append(r=x('<div style="position: relative;" />').append([K=x('<a id="lbPrevLink" href="#" />').click(C)[0],d=x('<a id="lbNextLink" href="#" />').click(f)[0]])[0])[0];c=x('<div id="lbBottom" />').appendTo(H).append([x('<a id="lbCloseLink" href="#" />').add(J).click(D)[0],B=x('<div id="lbCaption" />')[0],M=x('<div id="lbNumber" />')[0],x('<div style="clear: both;" />')[0]])[0]});x.slimbox=function(Q,P,O){v=x.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},O);if(typeof Q=="string"){Q=[[Q,P]];P=0}z=F.scrollTop()+((e?n.clientHeight:F.height())/2);N=v.initialWidth;t=v.initialHeight;I=N+(o?0:parseInt(x(b).css("border-left-width"))+parseInt(x(b).css("border-right-width")));i=t+(o?0:parseInt(x(b).css("border-top-width"))+parseInt(x(b).css("border-bottom-width")));x(b).css({top:Math.max(0,z-(i/2)),width:N,height:t,marginLeft:-I/2}).show();w=o||(J.currentStyle&&(J.currentStyle.position!="fixed"));if(w){J.style.position="absolute"}x(J).css("opacity",v.overlayOpacity).fadeIn(v.overlayFadeDuration);A();l(1);g=Q;v.loop=v.loop&&(g.length>1);return a(P)};x.fn.slimbox=function(O,R,Q){R=R||function(S){return[S.href,S.title]};Q=Q||function(){return true};var P=this;return P.unbind("click").click(function(){var U=this,W=0,V,S=0,T;V=x.grep(P,function(Y,X){return Q.call(U,Y,X)});for(T=V.length;S<T;++S){if(V[S]==U){W=S}V[S]=R(V[S],S)}return x.slimbox(V,W,O)})};function A(){var P=F.scrollLeft(),O=e?n.clientWidth:F.width();x([b,H]).css("left",P+(O/2));if(w){x(J).css({left:P,top:F.scrollTop(),width:O,height:F.height()})}}function l(O){x("object").add(o?"select":"embed").each(function(Q,R){if(O){x.data(R,"slimbox",R.style.visibility)}R.style.visibility=O?"hidden":x.data(R,"slimbox")});var P=O?"bind":"unbind";F[P]("scroll resize",A);x(document)[P]("keydown",q)}function q(Q){var P=Q.keyCode,O=x.inArray;return(O(P,v.closeKeys)>=0)?D():(O(P,v.nextKeys)>=0)?f():(O(P,v.previousKeys)>=0)?C():false}function C(){return a(y)}function f(){return a(E)}function a(O){if(O>=0){G=O;p=g[G][0];y=(G||(v.loop?g.length:0))-1;E=((G+1)%g.length)||(v.loop?0:-1);s();b.className="lbLoading";m=new Image();m.onload=k;m.src=p}return false}function k(){b.className="";x(h).css({backgroundImage:"url("+p+")",visibility:"hidden",display:""});x(r).width(m.width);x([r,K,d]).height(m.height);x(B).html(g[G][1]||"");x(M).html((((g.length>1)&&v.counterText)||"").replace(/{x}/,G+1).replace(/{y}/,g.length));if(y>=0){u.src=g[y][0]}if(E>=0){L.src=g[E][0]}N=h.offsetWidth;t=h.offsetHeight;I=N+(o?0:parseInt(x(b).css("border-left-width"))+parseInt(x(b).css("border-right-width")));i=t+(o?0:parseInt(x(b).css("border-top-width"))+parseInt(x(b).css("border-bottom-width")));var O=Math.max(0,z-(i/2));if(b.offsetHeight!=t){x(b).animate({height:t,top:O},v.resizeDuration,v.resizeEasing)}if(b.offsetWidth!=N){x(b).animate({width:N,marginLeft:-I/2},v.resizeDuration,v.resizeEasing)}x(b).queue(function(){x(H).css({width:N,top:O+t-(o?parseInt(x(b).css("border-bottom-width")):0),marginLeft:-I/2,visibility:"hidden",display:""});x(h).css({display:"none",visibility:"",opacity:""}).fadeIn(v.imageFadeDuration,j)})}function j(){if(y>=0){x(K).show()}if(E>=0){x(d).show()}x(c).css("marginTop",-c.offsetHeight).animate({marginTop:0},v.captionAnimationDuration);H.style.visibility=""}function s(){m.onload=null;m.src=u.src=L.src=p;x([b,h,c]).stop(true);x([K,d,h,H]).hide()}function D(){if(G>=0){s();G=y=E=-1;x(b).hide();x(J).stop().fadeOut(v.overlayFadeDuration,l)}return false}})(jQuery);

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
jQuery(function($) {
	$("a[rel^='lightbox']").slimbox({initialWidth: 170, initialHeight: 170, counterText: "{x}/{y}", closeKeys: [27, 88], previousKeys: [37], nextKeys: [39]}, null, function(el) {
		return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
	});
});