/*
	Slimbox v2.02 - The ultimate lightweight Lightbox clone for jQuery
	(c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
(function(A){var J=A(window),y,n,g,K=-1,q,B,I,z,C,Q,v,p=!window.XMLHttpRequest,e=window.opera&&(document.compatMode=="CSS1Compat")&&(A.browser.version>=9.3),o=document.documentElement,m={},x=new Image(),O=new Image(),M,b,h,s,N,d,L,c,F,P;A(function(){A("body").append(A([M=A('<div id="lbOverlay" />')[0],L=A('<div id="lbBottomContainer" />')[0],b=A('<div id="lbCenter" />')[0]]).css("display","none"));h=A('<div id="lbImage" />').appendTo(b).append(s=A('<div style="position: relative;" />').append([N=A('<a id="lbPrevLink" href="#" />').click(function(R){D();R.preventDefault();return false})[0],d=A('<a id="lbNextLink" href="#" />').click(function(R){f();R.preventDefault();return false})[0]])[0])[0];c=A('<div id="lbBottom" />').appendTo(L).append([A('<a id="lbCloseLink" href="#" />').add(M).click(H)[0],F=A('<div id="lbCaption" />')[0],P=A('<div id="lbNumber" />')[0],A('<div style="clear: both;" />')[0]])[0]});A.slimbox=function(V,T,R){y=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],canViewRestricted:false,enableRestrictedCallback:null,restrictedPlaceHolder:""},R);if(typeof V=="string"){V=[[V,T]];T=0}w(y.initialWidth,y.initialHeight);z=p||(M.currentStyle&&(M.currentStyle.position!="fixed"));if(z){M.style.position="absolute"}A(M).css("opacity",y.overlayOpacity).fadeIn(y.overlayFadeDuration);E();l(1);n=new Array();for(var U=0;U<V.length;U++){n[U]=V[U].ImageUrl}g=V;y.loop=y.loop&&(g.length>1);var S=false;for(var U=0;U<g.length;U++){if(g[U].IsRestricted&&!y.canViewRestricted){n[U]=y.restrictedPlaceHolder;S=true}}if(S&&!y.canViewRestricted&&!y.isMinor){w(500,320);A(h).css("display","none");div=A('<div id="restrictedContent" ><h1>Restricted content</h1><p>Certain images contain adult content that is considered unsuitable for younger users.</p><p>By clicking agree you acknowledge that you are at least 18 years of age and at least the age of majority where you are located.</p><p>If you do not meet the age requirement or do not wish to proceed, click Disagree. This will display only the unrestricted images.</p></div>').appendTo(b);disagree=A('<input type="image" src="/images/buttons/disagree.gif" alt="Disagree" />').bind("click",{imageIndex:T},G).appendTo(div);agree=A('<input type="image" src="/images/buttons/agree_arrow.gif" alt="Agree" />').bind("click",{imageIndex:T},u).appendTo(div);return false}else{return a(T)}};A.fn.slimbox=function(R,U,T){U=U||function(V){return[V.href,V.title]};T=T||function(){return true};var S=this;return S.unbind("click").click(function(){var X=this,Z=0,Y,V=0,W;Y=A.grep(S,function(ab,aa){return T.call(X,ab,aa)});for(W=Y.length;V<W;++V){if(Y[V]==X){Z=V}Y[V]=U(Y[V],V)}return A.slimbox(Y,Z,R)})};function G(S){var R=S.data.imageIndex;A("#restrictedContent").remove();A(h).css("display","block");return a(R)}function u(T){var R=T.data.imageIndex;A("#restrictedContent").remove();A(h).css("display","block");y.enableRestrictedCallback();for(var S=0;S<g.length;S++){n[S]=g[S].ImageUrl}return a(R)}function w(S,R){C=J.scrollTop()+((e?o.clientHeight:J.height())/2);Q=S;v=R;A(b).css({top:Math.max(0,C-(v/2)),width:Q,height:v,marginLeft:-Q/2}).show()}function E(){var S=J.scrollLeft(),R=e?o.clientWidth:J.width();A([b,L]).css("left",S+(R/2));if(z){A(M).css({left:S,top:J.scrollTop(),width:R,height:J.height()})}}function l(R){A("object").add(p?"select":"embed").each(function(T,U){if(R){A.data(U,"slimbox",U.style.visibility)}U.style.visibility=R?"hidden":A.data(U,"slimbox")});var S=R?"bind":"unbind";J[S]("scroll resize",E);A(document)[S]("keydown",r)}function r(T){var S=T.keyCode,R=A.inArray;return(R(S,y.closeKeys)>=0)?H():(R(S,y.nextKeys)>=0)?f():(R(S,y.previousKeys)>=0)?D():false}function D(){return a(B)}function f(){return a(I)}function a(R){if(R>=0){K=R;q=n[K];B=(K||(y.loop?g.length:0))-1;I=((K+1)%g.length)||(y.loop?0:-1);t();b.className="lbLoading";m=new Image();m.onload=k;m.src=q;i(g[K].PhotoId)}return false}function k(){b.className="";A(h).css({backgroundImage:"url("+q+")",visibility:"hidden",display:""});A(s).width(m.width);A([s,N,d]).height(m.height);A(F).html(g[K].Caption||"");A(P).html((((g.length>1)&&y.counterText)||"").replace(/{x}/,K+1).replace(/{y}/,g.length));if(B>=0){x.src=g[B][0]}if(I>=0){O.src=g[I][0]}Q=h.offsetWidth;v=h.offsetHeight;var R=Math.max(0,C-(v/2));if(b.offsetHeight!=v){A(b).animate({height:v,top:R},y.resizeDuration,y.resizeEasing)}if(b.offsetWidth!=Q){A(b).animate({width:Q,marginLeft:-Q/2},y.resizeDuration,y.resizeEasing)}A(b).queue(function(){var S=A(L).css("height");A(L).css({width:Q,top:R-38,marginLeft:-Q/2,visibility:"hidden",display:""});A(h).css({display:"none",visibility:"",opacity:""}).fadeIn(y.imageFadeDuration,j)})}function j(){if(B>=0){A(N).show()}if(I>=0){A(d).show()}A(c).css("marginBottom",-c.offsetHeight).animate({marginBottom:0},y.captionAnimationDuration);L.style.visibility=""}function t(){m.onload=null;m.src=x.src=O.src=q;A([b,h,c]).stop(true);A([N,d,h,L]).hide()}function H(){if(K>=0){t();K=B=I=-1;A(b).hide();A(M).stop().fadeOut(y.overlayFadeDuration,l)}return false}function i(R){A.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:"/services/MembershipService.asmx/TrackPhotoView",data:'{"photoId":"'+R+'"}',dataType:"json"})}})(jQuery);