var noCaptionsText="";var defaultPhotoDialog="";var removePhotoDialog="";function initGallery(){photoid=getPhotoID_fromURL();if(photoid==undefined){jsPhotos.current=0}else{jsPhotos.current=getIndex_fromPhotoID(photoid)}var a=parseInt(jQuery("#jsGallery .viewport").width()*0.8);var b=a/16*12;jQuery("#jsGallery .photoDisplay").height(b);jQuery("#jsGallery .container").height(b);jQuery("#jsGallery .overlay").css("margin-top",b*-1);jQuery("#jsGallery .photoBtn").css("margin-top",b/2-30);jQuery("#jsGallery .photoLoad").css("top",b*0.5-9).css("left",(a*0.5*1.2-27));displayPhoto(jsPhotos.current);jQuery("#jsGallery .photoDisplay").hover(function(){jQuery("#jsGallery .overlay").fadeIn("fast")},function(){jQuery("#jsGallery .overlay").fadeOut("normal")});jQuery("#jsGallery .photoBtn.prev").click(function(){displayPhoto(getPrevPhotoIndex())});jQuery("#jsGallery .photoBtn.next").click(function(){displayPhoto(getNextPhotoIndex())})}function displayPhoto(d){jsPhotos.current=d;if(!jsPhotos.entry[d]){return}var c=(jsPhotos.entry[d].caption!="")?jsPhotos.entry[d].caption:noCaptionsText;jQuery("#jsGallery .photoCaption h3").text(c);jQuery("#jsGallery .photoLoad").show();var a=jsPhotos.entry[d].fullsize+"&maxW="+jQuery("#jsGallery .container").width()+"&maxH="+jQuery("#jsGallery .container").height();var b=new Image();jQuery(b).load(function(){jQuery("#jsGallery .photoImg").fadeOut("fast",function(){jQuery("#jsGallery .photoImg").attr("src",b.src);var j=b.height;var h=jQuery("#jsGallery .container").height();jQuery("#jsGallery .photoImg").css("top",parseInt((h-j)/2));var g=b.width;var f=jQuery("#jsGallery .container").width();jQuery("#jsGallery .photoImg").css("left",parseInt((f-g)/2));jQuery("#jsGallery .photoImg").fadeIn("fast");jQuery("#jsGallery .photoLoad").hide()})}).attr("src",a);jQuery("#jsGallery .photoImg").attr("alt",c);var e=jsPhotos.entry[d].photoid;switchPhotoTrigger(e);setPhotoID_toURL(jsPhotos.entry[d].photoid);jQuery("#jsGallery .photoBtn.next img").attr("src",jsPhotos.entry[getNextPhotoIndex()].thumbnail);jQuery("#jsGallery .photoBtn.prev img").attr("src",jsPhotos.entry[getPrevPhotoIndex()].thumbnail);photoPrefetch(getPrevPhotoIndex());photoPrefetch(getNextPhotoIndex())}function photoPrefetch(c){var a=jsPhotos.entry[c].fullsize+"&maxW="+jQuery("#jsGallery .container").width()+"&maxH="+jQuery("#jsGallery .container").height();var b=new Image();jQuery(b).load(function(){}).attr("src",a)}function getNextPhotoIndex(){i=parseInt(jsPhotos.current)+1;if(i>=jsPhotos.entry.length){i=0}return i}function getPrevPhotoIndex(){i=parseInt(jsPhotos.current)-1;if(i<0){i=jsPhotos.entry.length-1}return i}function setPhotoID_toURL(a){document.location=document.location.href.split("#")[0]+"#photoid="+a}function getPhotoID_fromURL(){var a=document.location.href;if(a.match("#")&&a.split("#")[1].match("photoid=")){a=a.split("#")[1];if(a.match("&")){a=a.split("&")[0]}return a.split("=")[1]}}function getIndex_fromPhotoID(b){for(var a=0;a<jsPhotos.entry.length;a++){if(jsPhotos.entry[a].photoid==b){return a}}}function switchPhotoTrigger(a){jax.call("community","photos,ajaxSwitchPhotoTrigger",a)}function editPhotoCaption(){var a=jQuery.trim(jQuery("#jsGallery .photoCaption h3").text());jQuery("#jsGallery .photoCaption_EditMode input").val(a);jQuery("#jsGallery .photoCaption").hide();jQuery("#jsGallery .photoCaption_EditMode").show()}function cancelPhotoCaption(){jQuery("#jsGallery .photoCaption_EditMode").hide();jQuery("#jsGallery .photoCaption").show();jQuery("#jsGallery .photoCaption_EditMode input").val("")}function savePhotoCaption(){var a=jQuery.trim(jQuery("#jsGallery .photoCaption h3").text());var b=jQuery.trim(jQuery("#jsGallery .photoCaption_EditMode input").val());if(b==""||b==a){cancelPhotoCaption()}else{jax.call("community","photos,ajaxSaveCaption",jsPhotos.entry[jsPhotos.current].photoid,b)}}function updatePhotoCaption(b,a){jQuery("#jsGallery .photoCaption h3").text(a);jsPhotos.entry[getIndex_fromPhotoID(b)].caption=a;cancelPhotoCaption()}function removePhoto(){if(confirm(removePhotoDialog)){var b=jsPhotos.current;var c=jsPhotos.entry[b].photoid;var a="0";jsPhotos.entry.splice(b,1);if(jsPhotos.entry.length==0){a="1";jax.call("community","photos,ajaxRemovePhoto",c,a)}else{jax.call("community","photos,ajaxRemovePhoto",c,a);if(b>=jsPhotos.entry.length){b=0}displayPhoto(b)}}}function setPhotoAsDefault(){var a=jsPhotos.album;var b=jsPhotos.entry[jsPhotos.current].photoid;if(confirm(defaultPhotoDialog)){jax.call("community","photos,ajaxSetDefaultPhoto",a,b)}};
