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