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

