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