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 hideGalleryHiResDL(){document.getElementById("galleryHighResSave").style.display="none"}function showGalleryHiResDL(){new Effect.Appear("galleryHighResSave",{duration:0.5})}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 setHighResImage(A){if(A){document.getElementById("galleryHighResSaveLink").href="ajaxRequest.php?type=galleryDownloadPhoto&photo="+A}}function galleryCheckOverlays(){var A=document.getElementById("photoGalleryEmailFriend");if(A){if(A.style.display!="none"){galleryEmailWindowHide()}}}function galleryProductInfoEmail(){var J=false;var D=document.getElementById("gal_sendersName");var I=document.getElementById("gal_sendersNameErr");var H=document.getElementById("gal_emails");var K=document.getElementById("gal_emailsErr");var C=document.getElementById("gal_useHTML");var L=document.getElementById("gal_message");var B=document.getElementById("gal_messageErr");var G=document.getElementById("gal_model").value;if(G){I.innerHTML="";B.innerHTML="";K.innerHTML="";if(D.value.length==0){J=true;I.innerHTML="You must include your name."}if(D.value.length>200){J=true;I.innerHTML="Name is too long."}if(L.value.length>500){J=true;B.innerHTML="Optional message too long."}if(H.value.length<5){J=true;K.innerHTML="Must include a valid email address."}var H=H.value;if(H){var E="";var A=new Array();A=H.split(",");for(var F=0;F<A.length;F++){if(!emailcheck(A[F])){E=E+" "+A[F]}}if(E!=""){J=true;K.innerHTML="The following email addresses are incorrect: "+E}}if(J==false){new Ajax.Updater({success:"ajaxProductInfoSent"},"ajaxRequest.php?type=gallerySendProductInfo",{method:"post",postBody:"&model="+G+"&isHTML="+C.checked+"&name="+D.value+"&emails="+H+"&message="+L.value,onComplete:function(){D.value="";L.value="";document.getElementById("gal_emails").value="";galleryCheckOverlays()}})}}}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){historySetBackButton("galBottom"+A,{function_name:"TableauGallery",image_num:A})}}function emitNewGalPhoto(A,B,C){gallerySetBackButton(C);if(A){hideGalleryHiResDL();new Ajax.Updater({success:ajaxGalElement},"ajaxRequest.php?type=loadGalleryPhoto",{method:"post",postBody:"&photo="+A,onCreate:function(){galleryCheckOverlays()},onComplete:function(){showGalleryHiResDL();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,B){if(B){setHighResImage(B)}totalImages=A;document.getElementById(galToolBarElement).style.display="block";if(isKeyNavOk){galleryKeyBoardObserver()}if(document.getElementById("firstInGallery")){loadGalleryPhotoArray(document.getElementById("firstInGallery"))}galleryUpdateImageList()};