(function(b){var s="colorbox",D="hover",i=true,d=false,c,x=b.browser.msie&&!b.support.opacity,P=x&&b.browser.version<7,U="cbox_open",C="cbox_load",F="cbox_complete",H="cbox_cleanup",Q="cbox_closed",n,h,v,m,J,I,G,E,g,k,j,B,y,O,K,r,z,A,N,t,u,p,q,f,L,e,a,o,w,R={transition:"elastic",speed:350,width:d,height:d,innerWidth:d,innerHeight:d,initialWidth:"400",initialHeight:"400",maxWidth:d,maxHeight:d,scalePhotos:i,scrolling:i,inline:d,html:d,iframe:d,photo:d,href:d,title:d,rel:d,opacity:.9,preloading:i,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:d,overlayClose:i,loop:i,slideshow:d,slideshowAuto:i,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:d,onLoad:d,onComplete:d,onCleanup:d,onClosed:d,escKey:i,arrowKey:i};function l(a,b){b=b==="x"?k.width():k.height();return typeof a==="string"?Math.round(a.match(/%/)?b/100*parseInt(a,10):parseInt(a,10)):a}function M(c){c=b.isFunction(c)?c.call(f):c;return a.photo||c.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function S(){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!=="on")a[c]=a[c].call(f);a.rel=a.rel||f.rel||"nofollow";a.href=a.href||b(f).attr("href");a.title=a.title||f.title}function T(d){f=d;a=b.extend({},b(f).data(s));S();if(a.rel!=="nofollow"){g=b(".cboxElement").filter(function(){var c=b(this).data(s).rel||this.rel;return c===a.rel});e=g.index(f);if(e<0){g=g.add(f);e=g.length-1}}else{g=b(f);e=0}if(!o){o=i;w=i;L=f;try{L.blur()}catch(h){}b.event.trigger(U);a.onOpen&&a.onOpen.call(f);n.css({opacity:parseFloat(a.opacity),cursor:a.overlayClose?"pointer":"auto"}).show();a.w=l(a.initialWidth,"x");a.h=l(a.initialHeight,"y");c.position(0);P&&k.bind("resize.cboxIE6 scroll.cboxIE6",function(){n.css({width:k.width(),height:k.height(),top:k.scrollTop(),left:k.scrollLeft()})}).trigger("scroll.cboxIE6")}K.add(A).add(z).add(r).add(O).hide();N.html(a.close).show();c.slideshow();c.load()}c=b.fn.colorbox=b.colorbox=function(c,d){var a=this;if(a.selector&&!a.length)return a;c=c||{};if(d)c.onComplete=d;if(!a.length||a.selector===undefined){a=b("<a/>");c.open=i}a.each(function(){b(this).data(s,b.extend({},b(this).data(s)||R,c)).addClass("cboxElement")});c.open&&T(a[0]);return a};c.init=function(){function f(a){return b('<div id="cbox'+a+'"/>')}k=b(window);h=b('<div id="colorbox"/>');n=f("Overlay").hide();v=f("Wrapper");m=f("Content").append(j=f("LoadedContent").css({width:0,height:0}),y=f("LoadingOverlay").add(f("LoadingGraphic")),O=f("Title"),K=f("Current"),z=f("Next"),A=f("Previous"),r=f("Slideshow"),N=f("Close"));v.append(b("<div/>").append(f("TopLeft"),J=f("TopCenter"),f("TopRight")),b("<div/>").append(I=f("MiddleLeft"),m,G=f("MiddleRight")),b("<div/>").append(f("BottomLeft"),E=f("BottomCenter"),f("BottomRight"))).children().children().css({"float":"left"});B=b("<div id='cboxLoadingBay' style='position:absolute; width:9999px;'/>");b("body").prepend(n,h.append(v,B));if(x){h.addClass("cboxIE");P&&n.css("position","absolute")}m.children().hover(function(){b(this).addClass(D)},function(){b(this).removeClass(D)}).addClass(D);t=J.height()+E.height()+m.outerHeight(i)-m.height();u=I.width()+G.width()+m.outerWidth(i)-m.width();p=j.outerHeight(i);q=j.outerWidth(i);h.css({"padding-bottom":t,"padding-right":u}).hide();z.click(c.next);A.click(c.prev);N.click(c.close);m.children().removeClass(D);b(".cboxElement").live("click",function(a){if(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)return i;else{T(this);return d}});n.click(function(){a.overlayClose&&c.close()});b(document).bind("keydown",function(b){if(o&&a.escKey&&b.keyCode===27){b.preventDefault();c.close()}if(o&&a.arrowKey&&!w&&g.length>1)if(b.keyCode===37&&(e>0||a.loop)){b.preventDefault();A.click()}else if(b.keyCode===39&&(e<g.length-1||a.loop)){b.preventDefault();z.click()}})};c.remove=function(){h.add(n).remove();b(".cboxElement").removeData(s).removeClass("cboxElement")};c.position=function(i,c){var e,g=Math.max(k.height()-a.h-p-t,0)/2+k.scrollTop(),f=Math.max(k.width()-a.w-q-u,0)/2+k.scrollLeft();e=h.width()===a.w+q&&h.height()===a.h+p?0:i;v[0].style.width=v[0].style.height="9999px";function b(a){J[0].style.width=E[0].style.width=m[0].style.width=a.style.width;y[0].style.height=y[1].style.height=m[0].style.height=I[0].style.height=G[0].style.height=a.style.height}h.dequeue().animate({width:a.w+q,height:a.h+p,top:g,left:f},{duration:e,complete:function(){b(this);w=d;v[0].style.width=a.w+q+u+"px";v[0].style.height=a.h+p+t+"px";c&&c()},step:function(){b(this)}})};c.resize=function(b){if(o){b=b||{};if(b.width)a.w=l(b.width,"x")-q-u;if(b.innerWidth)a.w=l(b.innerWidth,"x");j.css({width:a.w});if(b.height)a.h=l(b.height,"y")-p-t;if(b.innerHeight)a.h=l(b.innerHeight,"y");if(!b.innerHeight&&!b.height){var d=j.wrapInner("<div style='overflow:auto'></div>").children();a.h=d.height();d.replaceWith(d.children())}j.css({height:a.h});c.position(a.transition==="none"?0:a.speed)}};c.prep=function(p){if(!o)return;var q,d=a.transition==="none"?0:a.speed;k.unbind("resize.cbox");j.remove();j=b('<div id="cboxLoadedContent"/>').html(p);function n(){a.w=a.w||j.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}function l(){a.h=a.h||j.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}j.hide().appendTo(B).css({width:n(),overflow:a.scrolling?"auto":"hidden"}).css({height:l()}).prependTo(m);b("#cboxPhoto").css({cssFloat:"none"});if(P)b("select:not(#colorbox select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one(H,function(){this.style.visibility="inherit"});function i(u){var t,m,p,l,i=g.length,n=a.loop;c.position(u,function(){function u(){x&&h[0].style.removeAttribute("filter")}if(!o)return;if(x)q&&j.fadeIn(100);a.iframe&&b("<iframe frameborder=0"+(a.scrolling?"":" scrolling='no'")+(x?" allowtransparency='true'":"")+"/>").appendTo(j).attr({src:a.href,id:"cboxIframe",name:(new Date).getTime()});j.show();O.show().html(a.title);if(i>1){K.html(a.current.replace(/\{current\}/,e+1).replace(/\{total\}/,i)).show();z[n||e<i-1?"show":"hide"]().html(a.next);A[n||e>0?"show":"hide"]().html(a.previous);t=e>0?g[e-1]:g[i-1];p=e<i-1?g[e+1]:g[0];if(a.slideshow){r.show();e===i-1&&!n&&h.is(".cboxSlideshow_on")&&r.click()}if(a.preloading){l=b(p).data(s).href||p.href;m=b(t).data(s).href||t.href;if(M(l))b("<img/>")[0].src=l;if(M(m))b("<img/>")[0].src=m}}y.hide();if(a.transition==="fade")h.fadeTo(d,1,function(){u()});else u();k.bind("resize.cbox",function(){c.position(0)});b.event.trigger(F);a.onComplete&&a.onComplete.call(f)})}if(a.transition==="fade")h.fadeTo(d,0,function(){i(0)});else i(d)};c.load=function(){var k,h,n,m=c.prep;w=i;f=g[e];a=b.extend({},b(f).data(s));S();b.event.trigger(C);a.onLoad&&a.onLoad.call(f);a.h=a.height?l(a.height,"y")-p-t:a.innerHeight?l(a.innerHeight,"y"):d;a.w=a.width?l(a.width,"x")-q-u:a.innerWidth?l(a.innerWidth,"x"):d;a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=l(a.maxWidth,"x")-q-u;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=l(a.maxHeight,"y")-p-t;a.mh=a.h&&a.h<a.mh?a.h:a.mh}k=a.href;y.show();if(a.inline){b('<div id="cboxInlineTemp"/>').hide().insertBefore(b(k)[0]).bind(C+" "+H,function(){b(this).replaceWith(j.children())});m(b(k))}else if(a.iframe)m(" ");else if(a.html)m(a.html);else if(M(k)){h=new Image;h.onload=function(){var d;h.onload=null;h.id="cboxPhoto";b(h).css({margin:"auto",border:"none",display:"block",cssFloat:"left"});if(a.scalePhotos){n=function(){h.height-=h.height*d;h.width-=h.width*d};if(a.mw&&h.width>a.mw){d=(h.width-a.mw)/h.width;n()}if(a.mh&&h.height>a.mh){d=(h.height-a.mh)/h.height;n()}}if(a.h)h.style.marginTop=Math.max(a.h-h.height,0)/2+"px";m(h);g.length>1&&b(h).css({cursor:"pointer"}).click(c.next);if(x)h.style.msInterpolationMode="bicubic"};h.src=k}else b("<div>Request unsuccessful.</div>").appendTo(B).load(k,function(){m(this)})};c.next=function(){if(!w){e=e<g.length-1?e+1:0;c.load()}};c.prev=function(){if(!w){e=e>0?e-1:g.length-1;c.load()}};c.slideshow=function(){var e,d,b="cboxSlideshow_";r.bind(Q,function(){r.unbind();clearTimeout(d);h.removeClass(b+"off "+b+"on")});function f(){r.text(a.slideshowStop).bind(F,function(){d=setTimeout(c.next,a.slideshowSpeed)}).bind(C,function(){clearTimeout(d)}).one("click",function(){e()});h.removeClass(b+"off").addClass(b+"on")}e=function(){clearTimeout(d);r.text(a.slideshowStart).unbind(F+" "+C).one("click",function(){f();d=setTimeout(c.next,a.slideshowSpeed)});h.removeClass(b+"on").addClass(b+"off")};if(a.slideshow&&g.length>1)if(a.slideshowAuto)f();else e()};c.close=function(){if(o){o=d;b.event.trigger(H);a.onCleanup&&a.onCleanup.call(f);k.unbind(".cbox .cboxIE6");h.add(n).stop().fadeTo("fast",0,function(){b("#colorbox iframe").attr("src","about:blank");j.remove();h.add(n).css({opacity:1,cursor:"auto"}).hide();try{L.focus()}catch(c){}setTimeout(function(){b.event.trigger(Q);a.onClosed&&a.onClosed.call(f)},1)})}};c.element=function(){return b(f)};c.settings=R;b(c.init)})(jQuery);
