/*
 GNU Affero General Public License - {@link http://www.gnu.org/licenses/agpl.html}
 @example Visit {@link http://jquery.com/plugins/project/jquerylightbox_bal} for more information.
*/
(function(a){if(typeof a.log==="undefined"){if(!a.browser.safari&&typeof window.console!=="undefined"&&typeof window.console.log==="function"){a.log=function(){for(var b=[],c=0;c<arguments.length;c++)b.push(arguments[c]);window.console.log.apply(window.console,b)};a.console={log:a.log,debug:window.console.debug||a.log,warn:window.console.warn||a.log,error:window.console.error||a.log,trace:window.console.trace||a.log}}else{a.log=function(){};a.console={log:a.log,debug:a.log,warn:a.log,error:alert,
trace:a.log}}$log=a.log;$debug=a.console.debug;$warn=a.console.warn;$error=a.console.error;$trace=a.console.trace}a.params_to_json=a.params_to_json||function(b){b=String(b);b=b.substring(b.indexOf("?")+1);b=b.replace(/\+/g,"%20");if(b.substring(0,1)==="{"&&b.substring(b.length-1)==="}")return eval(decodeURIComponent(b));b=b.split(/\&|\&amp\;/);for(var c={},d=0,g=b.length;d<g;++d){var f=b[d]||null;if(f!==null){f=f.split("=");if(f!==null){var i=f[0]||null;if(i!==null)if(typeof f[1]!=="undefined"){var e=
f[1];i=decodeURIComponent(i);e=decodeURIComponent(e);try{e=eval(e)}catch(h){}f=i.split(".");if(f.length===1)c[i]=e;else{e="";for(ii in f){i=f[ii];e+="."+i;eval("json"+e+" = json"+e+" || {}")}eval("json"+e+" = value")}}}}}return c};Array.prototype.remove=function(b,c){var d=this.slice((c||b)+1||this.length);this.length=b<0?this.length+b:b;return this.push.apply(this,d)};Array.prototype.get=function(b,c){if(b==="first")b=0;else if(b==="last")b=this.length-1;else if(!b&&b!==0)b=this.index;c!==false&&
this.setIndex(b);return this[b]||undefined};Array.prototype.each=function(b){for(var c=0;c<this.length;++c)if(b(c,this[c],this)===false)break;return this};Array.prototype.setIndex=function(b){this.index=b<this.length&&b>=0?b:null;return this};Array.prototype.current=function(b){return this.get(b,true)};Array.prototype.isEmpty=function(){return this.length===0};Array.prototype.isSingle=function(){return this.length===1};Array.prototype.isMany=function(){return this.length!==0};Array.prototype.isLast=
function(b){b=typeof b==="undefined"?this.index:b;return!this.isEmpty()&&b===this.length-1};Array.prototype.isFirst=function(b){b=typeof b==="undefined"?this.index:b;return!this.isEmpty()&&b===0};Array.prototype.clear=function(){this.length=0};Array.prototype.next=function(b){return this.get(this.index+1,b)};Array.prototype.prev=function(b){return this.get(this.index-1,b)};Array.prototype.reset=function(){this.index=null;return this};Array.prototype.set=function(b,c){if(b<this.length&&b>=0)this[b]=
c;else{$error("index above array length");return false}return this};Array.prototype.loop=function(){if(!this.index&&this.index!==0)return this.current(0);return this.next()};Array.prototype.add=function(){this.push.apply(this,arguments);return this};Array.prototype.insert=function(b,c){if(typeof b!=="number")b=this.length;b=b<=this.length?b:this.length;var d=this.slice(b);this.length=b;this.push(c);this.push.apply(this,d);return this};a.LightboxClass=function(){this.construct()};a.fn.lightbox=function(b){a.Lightbox=
a.Lightbox||new a.LightboxClass;if(a.Lightbox.ie6&&!a.Lightbox.ie6_support)return this;b=a.extend({start:false,events:true},b);var c=a(this);if(b.events){c.unbind("click").click(function(){var d=a(this);d=c.index(d);if(!a.Lightbox.init(d,c))return false;if(!a.Lightbox.start())return false;return false});c.addClass("lightbox-enabled")}if(b.start){a(this);if(!a.Lightbox.init(0,c))return this;if(!a.Lightbox.start())return this}return this};a.extend(a.LightboxClass.prototype,{images:[],constructed:false,
compressed:null,src:null,baseurl:null,files:{compressed:{scripts:{lightbox:"scripts/jquery.lightbox.min.js",colorBlend:"scripts/jquery.color.min.js"},styles:{lightbox:"styles/jquery.lightbox.min.css"}},uncompressed:{scripts:{lightbox:"scripts/jquery.lightbox.js",colorBlend:"scripts/jquery.color.js"},styles:{lightbox:"styles/jquery.lightbox.css"}},images:{prev:"images/prev.gif",next:"images/next.gif",blank:"images/blank.gif",loading:"images/loading.gif"}},text:{image:"Image",of:"of",close:"Close X",
closeInfo:"You can also click anywhere outside the image to close.",download:"Download.",help:{close:"Click to close",interact:"Hover to interact"},about:{text:"jQuery Lightbox Plugin (balupton edition)",title:"Licenced under the GNU Affero General Public License.",link:"http://jquery.com/plugins/project/jquerylightbox_bal"}},keys:{close:"c",prev:"p",next:"n"},handlers:{show:null},opacity:0.9,padding:null,speed:400,rel:"lightbox",auto_relify:true,auto_scroll:"follow",auto_resize:true,ie6:null,ie6_support:true,
colorBlend:null,download_link:true,show_helper_text:true,show_linkback:true,show_info:"auto",show_extended_info:"auto",options:["show_helper_text","auto_scroll","auto_resize","download_link","show_info","show_extended_info","ie6_support","colorBlend","baseurl","files","text","show_linkback","keys","opacity","padding","speed","rel","auto_relify"],construct:function(b){var c=typeof this.constructed==="undefined"||this.constructed===false;this.constructed=true;var d=c;b=b||{};var g=function(e,h){if(typeof e===
"object")for(var j in e)e[j]=g(e[j],h);else if(typeof h==="array"){j=0;for(var k=e.length;j<k;++j)e[j]=g(e[j],h)}else e=h+e;return e};if(c&&typeof b.files==="undefined"){this.compressed=null;var f=a("script[src*="+this.files.compressed.scripts.lightbox+"]:first");if(f.length!==0){a.extend(true,this.files,this.files.compressed);this.compressed=true}else{f=a("script[src*="+this.files.uncompressed.scripts.lightbox+"]:first");if(f.length!==0){a.extend(true,this.files,this.files.uncompressed);this.compressed=
false}}if(this.compressed===null){a.console.error("Lightbox was not able to find it's javascript script tag necessary for auto-inclusion.");d=false}else{this.src=f.attr("src");this.baseurl=this.src.substring(0,this.src.indexOf(this.files.scripts.lightbox));this.files=g(this.files,this.baseurl);b=a.extend(b,a.params_to_json(this.src))}this.images.image={src:"",title:"Untitled",description:"",name:"",color:null,width:null,height:null,id:null,image:true};this.images.prepare=function(e){var h=a.extend({},
this.image);if(e.tagName){e=a(e);if(e.attr("src")||e.attr("href")){h.src=e.attr("src")||e.attr("href");h.title=e.attr("title")||e.attr("alt")||h.title;h.name=e.attr("name")||"";h.color=e.css("backgroundColor");e=h.title.indexOf(": ");if(e>0){h.description=h.title.substring(e+2)||h.description;h.title=h.title.substring(0,e)||h.title}}else h=null}else h=e.src?a.extend(this.image,e):null;if(h)h.id=h.id||h.src+h.title+h.description;return h};this.images.create=function(e){var h=this;if(e.each)e.each(function(k,
l){h.create(l)});else{var j=h.prepare(e);j?h.push(j):a.console.error("We dont know what we have:",e,j);return h}}}else if(typeof b.files==="object")b.files=g(b.files,this.baseurl);else d=false;for(var i in this.options){f=this.options[i];if(typeof b[f]==="object"&&typeof this[f]==="object")this[f]=a.extend(true,this[f],b[f]);else if(typeof b[f]!=="undefined")this[f]=b[f]}delete i;this.ie6=c&&navigator.userAgent.indexOf("MSIE 6")>=0?true:false;if(d||typeof b.download_link!=="undefined"||typeof b.colorBlend!==
"undefined"||typeof b.files==="object"||typeof b.text==="object"||typeof b.show_linkback!=="undefined"||typeof b.scroll_with!=="undefined")a(function(){a.Lightbox.domReady()});return true},domReady:function(){var b=document.getElementsByTagName(a.browser.safari?"head":"body")[0],c=this.files.styles,d=this.files.scripts;if(this.colorBlend===true&&typeof a.colorBlend==="undefined")this.colorBlend=true;else{this.colorBlend=typeof a.colorBlend!=="undefined";delete d.colorBlend}for(stylesheet in c){var g=
document.createElement("link");g.type="text/css";g.rel="stylesheet";g.media="screen";g.href=c[stylesheet];g.id="lightbox-stylesheet-"+stylesheet.replace(/[^a-zA-Z0-9]/g,"");a("#"+g.id).remove();b.appendChild(g)}for(script in d){g=document.createElement("script");g.type="text/javascript";g.src=d[script];g.id="lightbox-script-"+script.replace(/[^a-zA-Z0-9]/g,"");a("#"+g.id).remove();b.appendChild(g)}delete d;delete c;delete b;a("#lightbox,#lightbox-overlay").remove();a("body").append('<div id="lightbox-overlay"><div id="lightbox-overlay-text">'+
(this.show_linkback?'<p><span id="lightbox-overlay-text-about"><a href="#" title="'+this.text.about.title+'">'+this.text.about.text+"</a></span></p><p>&nbsp;</p>":"")+(this.show_helper_text?'<p><span id="lightbox-overlay-text-close">'+this.text.help.close+'</span><br/>&nbsp;<span id="lightbox-overlay-text-interact">'+this.text.help.interact+"</span></p>":"")+'</div></div><div id="lightbox"><div id="lightbox-imageBox"><div id="lightbox-imageContainer"><img id="lightbox-image" /><div id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="'+
this.files.images.loading+'" /></a></div></div></div><div id="lightbox-infoBox"><div id="lightbox-infoContainer"><div id="lightbox-infoHeader"><span id="lightbox-caption">'+(this.download_link?'<a href="#" title="'+this.text.download+'" id="lightbox-caption-title"></a>':'<span id="lightbox-caption-title"></span>')+'<span id="lightbox-caption-seperator"></span><span id="lightbox-caption-description"></span></span></div><div id="lightbox-infoFooter"><span id="lightbox-currentNumber"></span><span id="lightbox-close"><a href="#" id="lightbox-close-button" title="'+
this.text.closeInfo+'">'+this.text.close+'</a></span></div><div id="lightbox-infoContainer-clear"></div></div></div></div>');this.resizeBoxes();this.repositionBoxes();a("#lightbox,#lightbox-overlay,#lightbox-overlay-text-interact").hide();this.ie6&&this.ie6_support&&a("#lightbox-overlay").css({position:"absolute",top:"0px",left:"0px"});a.each(this.files.images,function(){var f=new Image;f.onload=function(){f=f.onload=null};f.src=this});a(window).unbind("resize").resize(function(){a.Lightbox.resizeBoxes("resized")});
this.scroll==="follow"&&a(window).scroll(function(){a.Lightbox.repositionBoxes()});a("#lightbox-nav-btnPrev").unbind().hover(function(){a(this).css({background:"url("+a.Lightbox.files.images.prev+") left 45% no-repeat"})},function(){a(this).css({background:"transparent url("+a.Lightbox.files.images.blank+") no-repeat"})}).click(function(){a.Lightbox.images.prev();a.Lightbox.showImage();return false});a("#lightbox-nav-btnNext").unbind().hover(function(){a(this).css({background:"url("+a.Lightbox.files.images.next+
") right 45% no-repeat"})},function(){a(this).css({background:"transparent url("+a.Lightbox.files.images.blank+") no-repeat"})}).click(function(){a.Lightbox.images.next();a.Lightbox.showImage();return false});this.show_linkback&&a("#lightbox-overlay-text-about a").click(function(){window.open(a.Lightbox.text.about.link);return false});a("#lightbox-overlay-text-close").unbind().hover(function(){a("#lightbox-overlay-text-interact").fadeIn()},function(){a("#lightbox-overlay-text-interact").fadeOut()});
this.download_link&&a("#lightbox-caption-title").click(function(){window.open(a(this).attr("href"));return false});a("#lightbox-overlay, #lightbox, #lightbox-loading-link, #lightbox-btnClose").unbind().click(function(){a.Lightbox.finish();return false});this.auto_relify&&this.relify();return true},relify:function(){var b={},c=0,d=this.rel;a.each(a("[rel*="+d+"]"),function(g,f){var i=a(f).attr("rel");if(i===d)i=c;if(typeof b[i]==="undefined"){b[i]=[];c++}b[i].push(f)});a.each(b,function(g,f){a(f).lightbox()});
return true},init:function(b,c){if(typeof c==="undefined"){c=b;b=0}this.images.clear();this.images.create(c);if(this.images.isEmpty()){a.console.warn("WARNING","Lightbox started, but no images: ",b,c);return false}if(!this.images.current(b)){a.console.warn("WARNING","Could not find current image: ",b,this.images);return false}return true},start:function(){this.visible=true;this.scroll==="disable"&&a(document.body).css("overflow","hidden");a("embed, object, select").css("visibility","hidden");this.resizeBoxes("general");
this.repositionBoxes({speed:0});a("#lightbox-infoFooter").hide();a("#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-infoBox").hide();a("#lightbox-overlay").css("opacity",this.opacity).fadeIn(400,function(){a("#lightbox").fadeIn(300);if(!a.Lightbox.showImage()){a.Lightbox.finish();return false}});return true},finish:function(){a("#lightbox").hide();a("#lightbox-overlay").fadeOut(function(){a("#lightbox-overlay").hide()});a("embed, object, select").css({visibility:"visible"});
this.images.reset();this.scroll==="disable"&&a(document.body).css("overflow","visible");this.visible=false},resizeBoxes:function(b){if(b!=="transition"){var c=a(this.ie6?document.body:document);a("#lightbox-overlay").css({width:c.width(),height:c.height()});delete c}switch(b){case "general":return true;case "resized":if(this.auto_resize===false){this.repositionBoxes({nHeight:e,speed:this.speed});return true}case "transition":default:break}var d=this.images.current();if(!d||!d.width||!this.visible)return false;
c=d.width;d=d.height;e=a(window).width();var g=a(window).height();if(this.auto_resize!==false){e=Math.floor(e*0.8);g=Math.floor(g*0.8);for(var f;c>e||d>g;){if(c>e){f=e/c;c=e;d=Math.floor(d*f)}if(d>g){f=g/d;d=g;c=Math.floor(c*f)}}}var i=a("#lightbox-imageBox").width();f=a("#lightbox-imageBox").height();g=c+this.padding*2;var e=d+this.padding*2;i=i-g;f=f-e;a("#lightbox-nav-btnPrev,#lightbox-nav-btnNext").css("height",e);a("#lightbox-infoBox").css("width",g);if(b==="transition")if(i===0&&f===0){this.pause(this.speed/
3);this.showImage(null,3)}else{a("#lightbox-image").width(c).height(d);a("#lightbox-imageBox").animate({width:g,height:e},this.speed,function(){a.Lightbox.showImage(null,3)})}else{a("#lightbox-image").animate({width:c,height:d},this.speed);a("#lightbox-imageBox").animate({width:g,height:e},this.speed)}this.repositionBoxes({nHeight:e,speed:this.speed});return true},repositioning:false,reposition_failsafe:false,repositionBoxes:function(b){if(this.repositioning){this.reposition_failsafe=true;return null}this.repositioning=
true;b=a.extend({},b);b.callback=b.callback||null;b.speed=b.speed||"slow";var c=this.getPageScroll(),d=b.nHeight||parseInt(a("#lightbox").height(),10);d=c.yScroll+(a(window).height()-d)/2.5;c={left:c.xScroll,top:d};if(b.speed)a("#lightbox").animate(c,"slow",function(){if(a.Lightbox.reposition_failsafe){a.Lightbox.repositioning=a.Lightbox.reposition_failsafe=false;a.Lightbox.repositionBoxes(b)}else{a.Lightbox.repositioning=false;b.callback&&b.callback()}});else{a("#lightbox").css(c);if(this.reposition_failsafe){this.repositioning=
this.reposition_failsafe=false;this.repositionBoxes(b)}else this.repositioning=false}return true},visible:false,showImage:function(b,c){c=c||1;if(b=this.images.current(b)||this.images.get("first",true)){switch(c){case 1:this.KeyboardNav_Disable();a("#lightbox-loading").show();a("#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-infoBox").hide();a("#lightbox-imageBox").unbind();if(b.width&&b.height)this.showImage(null,2);else{var d=new Image;d.onload=function(){b.width=
d.width;b.height=d.height;a.Lightbox.showImage(null,2);d=d.onload=null};d.src=b.src}break;case 2:a("#lightbox-image").attr("src",b.src);if(typeof this.padding==="undefined"||this.padding===null||isNaN(this.padding))this.padding=parseInt(a("#lightbox-imageContainer").css("padding-left"),10)||parseInt(a("#lightbox-imageContainer").css("padding"),10)||0;if(this.colorBlend){a("#lightbox-overlay").animate({backgroundColor:b.color},this.speed*2);a("#lightbox-imageBox").css("borderColor",b.color)}this.resizeBoxes("transition");
break;case 3:a("#lightbox-loading").hide();a("#lightbox-image").fadeIn(this.speed*1.5,function(){a.Lightbox.showImage(null,4)});this.preloadNeighbours();this.handlers.show!==null&&this.handlers.show(b);break;case 4:var g=a("#lightbox-caption-title").html(b.title||"Untitled");if(this.download_link)g.attr("href",this.download_link?b.src:"");delete g;a("#lightbox-caption-seperator").html(b.description?": ":"");a("#lightbox-caption-description").html(b.description||"&nbsp;");this.images.length>1?a("#lightbox-currentNumber").html(this.text.image+
"&nbsp;"+(this.images.index+1)+"&nbsp;"+this.text.of+"&nbsp;"+this.images.length):a("#lightbox-currentNumber").html("&nbsp;");a("#lightbox-imageBox").unbind("mouseover").mouseover(function(){a("#lightbox-infoBox:not(:visible)").stop().slideDown("fast")});a("#lightbox-infoBox").unbind("mouseover").mouseover(function(){a("#lightbox-infoFooter:not(:visible)").stop().slideDown("fast")});if(this.show_extended_info===true){a("#lightbox-imageBox").trigger("mouseover");a("#lightbox-infoBox").trigger("mouseover")}else this.show_info===
true&&a("#lightbox-imageBox").trigger("mouseover");a("#lightbox-nav-btnPrev, #lightbox-nav-btnNext").css({background:"transparent url("+this.files.images.blank+") no-repeat"});this.images.isFirst()||a("#lightbox-nav-btnPrev").show();this.images.isLast()||a("#lightbox-nav-btnNext").show();a("#lightbox-nav").show();this.KeyboardNav_Enable();break;default:a.console.error("Don't know what to do: ",b,c);return this.showImage(b,1)}return true}},preloadNeighbours:function(){if(this.images.isSingle()||this.images.isEmpty())return true;
var b=this.images.current(),c=this.images.index;if(!b)return b;var d=this.images.prev();if(d){b=new Image;b.src=d.src}this.images.setIndex(c);if(d=this.images.next()){b=new Image;b.src=d.src}this.images.setIndex(c)},KeyboardNav_Enable:function(){a(document).keydown(function(b){a.Lightbox.KeyboardNav_Action(b)})},KeyboardNav_Disable:function(){a(document).unbind("keydown")},KeyboardNav_Action:function(b){b=b||window.event;var c=b.keyCode;b=b.DOM_VK_ESCAPE||27;var d=String.fromCharCode(c).toLowerCase();
if(d===this.keys.close||c===b)return a.Lightbox.finish();if(d===this.keys.prev||c===37)return a.Lightbox.showImage(a.Lightbox.images.prev());if(d===this.keys.next||c===39)return a.Lightbox.showImage(a.Lightbox.images.next());return true},getPageScroll:function(){var b,c;if(self.pageYOffset){c=self.pageYOffset;b=self.pageXOffset}else if(document.documentElement&&document.documentElement.scrollTop){c=document.documentElement.scrollTop;b=document.documentElement.scrollLeft}else if(document.body){c=document.body.scrollTop;
b=document.body.scrollLeft}return{xScroll:b,yScroll:c}},pause:function(b){var c=new Date,d=null;do d=new Date;while(d-c<b)}});if(typeof a.Lightbox==="undefined")a.Lightbox=new a.LightboxClass})(jQuery);

