LightboxOptions=Object.extend({fileLoadingImage:"/info/wiki/lynxmotion/download/XWiki/Lightbox/loading.gif",fileBottomNavCloseImage:"/info/wiki/lynxmotion/download/XWiki/Lightbox/closelabel.gif",overlayOpacity:0.8,animate:true,resizeSpeed:7,borderSize:10,labelImage:"Image",labelOf:"of"},window.LightboxOptions||{});var Lightbox=Class.create();Lightbox.prototype={imageArray:[],activeImage:undefined,initialize:function(){this.updateImageList();this.keyboardAction=this.keyboardAction.bindAsEventListener(this);if(LightboxOptions.resizeSpeed>10){LightboxOptions.resizeSpeed=10}if(LightboxOptions.resizeSpeed<1){LightboxOptions.resizeSpeed=1}this.resizeDuration=LightboxOptions.animate?((11-LightboxOptions.resizeSpeed)*0.15):0;this.overlayDuration=LightboxOptions.animate?0.2:0;var b=(LightboxOptions.animate?250:1)+"px";var a=$$("body")[0];a.appendChild(Builder.node("div",{id:"overlay"}));a.appendChild(Builder.node("div",{id:"lightbox"},[Builder.node("div",{id:"outerImageContainer"},Builder.node("div",{id:"imageContainer"},[Builder.node("img",{id:"lightboxImage"}),Builder.node("div",{id:"hoverNav"},[Builder.node("a",{id:"prevLink",href:"#"}),Builder.node("a",{id:"nextLink",href:"#"})]),Builder.node("div",{id:"loading"},Builder.node("a",{id:"loadingLink",href:"#"},Builder.node("img",{src:LightboxOptions.fileLoadingImage})))])),Builder.node("div",{id:"imageDataContainer"},Builder.node("div",{id:"imageData"},[Builder.node("div",{id:"imageDetails"},[Builder.node("span",{id:"caption"}),Builder.node("span",{id:"numberDisplay"})]),Builder.node("div",{id:"bottomNav"},Builder.node("a",{id:"bottomNavClose",href:"#"},Builder.node("img",{src:LightboxOptions.fileBottomNavCloseImage})))]))]));$("overlay").hide().observe("click",(function(){this.end()}).bind(this));$("lightbox").hide().observe("click",(function(d){if(d.element().id=="lightbox"){this.end()}}).bind(this));$("outerImageContainer").setStyle({width:b,height:b});$("prevLink").observe("click",(function(d){d.stop();this.changeImage(this.activeImage-1)}).bindAsEventListener(this));$("nextLink").observe("click",(function(d){d.stop();this.changeImage(this.activeImage+1)}).bindAsEventListener(this));$("loadingLink").observe("click",(function(d){d.stop();this.end()}).bind(this));$("bottomNavClose").observe("click",(function(d){d.stop();this.end()}).bind(this));var c=this;(function(){var d="overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose";$w(d).each(function(e){c[e]=$(e)})}).defer()},updateImageList:function(){this.updateImageList=Prototype.emptyFunction;document.observe("click",(function(a){var b=a.findElement("a[rel^=lightbox]")||a.findElement("area[rel^=lightbox]");if(b){a.stop();this.start(b)}}).bind(this))},start:function(g){$$("select","object","embed").each(function(h){h.style.visibility="hidden"});var c=this.getPageSize();$("overlay").setStyle({width:c[0]+"px",height:c[1]+"px"});var d=new Effect.Appear(this.overlay,{duration:this.overlayDuration,from:0,to:LightboxOptions.overlayOpacity});this.imageArray=[];var b=0;if((g.rel=="lightbox")){this.imageArray.push([g.href,g.title])}else{this.imageArray=$$(g.tagName+'[href][rel="'+g.rel+'"]').collect(function(h){return[h.href,h.title]}).uniq();while(this.imageArray[b][0]!=g.href){b++}}var a=document.viewport.getScrollOffsets();var f=a[1]+(document.viewport.getHeight()/10);var e=a[0];this.lightbox.setStyle({top:f+"px",left:e+"px"}).show();this.changeImage(b)},changeImage:function(b){this.activeImage=b;if(LightboxOptions.animate){this.loading.show()}this.lightboxImage.hide();this.hoverNav.hide();this.prevLink.hide();this.nextLink.hide();this.imageDataContainer.setStyle({opacity:0.0001});this.numberDisplay.hide();var a=new Image();a.onload=(function(){this.lightboxImage.src=this.imageArray[this.activeImage][0];this.resizeImageContainer(a.width,a.height)}).bind(this);a.src=this.imageArray[this.activeImage][0]},resizeImageContainer:function(f,g){var i=this.outerImageContainer.getWidth();var d=this.outerImageContainer.getHeight();var h=(f+LightboxOptions.borderSize*2);var k=(g+LightboxOptions.borderSize*2);var m=(h/i)*100;var c=(k/d)*100;var j=i-h;var a=d-k;if(a!=0){var b=new Effect.Scale(this.outerImageContainer,c,{scaleX:false,duration:this.resizeDuration,queue:"front"})}if(j!=0){var l=new Effect.Scale(this.outerImageContainer,m,{scaleY:false,duration:this.resizeDuration,delay:this.resizeDuration})}var e=0;if((a==0)&&(j==0)){e=100;if(Prototype.Browser.IE){e=250}}(function(){this.prevLink.setStyle({height:g+"px"});this.nextLink.setStyle({height:g+"px"});this.imageDataContainer.setStyle({width:h+"px"});this.showImage()}).bind(this).delay(e/1000)},showImage:function(){this.loading.hide();var a=new Effect.Appear(this.lightboxImage,{duration:this.resizeDuration,queue:"end",afterFinish:(function(){this.updateDetails()}).bind(this)});this.preloadNeighborImages()},updateDetails:function(){if(this.imageArray[this.activeImage][1]!=""){this.caption.update(this.imageArray[this.activeImage][1]).show()}if(this.imageArray.length>1){this.numberDisplay.update(LightboxOptions.labelImage+" "+(this.activeImage+1)+" "+LightboxOptions.labelOf+"  "+this.imageArray.length).show()}var a=new Effect.Parallel([new Effect.SlideDown(this.imageDataContainer,{sync:true,duration:this.resizeDuration,from:0,to:1}),new Effect.Appear(this.imageDataContainer,{sync:true,duration:this.resizeDuration})],{duration:this.resizeDuration,afterFinish:(function(){var b=this.getPageSize();this.overlay.setStyle({height:b[1]+"px"});this.updateNav()}).bind(this)})},updateNav:function(){this.hoverNav.show();if(this.activeImage>0){this.prevLink.show()}if(this.activeImage<(this.imageArray.length-1)){this.nextLink.show()}this.enableKeyboardNav()},enableKeyboardNav:function(){document.observe("keydown",this.keyboardAction)},disableKeyboardNav:function(){document.stopObserving("keydown",this.keyboardAction)},keyboardAction:function(d){var a=d.keyCode;var b;if(d.DOM_VK_ESCAPE){b=d.DOM_VK_ESCAPE}else{b=27}var c=String.fromCharCode(a).toLowerCase();if(c.match(/x|o|c/)||(a==b)){this.end()}else{if((c=="p")||(a==37)){if(this.activeImage!=0){this.disableKeyboardNav();this.changeImage(this.activeImage-1)}}else{if((c=="n")||(a==39)){if(this.activeImage!=(this.imageArray.length-1)){this.disableKeyboardNav();this.changeImage(this.activeImage+1)}}}}},preloadNeighborImages:function(){var a,b;if(this.imageArray.length>this.activeImage+1){a=new Image();a.src=this.imageArray[this.activeImage+1][0]}if(this.activeImage>0){b=new Image();b.src=this.imageArray[this.activeImage-1][0]}},end:function(){this.disableKeyboardNav();this.lightbox.hide();var a=new Effect.Fade(this.overlay,{duration:this.overlayDuration});$$("select","object","embed").each(function(b){b.style.visibility="visible"})},getPageSize:function(){var e,a,d,b,c,f;if(window.innerHeight&&window.scrollMaxY){e=window.innerWidth+window.scrollMaxX;a=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){e=document.body.scrollWidth;a=document.body.scrollHeight}else{e=document.body.offsetWidth;a=document.body.offsetHeight}}if(self.innerHeight){if(document.documentElement.clientWidth){c=document.documentElement.clientWidth}else{c=self.innerWidth}f=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){c=document.documentElement.clientWidth;f=document.documentElement.clientHeight}else{if(document.body){c=document.body.clientWidth;f=document.body.clientHeight}}}if(a<f){d=f}else{d=a}if(e<c){b=e}else{b=c}return[b,d]}};document.observe("dom:loaded",function(){var a=new Lightbox()});