LightboxOptions=Object.extend({fileLoadingImage:"/Scripts/lightbox2/images/loading.gif",fileBottomNavCloseImage:"/Scripts/lightbox2/images/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 _1=(LightboxOptions.animate?250:1)+"px";var _2=$$("body")[0];_2.appendChild(Builder.node("div",{id:"overlay"}));_2.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(_3){if(_3.element().id=="lightbox"){this.end();}}).bind(this));$("outerImageContainer").setStyle({width:_1,height:_1});$("prevLink").observe("click",(function(_4){_4.stop();this.changeImage(this.activeImage-1);}).bindAsEventListener(this));$("nextLink").observe("click",(function(_5){_5.stop();this.changeImage(this.activeImage+1);}).bindAsEventListener(this));$("loadingLink").observe("click",(function(_6){_6.stop();this.end();}).bind(this));$("bottomNavClose").observe("click",(function(_7){_7.stop();this.end();}).bind(this));var th=this;(function(){var _9="overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink "+"imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose";$w(_9).each(function(id){th[id]=$(id);});}).defer();},updateImageList:function(){this.updateImageList=Prototype.emptyFunction;document.observe("click",(function(_b){var _c=_b.findElement("a[rel^=lightbox]")||_b.findElement("area[rel^=lightbox]");if(_c){_b.stop();this.start(_c);}}).bind(this));},start:function(_d){$$("select","object","embed").each(function(_e){_e.style.visibility="hidden";});var _f=this.getPageSize();$("overlay").setStyle({width:_f[0]+"px",height:_f[1]+"px"});new Effect.Appear(this.overlay,{duration:this.overlayDuration,from:0,to:LightboxOptions.overlayOpacity});this.imageArray=[];var _10=0;if((_d.rel=="lightbox")){this.imageArray.push([_d.href,_d.title]);}else{this.imageArray=$$(_d.tagName+"[href][rel=\""+_d.rel+"\"]").collect(function(_11){return [_11.href,_11.title];}).uniq();while(this.imageArray[_10][0]!=_d.href){_10++;}}var _12=document.viewport.getScrollOffsets();var _13=_12[1]+(document.viewport.getHeight()/10);var _14=_12[0];this.lightbox.setStyle({top:_13+"px",left:_14+"px"}).show();this.changeImage(_10);},changeImage:function(_15){this.activeImage=_15;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 _16=new Image();_16.onload=(function(){this.lightboxImage.src=this.imageArray[this.activeImage][0];this.resizeImageContainer(_16.width,_16.height);}).bind(this);_16.src=this.imageArray[this.activeImage][0];},resizeImageContainer:function(_17,_18){var _19=this.outerImageContainer.getWidth();var _1a=this.outerImageContainer.getHeight();var _1b=(_17+LightboxOptions.borderSize*2);var _1c=(_18+LightboxOptions.borderSize*2);var _1d=(_1b/_19)*100;var _1e=(_1c/_1a)*100;var _1f=_19-_1b;var _20=_1a-_1c;if(_20!=0){new Effect.Scale(this.outerImageContainer,_1e,{scaleX:false,duration:this.resizeDuration,queue:"front"});}if(_1f!=0){new Effect.Scale(this.outerImageContainer,_1d,{scaleY:false,duration:this.resizeDuration,delay:this.resizeDuration});}var _21=0;if((_20==0)&&(_1f==0)){_21=100;if(Prototype.Browser.IE){_21=250;}}(function(){this.prevLink.setStyle({height:_18+"px"});this.nextLink.setStyle({height:_18+"px"});this.imageDataContainer.setStyle({width:_1b+"px"});this.showImage();}).bind(this).delay(_21/1000);},showImage:function(){this.loading.hide();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();}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 _22=this.getPageSize();this.overlay.setStyle({height:_22[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(_23){var _24=_23.keyCode;var _25;if(_23.DOM_VK_ESCAPE){_25=_23.DOM_VK_ESCAPE;}else{_25=27;}var key=String.fromCharCode(_24).toLowerCase();if(key.match(/x|o|c/)||(_24==_25)){this.end();}else{if((key=="p")||(_24==37)){if(this.activeImage!=0){this.disableKeyboardNav();this.changeImage(this.activeImage-1);}}else{if((key=="n")||(_24==39)){if(this.activeImage!=(this.imageArray.length-1)){this.disableKeyboardNav();this.changeImage(this.activeImage+1);}}}}},preloadNeighborImages:function(){var _27,_28;if(this.imageArray.length>this.activeImage+1){_27=new Image();_27.src=this.imageArray[this.activeImage+1][0];}if(this.activeImage>0){_28=new Image();_28.src=this.imageArray[this.activeImage-1][0];}},end:function(){this.disableKeyboardNav();this.lightbox.hide();new Effect.Fade(this.overlay,{duration:this.overlayDuration});$$("select","object","embed").each(function(_29){_29.style.visibility="visible";});},getPageSize:function(){var _2a,_2b;if(window.innerHeight&&window.scrollMaxY){_2a=window.innerWidth+window.scrollMaxX;_2b=window.innerHeight+window.scrollMaxY;}else{if(document.body.scrollHeight>document.body.offsetHeight){_2a=document.body.scrollWidth;_2b=document.body.scrollHeight;}else{_2a=document.body.offsetWidth;_2b=document.body.offsetHeight;}}var _2c,_2d;if(self.innerHeight){if(document.documentElement.clientWidth){_2c=document.documentElement.clientWidth;}else{_2c=self.innerWidth;}_2d=self.innerHeight;}else{if(document.documentElement&&document.documentElement.clientHeight){_2c=document.documentElement.clientWidth;_2d=document.documentElement.clientHeight;}else{if(document.body){_2c=document.body.clientWidth;_2d=document.body.clientHeight;}}}if(_2b<_2d){pageHeight=_2d;}else{pageHeight=_2b;}if(_2a<_2c){pageWidth=_2a;}else{pageWidth=_2c;}return [pageWidth,pageHeight];}};document.observe("dom:loaded",function(){new Lightbox();});