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