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