function changePhoto(a){window.location.hash=a;return false}function loadPhoto(b,d,a,c){nextPosition=parseInt(a)+1;$("#photo_display").load("/photos_display_handler.php",{photoSetType:b,photoSetTypeID:d,photoSetPosition:a,page:c},function(){preloadPhoto(b,d,nextPosition,c)})}function preloadPhoto(b,d,a,c){$("#preloadNextPhoto").load("/photos_display_cache_handler.php",{photoSetType:b,photoSetTypeID:d,photoSetPosition:a,page:c})}var photoSetTypeID=$("#photoSetTypeID").val();var photoSetType=$("#photoSetType").val();var page=$("#page").val();var maxPosition=$("#maxPosition").val();setInterval("hashPoll()",50);var curHash=window.location.hash;var commentTextAreaIDs=new Array();function hashPoll(){hashNum=window.location.hash;if(!hashNum){curURL=document.location.href;arrURL=curURL.split("/");hashNum=arrURL[arrURL.length-1]}hashNum=hashNum.replace("#","");if(curHash!=window.location.hash){loadPhoto(photoSetType,photoSetTypeID,hashNum,page);curHash=window.location.hash}var b=$(":input[name*='_text']");for(var a=0;a<b.length;a++){var c=b[a].id;if(jQuery.inArray(c,commentTextAreaIDs)==-1){$("#"+c).focus(function(){textAreaHasFocus=true});$("#"+c).blur(function(){textAreaHasFocus=false});commentTextAreaIDs.push(c)}}}hashNum=window.location.hash;hashNum=hashNum.replace("#","");if(hashNum){$("#photo_display").html("");loadPhoto(photoSetType,photoSetTypeID,hashNum,page);curHash=window.location.hash}var textAreaHasFocus=false;$(document).keydown(function(c){if(!hashNum){curURL=document.location.href;arrURL=curURL.split("/");hashNum=arrURL[arrURL.length-1]}var a=parseInt(hashNum)+1;if(a>(parseInt(maxPosition)-1)){a=0}var b=parseInt(hashNum)-1;if(b<0){b=parseInt(maxPosition)-1}if(!c.ctrlKey&&!c.altKey&&!textAreaHasFocus){if(c.which==37){changePhoto(b)}else{if(c.which==39){changePhoto(a)}}}});