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