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