var delay=5500;var curIndex=getPn("pn");var timer;var started=false;function viewStoryPhotos(){performHide(document.getElementById("inlinePhoto"));showPhoto(0)}function hideStoryPhotos(){stopSlideshow();performShow(document.getElementById("inlinePhoto"));performHide(document.getElementById("storyPhoto"));performHide(document.getElementById("photoThumbs"))}function getPn(a){var d=location.search.substring(1,location.search.length);var c=false;var b=d.split("&");for(i=0;i<b.length;i++){param_name=b[i].substring(0,b[i].indexOf("="));if(param_name==a){c=b[i].substring(b[i].indexOf("=")+1)}}if(c){return c}else{return 0}}function showPhoto(a){performShow(document.getElementById("photoControls"));if(a>=0&&a<=arrayPics.length-1){curIndex=a;performShow(document.getElementById("storyPhoto"));performShow(document.getElementById("photo"));performHide(document.getElementById("photoThumbs"));document.getElementById("photo").style.backgroundImage="url("+arrayPics[a].src+")";document.getElementById("currentPhoto").innerHTML=parseInt(a)+parseInt(1)+"";if(arrayCaptions!=null){document.getElementById("caption").innerHTML=arrayCaptions[a]}captionOverflow()}showPrevNext()}function toggleCaption(){performToggle(document.getElementById("caption"));performToggle(document.getElementById("captionTop"));captionOverflow()}function captionOverflow(){if(document.getElementById("caption").style.display=="block"){if(document.getElementById("caption").offsetHeight>213){document.getElementById("captionTop").innerHTML="Use two fingers to scroll caption"}else{document.getElementById("captionTop").innerHTML=""}}}function previousPhoto(){showPhoto(parseInt(curIndex)-parseInt(1))}function nextPhoto(){showPhoto(parseInt(curIndex)+parseInt(1))}function showPrevNext(){if(curIndex==0){document.getElementById("photoControlPrevious").style.opacity=0.4}else{document.getElementById("photoControlPrevious").style.opacity=0.999}if(curIndex==arrayPics.length-1||arrayPics.length==1){document.getElementById("photoControlNext").style.opacity=0.4}else{document.getElementById("photoControlNext").style.opacity=0.999}if(arrayPics.length==1){document.getElementById("photoControlPlay").style.opacity=0.4}}function startSlideshow(){if(started){stopSlideshow();return}if(arrayPics.length<2){return}started=true;document.getElementById("photoControlPlay").className="pause";document.getElementById("photoControls").className="";showPhoto(curIndex);timer=setTimeout("slideshow()",delay)}function stopSlideshow(){window.clearTimeout(timer);started=false;if(document.getElementById("photoControlPlay")){document.getElementById("photoControlPlay").className=""}}function slideshow(){if(curIndex<arrayPics.length-1){nextPhoto();timer=setTimeout("slideshow()",delay)}else{if(curIndex==arrayPics.length-1){stopSlideshow();document.getElementById("photoControlPlay").className="";showPhotoThumbs();curIndex=0}}}function showSharePhoto(){if(started){stopSlideshow()}performShow(document.getElementById("sharePanel"));performHide(document.getElementById("photoControls"));hideAddressbar()}sharing=false;function goSharePhotoGallery(a){if(sharing){return false}sharing=true;phone=document.getElementById("shareByTextBox").value;n=document.getElementById("yourNameTextBox").value;if(phone.length!=0&&"1"==phone.substring(0,1)){phone=phone.substring(1)}if(n.length==0){document.getElementById("errorMsg").innerHTML='"Your Name" is required';performShow(document.getElementById("errorShareByText"));sending=false;return false}if(phone.length!=10){document.getElementById("errorMsg").innerHTML="invalid phone number";performShow(document.getElementById("errorShareByText"));sending=false;return false}db=document.getElementById("dbId").value;performHide(document.getElementById("sharePanel"));performShow(document.getElementById("photoControls"));a=a+"?db="+db+"&phone="+phone+"&n="+n+"&photoId="+arrayPhotoIds[curIndex];req.onreadystatechange=shareHandler;req.open("GET",a);req.send(null);sharing=false;return false}function updateShareCountHandlerPhoto(){}function mailGoPhoto(d,c){c=c+"?ci="+arrayPhotoIds[curIndex];req.onreadystatechange=updateShareCountHandlerPhoto;req.open("GET",c);req.send(null);var a=d.indexOf("?");if(a>0){d=d.substring(0,a)}d=d+"?photoid="+arrayPhotoIds[curIndex];var b="I found this photo using iPhone News:\n\n"+d;document.location.href="mailto:?subject=I%20thought%20you%20should%20see%20this%20photo&&body="+escape(b)}function showPhotoThumbs(){if(arrayPics.length<2){return}stopSlideshow();performHide(document.getElementById("caption"));performHide(document.getElementById("captionTop"));performHide(document.getElementById("photo"));performHide(document.getElementById("photoControls"));performShow(document.getElementById("photoThumbs"))};
