(function(i,m,s){function q(ad){if(!N){t=ad,d(i.extend(X,i.data(t,A))),aa=i(t),x=0,X.rel!=="nofollow"&&(aa=i("."+U).filter(function(){var af=i.data(this,A).rel||this.rel;return af===X.rel}),x=aa.index(t),x===-1&&(aa=aa.add(t),x=aa.length-1));if(!F){F=J=!0,z.show();if(X.returnFocus){try{t.blur(),i(t).one(Z,function(){try{this.focus()}catch(af){}})}catch(ae){}}v.css({opacity:+X.opacity,cursor:X.overlayClose?"pointer":"auto"}).show(),X.w=ac(X.initialWidth,"x"),X.h=ac(X.initialHeight,"y"),Q.position(0),n&&a.bind("resize."+r+" scroll."+r,function(){v.css({width:a.width(),height:a.height(),top:a.scrollTop(),left:a.scrollLeft()})}).trigger("resize."+r),e(I,X.onOpen),T.add(u).hide(),P.html(X.close).show()}Q.load(!0)}}function g(){var ad,ae=E+"Slideshow_",af="click."+E,ag,ah,ai;X.slideshow&&aa[1]&&(ag=function(){C.text(X.slideshowStop).unbind(af).bind(R,function(){if(x<aa.length-1||X.loop){ad=setTimeout(Q.next,X.slideshowSpeed)}}).bind(M,function(){clearTimeout(ad)}).one(af+" "+V,ah),z.removeClass(ae+"off").addClass(ae+"on"),ad=setTimeout(Q.next,X.slideshowSpeed)},ah=function(){clearTimeout(ad),C.text(X.slideshowStart).unbind([R,M,V,af].join(" ")).one(af,ag),z.removeClass(ae+"on").addClass(ae+"off")},X.slideshowAuto?ag():ah())}function e(ad,ae){ae&&ae.call(t),i.event.trigger(ad)}function d(ad){for(var ae in ad){i.isFunction(ad[ae])&&ae.substring(0,2)!=="on"&&(ad[ae]=ad[ae].call(t))}ad.rel=ad.rel||t.rel||"nofollow",ad.href=i.trim(ad.href||i(t).attr("href")),ad.title=ad.title||t.title}function b(ad){return X.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(ad)}function ac(ad,ae){ae=ae==="x"?a.width():a.height();return typeof ad=="string"?Math.round(/%/.test(ad)?ae/100*parseInt(ad,10):parseInt(ad,10)):ad}function Y(ad,ae){var af=m.createElement("div");ad&&(af.id=E+ad),af.style.cssText=ae||!1;return i(af)}var w={transition:"elastic",speed:300,width:!1,initialWidth:"600",innerWidth:!1,maxWidth:!1,height:!1,initialHeight:"450",innerHeight:!1,maxHeight:!1,scalePhotos:!0,scrolling:!0,inline:!1,html:!1,iframe:!1,fastIframe:!0,photo:!1,href:!1,title:!1,rel:!1,opacity:0.9,preloading:!0,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:!1,returnFocus:!0,loop:!0,slideshow:!1,slideshowAuto:!0,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:!1,onLoad:!1,onComplete:!1,onCleanup:!1,onClosed:!1,overlayClose:!0,escKey:!0,arrowKey:!0},A="colorbox",E="cbox",I=E+"_open",M=E+"_load",R=E+"_complete",V=E+"_cleanup",Z=E+"_closed",f=E+"_purge",j=i.browser.msie&&!i.support.opacity,n=j&&i.browser.version<7,r=E+"_IE6",v,z,D,H,L,O,S,W,aa,a,c,k,o,u,y,C,G,K,P,T,X={},ab,h,l,p,t,x,B,F,J,N=!1,Q,U=E+"Element";Q=i.fn[A]=i[A]=function(ad,ae){var af=this,ag;if(!af[0]&&af.selector){return af}ad=ad||{},ae&&(ad.onComplete=ae);if(!af[0]||af.selector===undefined){af=i("<a/>"),ad.open=!0}af.each(function(){i.data(this,A,i.extend({},i.data(this,A)||w,ad)),i(this).addClass(U)}),ag=ad.open,i.isFunction(ag)&&(ag=ag.call(af)),ag&&q(af[0]);return af},Q.init=function(){a=i(s),z=Y().attr({id:A,"class":j?E+(n?"IE6":"IE"):""}),v=Y("Overlay",n?"position:absolute":"").hide(),D=Y("Wrapper"),H=Y("Content").append(c=Y("LoadedContent","width:0; height:0; overflow:hidden"),o=Y("LoadingOverlay").add(Y("LoadingGraphic")),u=Y("Title"),y=Y("Current"),G=Y("Next"),K=Y("Previous"),C=Y("Slideshow").bind(I,g),P=Y("Close")),D.append(Y().append(Y("TopLeft"),L=Y("TopCenter"),Y("TopRight")),Y(!1,"clear:left").append(O=Y("MiddleLeft"),H,S=Y("MiddleRight")),Y(!1,"clear:left").append(Y("BottomLeft"),W=Y("BottomCenter"),Y("BottomRight"))).children().children().css({"float":"left"}),k=Y(!1,"position:absolute; width:9999px; visibility:hidden; display:none"),i("body").prepend(v,z.append(D,k)),H.children().hover(function(){i(this).addClass("hover")},function(){i(this).removeClass("hover")}).addClass("hover"),ab=L.height()+W.height()+H.outerHeight(!0)-H.height(),h=O.width()+S.width()+H.outerWidth(!0)-H.width(),l=c.outerHeight(!0),p=c.outerWidth(!0),z.css({"padding-bottom":ab,"padding-right":h}).hide(),G.click(function(){Q.next()}),K.click(function(){Q.prev()}),P.click(function(){Q.close()}),T=G.add(K).add(y).add(C),H.children().removeClass("hover"),i("."+U).live("click",function(ad){ad.button!==0&&typeof ad.button!="undefined"||ad.ctrlKey||ad.shiftKey||ad.altKey||(ad.preventDefault(),q(this))}),v.click(function(){X.overlayClose&&Q.close()}),i(m).bind("keydown."+E,function(ad){var ae=ad.keyCode;F&&X.escKey&&ae===27&&(ad.preventDefault(),Q.close()),F&&X.arrowKey&&aa[1]&&(ae===37?(ad.preventDefault(),K.click()):ae===39&&(ad.preventDefault(),G.click()))})},Q.remove=function(){z.add(v).remove(),i("."+U).die("click").removeData(A).removeClass(U)},Q.position=function(ad,ae){function ai(aj){L[0].style.width=W[0].style.width=H[0].style.width=aj.style.width,o[0].style.height=o[1].style.height=H[0].style.height=O[0].style.height=S[0].style.height=aj.style.height}var af,ag=Math.max(m.documentElement.clientHeight-X.h-l-ab,0)/2+a.scrollTop(),ah=Math.max(a.width()-X.w-p-h,0)/2+a.scrollLeft();af=z.width()===X.w+p&&z.height()===X.h+l?0:ad,D[0].style.width=D[0].style.height="9999px",z.dequeue().animate({width:X.w+p,height:X.h+l,top:ag,left:ah},{duration:af,complete:function(){ai(this),J=!1,D[0].style.width=X.w+p+h+"px",D[0].style.height=X.h+l+ab+"px",ae&&ae()},step:function(){ai(this)}})},Q.resize=function(ad){if(F){ad=ad||{},ad.width&&(X.w=ac(ad.width,"x")-p-h),ad.innerWidth&&(X.w=ac(ad.innerWidth,"x")),c.css({width:X.w}),ad.height&&(X.h=ac(ad.height,"y")-l-ab),ad.innerHeight&&(X.h=ac(ad.innerHeight,"y"));if(!ad.innerHeight&&!ad.height){var ae=c.wrapInner("<div style='overflow:auto'></div>").children();X.h=ae.height(),ae.replaceWith(ae.children())}c.css({height:X.h}),Q.position(X.transition==="none"?0:X.speed)}},Q.prep=function(ad){function ah(ai){Q.position(ai,function(){var aj,ak,al,am,an=aa.length,ao,ap;!F||(ap=function(){o.hide(),e(R,X.onComplete)},j&&B&&c.fadeIn(100),u.html(X.title).add(c).show(),an>1?(typeof X.current=="string"&&y.html(X.current.replace(/\{current\}/,x+1).replace(/\{total\}/,an)).show(),G[X.loop||x<an-1?"show":"hide"]().html(X.next),K[X.loop||x?"show":"hide"]().html(X.previous),aj=x?aa[x-1]:aa[an-1],al=x<an-1?aa[x+1]:aa[0],X.slideshow&&C.show(),X.preloading&&(am=i.data(al,A).href||al.href,ak=i.data(aj,A).href||aj.href,am=i.isFunction(am)?am.call(al):am,ak=i.isFunction(ak)?ak.call(aj):ak,b(am)&&(i("<img/>")[0].src=am),b(ak)&&(i("<img/>")[0].src=ak))):T.hide(),X.iframe?(ao=i("<iframe/>").addClass(E+"Iframe")[0],X.fastIframe?ap():i(ao).load(ap),ao.name=E+ +(new Date),ao.src=X.href,X.scrolling||(ao.scrolling="no"),j&&(ao.frameBorder=0,ao.allowTransparency="true"),i(ao).appendTo(c).one(f,function(){ao.src="//about:blank"})):ap(),X.transition==="fade"?z.fadeTo(ae,1,function(){z[0].style.filter=""}):z[0].style.filter="",a.bind("resize."+E,function(){Q.position(0)}))})}function ag(){X.h=X.h||c.height(),X.h=X.mh&&X.mh<X.h?X.mh:X.h;return X.h}function af(){X.w=X.w||c.width(),X.w=X.mw&&X.mw<X.w?X.mw:X.w;return X.w}if(!!F){var ae=X.transition==="none"?0:X.speed;a.unbind("resize."+E),c.remove(),c=Y("LoadedContent").html(ad),c.hide().appendTo(k.show()).css({width:af(),overflow:X.scrolling?"auto":"hidden"}).css({height:ag()}).prependTo(H),k.hide(),i(B).css({"float":"none"}),n&&i("select").not(z.find("select")).filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(V,function(){this.style.visibility="inherit"}),X.transition==="fade"?z.fadeTo(ae,0,function(){ah(0)}):ah(ae)}},Q.load=function(ad){var ae,af,ag=Q.prep;J=!0,B=!1,t=aa[x],ad||d(i.extend(X,i.data(t,A))),e(f),e(M,X.onLoad),X.h=X.height?ac(X.height,"y")-l-ab:X.innerHeight&&ac(X.innerHeight,"y"),X.w=X.width?ac(X.width,"x")-p-h:X.innerWidth&&ac(X.innerWidth,"x"),X.mw=X.w,X.mh=X.h,X.maxWidth&&(X.mw=ac(X.maxWidth,"x")-p-h,X.mw=X.w&&X.w<X.mw?X.w:X.mw),X.maxHeight&&(X.mh=ac(X.maxHeight,"y")-l-ab,X.mh=X.h&&X.h<X.mh?X.h:X.mh),ae=X.href,o.show(),X.inline?(Y().hide().insertBefore(i(ae)[0]).one(f,function(){i(this).replaceWith(c.children())}),ag(i(ae))):X.iframe?ag(" "):X.html?ag(X.html):b(ae)?(i(B=new Image).addClass(E+"Photo").error(function(){X.title=!1,ag(Y("Error").text("This image could not be loaded"))}).load(function(){var ah;B.onload=null,X.scalePhotos&&(af=function(){B.height-=B.height*ah,B.width-=B.width*ah},X.mw&&B.width>X.mw&&(ah=(B.width-X.mw)/B.width,af()),X.mh&&B.height>X.mh&&(ah=(B.height-X.mh)/B.height,af())),X.h&&(B.style.marginTop=Math.max(X.h-B.height,0)/2+"px"),aa[1]&&(x<aa.length-1||X.loop)&&(B.style.cursor="pointer",B.onclick=function(){Q.next()}),j&&(B.style.msInterpolationMode="bicubic"),setTimeout(function(){ag(B)},1)}),setTimeout(function(){B.src=ae},1)):ae&&k.load(ae,function(ah,ai,aj){ag(ai==="error"?Y("Error").text("Request unsuccessful: "+aj.statusText):i(this).contents())})},Q.next=function(){!J&&aa[1]&&(x<aa.length-1||X.loop)&&(x=x<aa.length-1?x+1:0,Q.load())},Q.prev=function(){!J&&aa[1]&&(x||X.loop)&&(x=x?x-1:aa.length-1,Q.load())},Q.close=function(){F&&!N&&(N=!0,F=!1,e(V,X.onCleanup),a.unbind("."+E+" ."+r),v.fadeTo(200,0),z.stop().fadeTo(300,0,function(){z.add(v).css({opacity:1,cursor:"auto"}).hide(),e(f),c.remove(),setTimeout(function(){N=!1,e(Z,X.onClosed)},1)}))},Q.element=function(){return i(t)},Q.settings=w,i(Q.init)})(jQuery,document,this);
