(function(a){function R(c){if(c.keyCode===37){c.preventDefault();E.click()}else if(c.keyCode===39){c.preventDefault();F.click()}}function B(c,d){d=d==="x"?document.documentElement.clientWidth:document.documentElement.clientHeight;return typeof c==="string"?c.match(/%/)?d/100*parseInt(c,10):parseInt(c,10):c}function S(c){return b.photo?true:c.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function ba(){for(var c in b)if(typeof b[c]==="function")b[c]=b[c].call(m)}var t,h,x,o,T,U,V,W,f, s,p,M,N,ca,X,y,F,E,G,u,z,A,O,P,q,r,m,n,b,H,Y,C="hover",Z,D,I,J,K,v,da,Q,L="cbox_load",$="cbox_complete",aa={transition:"elastic",speed:350,width:false,height:false,initialWidth:"400",initialHeight:"400",initialPosTop:0,initialPosLeft:0,maxWidth:false,maxHeight:false,resize:true,inline:false,html:false,iframe:false,photo:false,href:false,title:false,rel:false,opacity:0.9,preloading:true,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:false,overlayClose:true, slideshow:false,slideshowAuto:true,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",mode:"original"};a.fn.colorbox=function(c,d){this.length?this.each(function(){var e=a(this).data("colorbox")?a.extend({},a(this).data("colorbox"),c):a.extend({},aa,c);if(e.mode=="original"){a("#colorbox").length==0&&I(e);a(this).data("colorbox",e).addClass("cboxelement")}else if(e.mode=="player"){a("#colorbox_player").length==0&&I(e);a(this).data("colorbox",e).addClass("mboxelement")}}): a(this).data("colorbox",a.extend({},aa,c));a(this).unbind("click.colorbox").bind("click.colorbox",function(e){m=this;b=a(m).data("colorbox");ba();var i=h;if(b.mode=="original"){h=a("#colorbox");t=a("#cboxOverlay")}else if(b.mode=="player"){h=a("#colorbox_player");t=a("#mboxOverlay")}if(i.attr("id")!=h.attr("id")){h.remove();t.remove();I(b)}a().bind("keydown.cbox_close",function(j){if(j.keyCode===27){j.preventDefault();G.click()}});b.overlayClose===true&&t.css({cursor:"pointer"}).one("click",Q);m.blur(); Y=d||false;var k=b.rel||m.rel;if(k&&k!=="nofollow"){if(b.mode=="original")f=a(".cboxelement").filter(function(){return(a(this).data("colorbox").rel||this.rel)===k});else if(b.mode=="player")f=a(".mboxelement").filter(function(){return(a(this).data("colorbox").rel||this.rel)===k});n=f.index(m);if(n<0){f=f.add(m);n=f.length-1}}else{f=a(m);n=0}if(!H){a.event.trigger("cbox_open");G.html(b.close);t.css({opacity:b.opacity}).show();H=true;K(B(b.initialWidth,"x"),B(b.initialHeight,"y"),0);a.browser.msie&& a.browser.version<7&&s.bind("resize.cboxie6 scroll.cboxie6",function(){t.css({width:s.width(),height:s.height(),top:s.scrollTop(),left:s.scrollLeft()})}).trigger("scroll.cboxie6")}da();J();e.preventDefault()});c&&c.open&&a(this).triggerHandler("click.colorbox");return this};I=function(c){function d(e){if(c.mode=="original")return a('<div id="cbox'+e+'"/>');else if(c.mode=="player")return a('<div id="mbox'+e+'"/>')}s=a(window);if(c.mode=="original")h=a('<div id="colorbox"/>');else if(c.mode=="player")h= a('<div id="colorbox_player"/>');t=d("Overlay").hide();x=d("Wrapper");o=d("Content").append(p=d("LoadedContent").css({width:0,height:0}),M=d("LoadingOverlay"),N=d("LoadingGraphic"),ca=d("Title"),X=d("Current"),y=d("Slideshow"),F=d("Next"),E=d("Previous"),G=d("Close"));x.append(a("<div/>").append(d("TopLeft"),T=d("TopCenter"),d("TopRight")),a("<div/>").append(U=d("MiddleLeft"),o,V=d("MiddleRight")),a("<div/>").append(d("BottomLeft"),W=d("BottomCenter"),d("BottomRight"))).children().children().css({"float":"left"}); a("body").prepend(t,h.append(x));a.browser.msie&&a.browser.version<7&&t.css("position","absolute");o.children().addClass(C).mouseover(function(){a(this).addClass(C)}).mouseout(function(){a(this).removeClass(C)}).hide();z=T.height()+W.height()+o.outerHeight(true)-o.height();A=U.width()+V.width()+o.outerWidth(true)-o.width();O=p.outerHeight(true);P=p.outerWidth(true);h.css({"padding-bottom":z,"padding-right":A}).hide();F.click(D);E.click(Z);G.click(Q);o.children().removeClass(C)};K=function(c,d,e,i){function k(w){T[0].style.width= W[0].style.width=o[0].style.width=w.style.width;N[0].style.height=M[0].style.height=o[0].style.height=U[0].style.height=V[0].style.height=w.style.height}var j=document.documentElement.clientHeight,g=j/2-d/2,l=document.documentElement.clientWidth/2-c/2;if(b.initialPosTop!=0){g=a(window).scrollTop();g=b.initialPosTop-g}if(b.initialPosLeft!=0){l=a(window).scrollLeft();l=b.initialPosLeft-l}if(d>j)g-=d-j;if(g<0)g=0;if(l<0)l=0;g+=s.scrollTop();l+=s.scrollLeft();c-=A;d-=z;e=h.width()===c&&h.height()===d? 0:e;x[0].style.width=x[0].style.height="9999px";h.dequeue().animate({height:d,width:c,top:g,left:l},{duration:e,complete:function(){k(this);x[0].style.width=c+A+"px";x[0].style.height=d+z+"px";i&&i()},step:function(){k(this)}})};v=function(c){function d(){return k=b.width?q:q&&q<p.width()?q:p.width()}function e(){return j=b.height?r:r&&r<p.height()?r:p.height()}function i(ga){var ea=k+P+A,fa=j+O+z;K(ea,fa,ga,function(){if(H){if(a.browser.msie){l&&p.fadeIn(100);h.css("filter","")}o.children().show(); if(b.mode=="original")a("#cboxIframeTemp").after("<iframe id='cboxIframe' name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+(b.href||m.href)+"' />").remove();else if(b.mode=="player")a("#mboxIframeTemp").after("<iframe id='mboxIframe' name='iframe_"+(new Date).getTime()+"' frameborder=0 src='"+(b.href||m.href)+"' />").remove();M.hide();N.hide();y.hide();if(f.length>1){X.html(b.current.replace(/\{current\}/,n+1).replace(/\{total\}/,f.length));F.html(b.next);E.html(b.previous);a().unbind("keydown", R).bind("keydown",R);b.slideshow&&y.show()}else{X.hide();F.hide();E.hide()}ca.html(b.title||m.title);a.event.trigger($);Y&&Y.call(m);b.transition==="fade"&&h.fadeTo(w,1,function(){a.browser.msie&&o.css("filter","")});s.bind("resize.cbox_resize",function(){K(ea,fa,0)})}})}if(H){s.unbind("resize.cbox_resize");var k,j,g,l,w=b.transition==="none"?0:b.speed;p.remove();p=a(c);if(b.mode=="original")p.hide().appendTo("body").attr({id:"cboxLoadedContent"}).css({width:d()}).css({height:e()}).prependTo(o);else b.mode== "player"&&p.hide().appendTo("body").attr({id:"mboxLoadedContent"}).css({width:d()}).css({height:e()}).prependTo(o);a.browser.msie&&a.browser.version<7&&a("select:not(#colorbox select)").filter(function(){return a(this).css("visibility")!=="hidden"}).css({visibility:"hidden"}).one("cbox_close",function(){a(this).css({visibility:"inherit"})});if(b.mode=="original")l=a("#cboxPhoto")[0];else if(b.mode=="player")l=a("#mboxPhoto")[0];if(l&&b.height){c=(j-parseInt(l.style.height,10))/2;l.style.marginTop= (c>0?c:0)+"px"}b.transition==="fade"?h.fadeTo(w,0,function(){i(0)}):i(w);if(b.preloading&&f.length>1){c=n>0?f[n-1]:f[f.length-1];g=n<f.length-1?f[n+1]:f[0];g=a(g).data("colorbox").href||g.href;c=a(c).data("colorbox").href||c.href;S(g)&&a("<img />").attr("src",g);S(c)&&a("<img />").attr("src",c)}}};J=function(){var c,d,e,i;m=f[n];b=a(m).data("colorbox");ba();a.event.trigger(L);c=b.height?B(b.height,"y")-O-z:false;d=b.width?B(b.width,"x")-P-A:false;e=b.href||m.href;M.show();N.show();G.show();if(b.maxHeight){r= b.maxHeight?B(b.maxHeight,"y")-O-z:false;c=c&&c<r?c:r}if(b.maxWidth){q=b.maxWidth?B(b.maxWidth,"x")-P-A:false;d=d&&d<q?d:q}r=c;q=d;if(b.inline){if(b.mode=="original")a('<div id="cboxInlineTemp" />').hide().insertBefore(a(e)[0]).bind(L+" cbox_close",function(){p.children().insertBefore(this);a(this).remove()});else b.mode=="player"&&a('<div id="mboxInlineTemp" />').hide().insertBefore(a(e)[0]).bind(L+" cbox_close",function(){p.children().insertBefore(this);a(this).remove()});v(a(e).wrapAll("<div/>").parent())}else if(b.iframe)if(b.mode== "original")v(a("<div><div id='cboxIframeTemp' /></div>"));else b.mode=="player"&&v(a("<div><div id='mboxIframeTemp' /></div>"));else if(b.html)v(a("<div/>").html(b.html));else if(S(e)){i=new Image;i.onload=function(){i.onload=null;if((r||q)&&b.resize){var k=this.width,j=this.height,g=0,l=this,w=function(){j+=j*g;k+=k*g;l.height=j;l.width=k};if(q&&k>q){g=(q-k)/k;w()}if(r&&j>r){g=(r-j)/j;w()}}if(b.mode=="original")v(a("<div />").css({width:this.width,height:this.height}).append(a(this).css({width:this.width, height:this.height,display:"block",margin:"auto",border:0}).attr("id","cboxPhoto")));else b.mode=="player"&&v(a("<div />").css({width:this.width,height:this.height}).append(a(this).css({width:this.width,height:this.height,display:"block",margin:"auto",border:0}).attr("id","mboxPhoto")));f.length>1&&a(this).css({cursor:"pointer"}).click(D);if(a.browser.msie&&a.browser.version==7)this.style.msInterpolationMode="bicubic"};i.src=e}else a("<div />").load(e,function(k,j){j==="success"?v(a(this)):v(a("<p>Request unsuccessful.</p>"))})}; D=function(){n=n<f.length-1?n+1:0;J()};Z=function(){n=n>0?n-1:f.length-1;J()};da=function(){function c(){y.text(b.slideshowStop).bind($,function(){e=setTimeout(D,b.slideshowSpeed)}).bind(L,function(){clearTimeout(e)}).one("click",function(){d();a(this).removeClass(C)});h.removeClass(i+"off").addClass(i+"on")}var d,e,i;if(b.mode=="original")i="cboxSlideshow_";else if(b.mode=="player")i="mboxSlideshow_";y.bind("cbox_close",function(){clearTimeout(e);y.unbind()});d=function(){clearTimeout(e);y.text(b.slideshowStart).unbind($+ " "+L).one("click",function(){c();e=setTimeout(D,b.slideshowSpeed);a(this).removeClass(C)});h.removeClass(i+"on").addClass(i+"off")};if(b.slideshow&&f.length>1)b.slideshowAuto?c():d()};Q=function(){a.event.trigger("cbox_close");H=false;a().unbind("keydown",R).unbind("keydown.cbox_close");s.unbind("resize.cbox_resize resize.cboxie6 scroll.cboxie6");t.css({cursor:"auto"}).fadeOut("fast");o.children().hide();h.stop(true,false).removeClass().fadeOut("fast",function(){p.remove();h.css({opacity:1});a.event.trigger("cbox_closed")})}; u=a.fn.colorbox;u.init=I;u.next=D;u.prev=Z;u.close=Q;u.load=J;u.position=K;u.dimensions=v;u.element=function(){return m};u.settings=aa})(jQuery);
