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