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