var imageArray=new Array();var currentImageNum=1;var totalImages=0;var isKeyNavOk=true;var galHighResImg=null;var ajaxGalElement="ajaxLoadGalleryPhoto";var galCaptionElement="photoGalleryImgTitle";var galPrevElement="galleryPrevLabel";var galNextElement="galleryNextLabel";var galToolBarElement="galleryToolBar";var galFindElement="a[rel^=photoGallery]";var galLoadingImg="/images/common/loading_icon.gif";var thumbContainer="outerThumbContainer";function showGalleryOverlay(){document.getElementById("photoGalleryOverlay").style.display="block"}function hideGalleryOverlay(){document.getElementById("photoGalleryOverlay").style.display="none"}function galleryEmailWindowShow(){showGalleryOverlay();new Effect.Appear("photoGalleryEmailFriend",{duration:0.5})}function galleryEmailWindowHide(){new Effect.Fade("photoGalleryEmailFriend",{duration:0.5,afterFinish:function(){hideGalleryOverlay()}})}function galleryToggleEmailAFriendWindow(){var a=document.getElementById("photoGalleryEmailFriend");if(a.style.display=="none"){galleryEmailWindowShow()}else{galleryEmailWindowHide()}}function galleryCheckOverlays(){var a=document.getElementById("photoGalleryEmailFriend");if(a){if(a.style.display!="none"){galleryEmailWindowHide()}}}function setCurrentImgBorder(a){for(x=0;x<totalImages;x++){element=document.getElementById(thumbContainer+x);if(element){element.style.borderColor="#C2C1C1"}}element=document.getElementById(thumbContainer+a);element.style.borderColor="#005D7E";currentThumb=a}function toggleDirectionalLinks(a){if(a>0){new Effect.Appear(galPrevElement)}else{new Effect.Fade(galPrevElement)}if(a<(imageArray.length-1)){new Effect.Appear(galNextElement)}else{new Effect.Fade(galNextElement)}}function galleryEmitCaption(a){var b=document.getElementById(galCaptionElement);b.style.display="none";b.innerHTML="";if(a){b.innerHTML=a;new Effect.Appear(galCaptionElement,{duration:0.5})}}function gallerySetBackButton(a){if(a!==false){}}function emitNewGalPhoto(a,b,c){gallerySetBackButton(c);if(a){new Ajax.Updater({success:ajaxGalElement},"ajaxRequest.php?type=loadGalleryPhoto",{method:"post",postBody:"&photo="+a,onCreate:function(){galleryCheckOverlays()},onComplete:function(){galleryEmitCaption(b)}})}}function toggleLoadingWindow(){var a="";element=document.getElementById(ajaxGalElement);a="<div align='center'><img src='"+galLoadingImg+"' alt='loading' title='loading...' align='center'></div>";element.innerHTML=a}function emitGalleryPhoto(b){setCurrentImgBorder(b);toggleDirectionalLinks(b);var a=imageArray[b][0];toggleLoadingWindow();emitNewGalPhoto(a,imageArray[b][1],b);currentImageNum=b}function loadGalleryPhotoArray(b){imageArray=new Array();var a=0;imageArray=$$(b.tagName+'[href][rel="'+b.rel+'"]').collect(function(c){return[c.href,c.title]}).uniq();while(imageArray[a][0]!=b.href){a++}emitGalleryPhoto(a)}function galleryUpdateImageList(){document.observe("click",(function(a){var b=a.findElement(galFindElement)||a.findElement(galFindElement);if(b){a.stop();loadGalleryPhotoArray(b)}}).bind(this))}function galleryPreviousImg(){if(currentImageNum!=0){var a=currentImageNum-1;emitGalleryPhoto(a)}}function galleryNextImg(){if(currentImageNum!=(totalImages-1)){var a=currentImageNum+1;emitGalleryPhoto(a)}}function galleryKeyBoardObserver(){document.observe("dom:loaded",function(){Event.observe(document,"keydown",function(c){var a=c.keyCode;var b=String.fromCharCode(a).toLowerCase();if(document.getElementById("photoGalleryOverlay").style.display=="none"){if((b=="p")||(a==37)){galleryPreviousImg()}if((b=="n")||(a==39)){galleryNextImg()}}})})}function initializeGallery(a){totalImages=a;document.getElementById(galToolBarElement).style.display="block";if(isKeyNavOk){galleryKeyBoardObserver()}if(document.getElementById("firstInGallery")){loadGalleryPhotoArray(document.getElementById("firstInGallery"))}galleryUpdateImageList()};