/*
	Slimbox v2.02 - The ultimate lightweight Lightbox clone for jQuery
	(c) 2007-2009 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
(function(z){var I=z(window),w,y,g,J=-1,o,A,H,x,B,Q,t,n=!window.XMLHttpRequest,e=window.opera&&(document.compatMode=="CSS1Compat")&&(z.browser.version>=9.3),m=document.documentElement,L=false,l={},v=new Image(),O=new Image(),M,b,h,q,N,d,K,c,E,P;z(function(){z("body").append(z([M=z('<div id="lbOverlay" />')[0],K=z('<div id="lbBottomContainer" />')[0],b=z('<div id="lbCenter" />')[0]]).css("display","none"));h=z('<div id="lbImage" />').appendTo(b).append(q=z('<div style="position: relative;" />').append([N=z('<a id="lbPrevLink" href="#" />').click(function(R){C();R.preventDefault();return false})[0],d=z('<a id="lbNextLink" href="#" />').click(function(R){f();R.preventDefault();return false})[0]])[0])[0];c=z('<div id="lbBottom" />').appendTo(K).append([z('<a id="lbCloseLink" href="#" />').add(M).click(G)[0],E=z('<div id="lbCaption" />')[0],P=z('<div id="lbNumber" />')[0],z('<div style="clear: both;" />')[0]])[0]});z.slimbox=function(V,T,R){w=z.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],checkRestricted:null,restrictedPlaceHolder:""},R);if(typeof V=="string"){V=[[V,T]];T=0}u(w.initialWidth,w.initialHeight);x=n||(M.currentStyle&&(M.currentStyle.position!="fixed"));if(x){M.style.position="absolute"}z(M).css("opacity",w.overlayOpacity).fadeIn(w.overlayFadeDuration);D();k(1);y=V.slice();g=V;w.loop=w.loop&&(g.length>1);if(w.checkRestricted!=null){L=w.checkRestricted()}var S=false;if(g[0].length==3){for(var U=0;U<g.length;U++){if(g[U][2]&&!L){g[U]=[w.restrictedPlaceHolder,""];S=true}}}if(S&&!L&&!w.isMinor){u(500,320);z(h).css("display","none");div=z('<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 return you to your original page.</p></div>').appendTo(b);disagree=z('<input type="image" src="/images/buttons/disagree.gif" alt="Disagree" />').bind("click",{imageIndex:T},F).appendTo(div);agree=z('<input type="image" src="/images/buttons/agree_arrow.gif" alt="Agree" />').bind("click",{imageIndex:T},s).appendTo(div);return false}else{return a(T)}};z.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=z.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 z.slimbox(Y,Z,R)})};function F(S){var R=S.data.imageIndex;z("#restrictedContent").remove();z(h).css("display","block");return a(R)}function s(S){var R=S.data.imageIndex;z("#restrictedContent").remove();z(h).css("display","block");z.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:"/services/MembershipService.asmx/EnableRestrictedContent",data:"{}",dataType:"json"});g=y;return a(R)}function u(S,R){B=I.scrollTop()+((e?m.clientHeight:I.height())/2);Q=S;t=R;z(b).css({top:Math.max(0,B-(t/2)),width:Q,height:t,marginLeft:-Q/2}).show()}function D(){var S=I.scrollLeft(),R=e?m.clientWidth:I.width();z([b,K]).css("left",S+(R/2));if(x){z(M).css({left:S,top:I.scrollTop(),width:R,height:I.height()})}}function k(R){z("object").add(n?"select":"embed").each(function(T,U){if(R){z.data(U,"slimbox",U.style.visibility)}U.style.visibility=R?"hidden":z.data(U,"slimbox")});var S=R?"bind":"unbind";I[S]("scroll resize",D);z(document)[S]("keydown",p)}function p(T){var S=T.keyCode,R=z.inArray;return(R(S,w.closeKeys)>=0)?G():(R(S,w.nextKeys)>=0)?f():(R(S,w.previousKeys)>=0)?C():false}function C(){return a(A)}function f(){return a(H)}function a(R){if(R>=0){J=R;o=g[J][0];A=(J||(w.loop?g.length:0))-1;H=((J+1)%g.length)||(w.loop?0:-1);r();b.className="lbLoading";l=new Image();l.onload=j;l.src=o}return false}function j(){b.className="";z(h).css({backgroundImage:"url("+o+")",visibility:"hidden",display:""});z(q).width(l.width);z([q,N,d]).height(l.height);z(E).html(g[J][1]||"");z(P).html((((g.length>1)&&w.counterText)||"").replace(/{x}/,J+1).replace(/{y}/,g.length));if(A>=0){v.src=g[A][0]}if(H>=0){O.src=g[H][0]}Q=h.offsetWidth;t=h.offsetHeight;var R=Math.max(0,B-(t/2));if(b.offsetHeight!=t){z(b).animate({height:t,top:R},w.resizeDuration,w.resizeEasing)}if(b.offsetWidth!=Q){z(b).animate({width:Q,marginLeft:-Q/2},w.resizeDuration,w.resizeEasing)}z(b).queue(function(){var S=z(K).css("height");z(K).css({width:Q,top:R-38,marginLeft:-Q/2,visibility:"hidden",display:""});z(h).css({display:"none",visibility:"",opacity:""}).fadeIn(w.imageFadeDuration,i)})}function i(){if(A>=0){z(N).show()}if(H>=0){z(d).show()}z(c).css("marginBottom",-c.offsetHeight).animate({marginBottom:0},w.captionAnimationDuration);K.style.visibility=""}function r(){l.onload=null;l.src=v.src=O.src=o;z([b,h,c]).stop(true);z([N,d,h,K]).hide()}function G(){if(J>=0){r();J=A=H=-1;z(b).hide();z(M).stop().fadeOut(w.overlayFadeDuration,k)}return false}})(jQuery);