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