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