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