(function(a){var o="colorbox",v="hover",m=true,e=false,c,B=!a.support.opacity,U=B&&!window.XMLHttpRequest,N="click.colorbox",Y="cbox_open",y="cbox_load",F="cbox_complete",G="cbox_cleanup",X="cbox_closed",L="resize.cbox_resize",Q="resize.cboxie6 scroll.cboxie6",s,i,t,j,M,K,J,I,d,n,f,E,D,W,O,r,z,A,H,p,q,w,x,l,k,h,g,b,C,P,S={transition:"elastic",speed:350,width:e,height:e,initialWidth:"400",initialHeight:"400",maxWidth:e,maxHeight:e,scalePhotos:m,scrollbars:m,inline:e,html:e,iframe:e,photo:e,href:e,title:e,rel:e,opacity:.9,preloading:m,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:e,overlayClose:m,slideshow:e,slideshowAuto:m,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow"};function R(a){if(a.keyCode===37){a.preventDefault();A.click()}else if(a.keyCode===39){a.preventDefault();z.click()}}function u(a,b){b=b==="x"?document.documentElement.clientWidth:document.documentElement.clientHeight;return typeof a==="string"?a.match(/%/)?b/100*parseInt(a,10):parseInt(a,10):a}function T(a){return b.photo||a.match(/\.(gif|png|jpg|jpeg|bmp|ashx)(?:\?([^#]*))?(?:#(\.*))?$/i)}function V(){for(var a in b)if(typeof b[a]==="function")b[a]=b[a].call(h)}c=a.fn.colorbox=function(f,i){if(this.length)this.each(function(){var b=a(this).data(o)?a.extend({},a(this).data(o),f):a.extend({},S,f);a(this).data(o,b).addClass("cboxelement")});else a(this).data(o,a.extend({},S,f));a(this).unbind(N).bind(N,function(j){h=this;b=a(h).data(o);V();a().bind("keydown.cbox_close",function(a){if(a.keyCode===27){a.preventDefault();c.close()}});b.overlayClose&&s.css({cursor:"pointer"}).one("click",c.close);h.blur();P=i||e;var f=b.rel||h.rel;if(f&&f!=="nofollow"){d=a(".cboxelement").filter(function(){var b=a(this).data(o).rel||this.rel;return b===f});g=d.index(h);if(g<0){d=d.add(h);g=d.length-1}}else{d=a(h);g=0}if(!C){C=m;a.event.trigger(Y);H.html(b.close);s.css({opacity:b.opacity}).show();c.position(u(b.initialWidth,"x"),u(b.initialHeight,"y"),0);U&&n.bind(Q,function(){s.css({width:n.width(),height:n.height(),top:n.scrollTop(),left:n.scrollLeft()})}).trigger(Q)}c.slideshow();c.load();j.preventDefault()});f&&f.open&&a(this).triggerHandler(N);return this};c.init=function(){function b(b){return a('<div id="cbox'+b+'"/>')}n=a(window);i=a('<div id="colorbox"/>');s=b("Overlay").hide();t=b("Wrapper");j=b("Content").append(f=b("LoadedContent").css({width:0,height:0}),E=b("LoadingOverlay"),D=b("LoadingGraphic"),W=b("Title"),O=b("Current"),r=b("Slideshow"),z=b("Next"),A=b("Previous"),H=b("Close"));t.append(a("<div/>").append(b("TopLeft"),M=b("TopCenter"),b("TopRight")),a("<div/>").append(K=b("MiddleLeft"),j,J=b("MiddleRight")),a("<div/>").append(b("BottomLeft"),I=b("BottomCenter"),b("BottomRight"))).children().children().css({"float":"left"});a("body").prepend(s,i.append(t));if(B){i.addClass("cboxIE");U&&s.css("position","absolute")}j.children().addClass(v).mouseover(function(){a(this).addClass(v)}).mouseout(function(){a(this).removeClass(v)}).hide();p=M.height()+I.height()+j.outerHeight(m)-j.height();q=K.width()+J.width()+j.outerWidth(m)-j.width();w=f.outerHeight(m);x=f.outerWidth(m);i.css({"padding-bottom":p,"padding-right":q}).hide();z.click(c.next);A.click(c.prev);H.click(c.close);j.children().removeClass(v)};c.position=function(b,a,k,g){var e=document.documentElement.clientHeight,c=e/2-a/2,d=document.documentElement.clientWidth/2-b/2,h;if(a>e)c-=a-e;if(c<0)c=0;if(d<0)d=0;c+=n.scrollTop();d+=n.scrollLeft();b=b-q;a=a-p;h=i.width()===b&&i.height()===a?0:k;t[0].style.width=t[0].style.height="9999px";function f(a){M[0].style.width=I[0].style.width=j[0].style.width=a.style.width;D[0].style.height=E[0].style.height=j[0].style.height=K[0].style.height=J[0].style.height=a.style.height}i.dequeue().animate({height:a,width:b,top:c,left:d},{duration:h,complete:function(){f(this);t[0].style.width=b+q+"px";t[0].style.height=a+p+"px";g&&g()},step:function(){f(this)}})};c.resize=function(M){if(!C)return;var H,e,u,J,y,I,v,s,S,t=b.transition==="none"?0:b.speed;n.unbind(L);if(!M){S=setTimeout(function(){e=f.children().outerHeight(m);f[0].style.height=e+"px";c.position(f.width()+x+q,e+w+p,t)},1);return}f.remove();f=a(M);function Q(){H=b.width?l:l&&l<f.width()?l:f.width();return H}function N(){e=b.height?k:k&&k<f.height()?k:f.height();return e}!b.scrollbars&&f.css({overflow:"hidden"});f.hide().appendTo("body").attr({id:"cboxLoadedContent"}).css({width:Q()}).css({height:N()}).prependTo(j);U&&a("select:not(#colorbox select)").filter(function(){return a(this).css("visibility")!=="hidden"}).css({visibility:"hidden"}).one(G,function(){a(this).css({visibility:"inherit"})});s=a("#cboxPhoto")[0];if(s&&b.height){u=(e-parseInt(s.style.height,10))/2;s.style.marginTop=(u>0?u:0)+"px"}function K(m){var l=H+x+q,k=e+w+p;a().unbind("keydown",R);c.position(l,k,m,function(){if(!C)return;if(B){s&&f.fadeIn(100);i[0].style.removeAttribute("filter")}j.children().show();a("#cboxIframeTemp").after("<iframe id='cboxIframe' name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+(b.href||h.href)+"' />").remove();E.hide();D.hide();r.hide();if(d.length>1){O.html(b.current.replace(/\{current\}/,g+1).replace(/\{total\}/,d.length));z.html(b.next);A.html(b.previous);a().bind("keydown",R);b.slideshow&&r.show()}else{O.hide();z.hide();A.hide()}W.html(b.title||h.title);a.event.trigger(F);P&&P.call(h);b.transition==="fade"&&i.fadeTo(t,1,function(){B&&i[0].style.removeAttribute("filter")});n.bind(L,function(){c.position(l,k,0)})})}if(b.transition==="fade"&&i.fadeTo(t,0,function(){K(0)})||K(t));if(b.preloading&&d.length>1){J=g>0?d[g-1]:d[d.length-1];I=g<d.length-1?d[g+1]:d[0];v=a(I).data(o).href||I.href;y=a(J).data(o).href||J.href;T(v)&&a("<img />").attr("src",v);T(y)&&a("<img />").attr("src",y)}};c.load=function(){var i,m,n,r,j=c.resize;h=d[g];b=a(h).data(o);V();a.event.trigger(y);i=b.height?u(b.height,"y")-w-p:e;m=b.width?u(b.width,"x")-x-q:e;n=b.href||h.href;E.show();D.show();H.show();if(b.maxHeight){k=b.maxHeight?u(b.maxHeight,"y")-w-p:e;i=i&&i<k?i:k}if(b.maxWidth){l=b.maxWidth?u(b.maxWidth,"x")-x-q:e;m=m&&m<l?m:l}k=i;l=m;if(b.inline){a('<div id="cboxInlineTemp" />').hide().insertBefore(a(n)[0]).bind(y+" "+G,function(){f.children().insertBefore(this);a(this).remove()});j(a(n).wrapAll("<div/>").parent())}else if(b.iframe)j(a("<div><div id='cboxIframeTemp' /></div>"));else if(b.html)j(a("<div/>").html(b.html));else if(T(n)){r=new Image;r.onload=function(){r.onload=null;if((k||l)&&b.scalePhotos){var f=this.width,e=this.height,g=0,i=this,h=function(){e+=e*g;f+=f*g;i.height=e;i.width=f};if(l&&f>l){g=(l-f)/f;h()}if(k&&e>k){g=(k-e)/e;h()}}j(a("<div />").css({width:this.width,height:this.height}).append(a(this).css({width:this.width,height:this.height,display:"block",margin:"auto",border:0}).attr("id","cboxPhoto")));d.length>1&&a(this).css({cursor:"pointer"}).click(c.next);if(B)this.style.msInterpolationMode="bicubic"};r.src=n}else a("<div />").load(n,function(c,b){if(b==="success")j(a(this));else j(a("<p>Request unsuccessful.</p>"))})};c.next=function(){g=g<d.length-1?g+1:0;c.load()};c.prev=function(){g=g>0?g-1:d.length-1;c.load()};c.slideshow=function(){var g,e,f="cboxSlideshow_";r.bind(G,function(){clearTimeout(e);r.unbind(F+" "+y+" click")});function h(){r.text(b.slideshowStop).bind(F,function(){e=setTimeout(c.next,b.slideshowSpeed)}).bind(y,function(){clearTimeout(e)}).one("click",function(){g();a(this).removeClass(v)});i.removeClass(f+"off").addClass(f+"on")}g=function(){clearTimeout(e);r.text(b.slideshowStart).unbind(F+" "+y).one("click",function(){h();e=setTimeout(c.next,b.slideshowSpeed);a(this).removeClass(v)});i.removeClass(f+"on").addClass(f+"off")};if(b.slideshow&&d.length>1)if(b.slideshowAuto)h();else g()};c.close=function(){a.event.trigger(G);C=e;a().unbind("keydown",R).unbind("keydown.cbox_close");n.unbind(L+" "+Q);s.css({cursor:"auto"}).fadeOut("fast");i.stop(m,e).fadeOut("fast",function(){f.remove();i.css({opacity:1});j.children().hide();a.event.trigger(X)})};c.element=function(){return h};c.settings=S;a(c.init)})(jQuery);