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

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
	jQuery(function($) {
		$("a[rel^='lightbox']").slimbox({initialWidth: 420, initialHeight: 420, counterText: "{x}/{y}", closeKeys: [27, 88], previousKeys: [37], nextKeys: [39]}, null, function(el) {
			return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
		});
	});
}