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