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