if(typeof(Meetup.PageHelpers)=="undefined"){Meetup.PageHelpers={}}Meetup.PageHelpers.PhotoGallery={};(function(){var self=Meetup.PageHelpers.PhotoGallery;self.cache={photoId:[]};self.ids={};var tagging_instance;var currentPhotoId;var albumThumbnailId;var groupPhotoId;var isGettingPhoto;var deleteCommentId;var selectedPhoto;var currentImageheight;var startPhotoId;var hashStart;self.elements={ALL_SIZES_URLS:$("D_photoGallery_allSizesUrls"),GALLERY_WRAPPER:$("D_photoGallery_wrapper"),CAPTION:$("D_photoGallery_photoCaption"),EDIT_CAPTION_LINK:$("D_photoGallery_editCaptionLink"),EDIT_CAPTION_DIALOG:$("D_photoGallery_editCaptionDialog"),EDIT_CAPTION_TEXTAREA:$("D_photoGallery_editCaptionText"),EDIT_CAPTION_SUBMIT:$("D_photoGallery_editCaptionSubmit"),DELETE_CAPTION_LINK:$("D_photoGallery_deleteCaptionLink"),DELETE_CAPTION_DIALOG:$("D_photoGallery_deleteCaptionDialog"),DELETE_CAPTION_SUBMIT:$("D_photoGallery_deleteCaptionSubmit"),PHOTO:$("D_photoGallery_image"),CREDIT:$("D_photoGallery_uploadCredit_inner"),PHOTO_COUNTER:$("D_photoGallery_currentPhotoCounter"),PAGER:$("D_photoGallery_pager"),NEXT:$("D_photoGallery_actionsNext"),PREV:$("D_photoGallery_actionsPrev"),SET_NAV:$("D_photoGallery_setNavigation"),SET_IMAGES:$("D_photoGallery_images"),ALL_SIZES:$("D_photoGallery_allSizes"),DELETE_PHOTO:$("D_photoGallery_deletePhoto"),MOVE_PHOTO:$("D_photoGallery_movePhoto"),CONFIRM_DELETE_PHOTO:$("D_photoGallery_confirmDeletePhoto"),CONFIRM_DELETE_COMMENT_DIALOG:$("D_photoGallery_confirmDeleteCommentDialog"),CONFIRM_DELETE_COMMENT_SUBMIT:$("D_photoGallery_confirmDeleteComment"),FACEBOOK_SHARE:$("facebookShare"),TWITTER_SHARE:$("twitterShare"),SIGN_IN:$("D_photoGallery_commentsSignIn"),SLIDESHOW_VIEW:$("D_photoGallery_slideshowView"),COMMENTS_WRAPPER:$("D_photoGallery_commentsWrapper"),COMMENTS_FORM:$("D_photoGallery_commentsForm"),COMMENTS_FORM_WRAPPER:$("D_photoGallery_commentsFormWrapper"),COMMENTS_LIST:$("D_photoGallery_comments"),COMMENTS_SUBMIT:$("D_photoGallery_commentsSubmit"),COMMENTS_TEXTAREA:$("D_photoGallery_commentsTextarea"),COMMENTS_SIGNIN:$("D_photoGallery_commentsSignIn"),COMMENTS_EDIT:$("D_photoGallery_commentsEdit"),COMMENTS_PHOTO_ID:$("D_photoGallery_commentsPhotoId"),ORG_CONTROLS:$("D_photoGallery_orgControlsWrapper"),MAKE_GROUP_PHOTO:$("D_photoGallery_makeGroupPhoto"),MAKE_ALBUM_THUMBNAIL:$("D_photoGallery_makeAlbumThumbnail")};var el=self.elements;var debug=function(msg){return false};var generateTemplate=function(photoId,caption,src){if(!Meetup.Facebook.altTemplate[photoId]){if(IS_DEV){src=src.replace(".dev.",".")}var href_fb=[Meetup.Data.groupBaseUrl,Meetup.Data.photoAlbum.id,"/",photoId,"/i3/facebook",].join("");var href_tw=[Meetup.Data.groupBaseUrl,Meetup.Data.photoAlbum.id,"/",photoId,"/i3/twitter",].join("");Meetup.Facebook.altTemplate[photoId]={name:Meetup.Copy.shareThisTitle,href:href_fb,caption:caption,media:[{type:"image",src:src,href:href_fb}]};Meetup.Twitter.altTemplate[photoId]={name:Meetup.Copy.shareThisTitle,href:href_tw,caption:Meetup.Copy.shareThisTitle}}};var getImage=function(e,photoId){if(e){e.stop()}if(isGettingPhoto){return}isGettingPhoto=true;var currentImageTransitionComplete=false;var tweenImageHeight=function(r,dims){Meetup.Tweener.addTween(el.PHOTO,{height:dims.h+"px",width:dims.w,time:0.2,transition:"linear",onComplete:function(){fadeInImage(r)}})};var fadeInImage=function(r,dims){el.PHOTO.src=r.six;(function(){if(el.PHOTO.complete&&(typeof el.PHOTO.naturalHeight!="undefined"||el.PHOTO.naturalHeight!=0)){Meetup.Tweener.addTween(el.PHOTO,{opacity:1,time:0.2,onStart:function(){removeElementClass("D_bigPhotoBody","isLoading");if(dims){el.PHOTO.style.width=dims.w+"px"}},onComplete:function(){selectedPhoto=r;updateHTML(r);setSelectedPhoto(r.index);if(typeof(self.cache.photo[r.id])=="undefined"){Meetup.Data.photoAlbum.photos.push(r);self.cache.photo[r.id]=Meetup.Data.photoAlbum.photos.length-1;tagging_instance.currentPhotoIndex[0]=Meetup.Data.photoAlbum.photos.length-1}else{tagging_instance.currentPhotoIndex[0]=self.cache.photo[r.id]}tagging_instance.afterMetaFadeOut();isGettingPhoto=false}})}else{setTimeout(arguments.callee,10)}})()};var succeed=function(req){var r=evalJSONRequest(req);self.cache.photo.put(photoId,req);Meetup.Data.photoAlbum.next=r.next;Meetup.Data.photoAlbum.previous=r.previous;currentPhotoId=r.id;if(typeof(self.ids[r.id])=="undefined"){var index=r.index;var pageNumber=Math.floor(index/Meetup.Data.photoAlbum.pageSize)+1;var offset;if($("current_photo_gallery_page").value!=pageNumber){offset=(pageNumber-1)*Meetup.Data.photoAlbum.pageSize}if(index==0){offset=0;debug("got to beginning")}if(index==Meetup.Data.photoAlbum.totalSize-1){offset=(Meetup.Data.photoAlbum.pageSize*Meetup.Data.photoAlbum.pages)-Meetup.Data.photoAlbum.pageSize;debug("got to end")}getPage(null,offset)}var tempImage=IMG({src:r.six,style:"position: absolute; left: -5000px; top: 0;"},null);document.body.appendChild(tempImage);if(!Meetup.Facebook.altTemplate[r.id]){generateTemplate(r.id,r.title,r.thumbUrl)}Meetup.Facebook.altTemplateKey=r.id;Meetup.Twitter.altTemplateKey=r.id;(function(){if(tempImage.complete&&currentImageTransitionComplete){debug("image loaded and transition complete");var dims=getElementDimensions(tempImage);if(dims.h==currentImageHeight){debug("no need to animate height");fadeInImage(r,dims)}else{tweenImageHeight(r,dims)}currentImageHeight=dims.h;removeElement(tempImage)}else{setTimeout(arguments.callee,10)}})()};var fail=function(){isGettingPhoto=false;alert("could not get photo")};if(self.cache.photo.get(photoId)!=null){succeed(self.cache.photo.get(photoId));debug("found cache for id:"+photoId)}else{var def=Meetup.Http.post(Meetup.Data.chapter.url+"photo_ajax/",MochiKit.Base.queryString({photoId:photoId,albumId:Meetup.Data.photoAlbum.id,op:"photo"}));def.addCallbacks(succeed,fail)}Meetup.Tweener.addTween(el.PHOTO,{opacity:0,time:0.5,onComplete:function(){currentImageTransitionComplete=true;addElementClass("D_bigPhotoBody","isLoading")}})};var getPage=function(e,offset){if(e){e.stop()}if(offset||offset==0){var photo_offset=offset}else{var photo_offset=parseQueryString(e.target().href.split("?")[1]).photo_offset}Meetup.Tweener.addTween(el.SET_IMAGES,{opacity:0.35,time:0.5});var def=Meetup.Http.post(Meetup.Data.chapter.url+"photo_ajax/",MochiKit.Base.queryString({albumId:Meetup.Data.photoAlbum.id,op:"pager",photo_offset:photo_offset}));var succeed=function(r){el.SET_NAV.innerHTML=r.responseText;el.SET_IMAGES=$("D_photoGallery_images");cachePhotoIds()};var fail=function(){alert("could not get page")};def.addCallbacks(succeed,fail)};var updateHTML=function(r){if(!r){debug("no response passed to updateHTML()");return false}el.ALL_SIZES.href=Meetup.Data.groupBaseUrl+"all_sizes/"+r.id;var allSizesUrls=[r.thumbUrl,r.small,r.bigUrl,r.six,r.hiRezUrl];var allSizesAnchors=getElementsByTagAndClassName("a",null,el.ALL_SIZES_URLS);var allSizesInputs=getElementsByTagAndClassName("input",null,el.ALL_SIZES_URLS);for(var i=0;i<5;i++){allSizesAnchors[i].href=allSizesUrls[i];allSizesInputs[i].value=allSizesUrls[i];connect(allSizesInputs[i],"onclick",function(e){var elm=e.src();elm.select()})}el.CAPTION.innerHTML=r.caption;if(el.EDIT_CAPTION_TEXTAREA&&el.EDIT_CAPTION_LINK){el.EDIT_CAPTION_TEXTAREA.value=r.caption!=""?unescapeEntities(r.caption):"";var captionDialogHdr=get1st("h3",null,el.EDIT_CAPTION_DIALOG);if(!r.caption&&el.EDIT_CAPTION_LINK){el.EDIT_CAPTION_LINK.innerHTML=Meetup.Copy.addCaption;captionDialogHdr.innerHTML=Meetup.Copy.addCaption}else{el.EDIT_CAPTION_LINK.innerHTML=Meetup.Copy.editCaption;captionDialogHdr.innerHTML=Meetup.Copy.editCaption}if(r.member.isCurrentUser||Meetup.Data.member.isCoord){removeElementClass(el.EDIT_CAPTION_LINK,"displaynone")}else{addElementClass(el.EDIT_CAPTION_LINK,"displaynone")}if(r.caption&&(r.member.isCurrentUser||Meetup.Data.member.isCoord)){removeElementClass(el.DELETE_CAPTION_LINK,"displaynone")}else{addElementClass(el.DELETE_CAPTION_LINK,"displaynone")}}if(el.COMMENTS_LIST){el.COMMENTS_LIST.innerHTML=""}if(r.comments&&r.comments.length>0){forEach(r.comments,function(item){buildComment(item,false)})}else{handleZeroCommentsDisplay()}if(el.COMMENTS_PHOTO_ID){el.COMMENTS_PHOTO_ID.value=r.id}if(el.DELETE_PHOTO){var deletePhotoUrl=Meetup.Data.groupBaseUrl+"?"+queryString({op:"delete",photoId:currentPhotoId,photoAlbumId:Meetup.Data.photoAlbum.id});el.DELETE_PHOTO.href=deletePhotoUrl;el.CONFIRM_DELETE_PHOTO.href=deletePhotoUrl;var deletePhotoLI=getFirstParentByTagAndClassName(el.DELETE_PHOTO,"li",null);if(r.member.isCurrentUser||Meetup.Data.member.isCoord){removeElementClass(deletePhotoLI,"displaynone")}else{addElementClass(deletePhotoLI,"displaynone")}}if(el.MOVE_PHOTO){if(r.member.isCurrentUser||Meetup.Data.member.isCoord){removeElementClass(el.MOVE_PHOTO,"displaynone")}else{addElementClass(el.MOVE_PHOTO,"displaynone")}}if(el.ORG_CONTROLS){updateOrgControlDisplay(el.MAKE_ALBUM_THUMBNAIL,Meetup.Copy.thisIsTheAlbumThumbnail);updateOrgControlDisplay(el.MAKE_GROUP_PHOTO,Meetup.Copy.thisIsTheGroupPhoto)}el.PHOTO_COUNTER.innerHTML=(r.index+1)+" of "+Meetup.Data.photoAlbum.totalSize;var viaConsumerInfo="";if(r.consumerName){viaConsumerInfo=SPAN({},BR({},null),"via "+r.consumerName);if(r.consumerUrl){viaConsumerInfo=SPAN({},BR({},null),"via ",A({href:r.consumerUrl,target:"_blank"},r.consumerName))}}if(r.member.id<0){var creditInfo=DIV({"class":"info"},"Added by a former member",viaConsumerInfo,BR({},null)," on "+r.ctime);replaceChildNodes(el.CREDIT,creditInfo)}else{var creditImage=DIV({"class":"memberPhoto"},A({href:Meetup.Data.chapter.url+"members/"+r.member.id},IMG({src:r.member.memberPhoto},null)));var creditInfo=DIV({"class":"info"},"Added by ",A({href:Meetup.Data.chapter.url+"members/"+r.member.id},null),viaConsumerInfo,BR({},null)," on "+r.ctime);get1st("a",null,creditInfo).innerHTML=r.member.name;replaceChildNodes(el.CREDIT,creditImage,creditInfo)}if(el.SIGN_IN){el.SIGN_IN.href=Meetup.Data.photoAlbum.albumReturnBaseUri+r.id}tagging_instance.resetPosition()};var cachePhotoIds=function(){self.ids={};var imgs=getElementsByTagAndClassName("img",null,el.SET_IMAGES);forEach(imgs,function(item){self.ids[item.id.split("photoId_")[1]]=null})};var setSelectedPhoto=function(index){Meetup.Data.photoAlbum.currentPhotoIndex=index;if(el.PAGER){var slice=Meetup.Data.photoAlbum.pageSize*($("current_photo_gallery_page").value-1);var figure=index-slice}var toSelect=(index>Meetup.Data.photoAlbum.pageSize-1)?figure:index;debug("toSelect: "+toSelect);var currentSelected=get1st("li","currentPhoto",el.SET_IMAGES);if(currentSelected){var r=removeElementClass(currentSelected,"currentPhoto")}addElementClass(getElementsByTagAndClassName("li",null,el.SET_IMAGES)[toSelect],"currentPhoto")};var editCaption=function(e){if(e){e.stop()}var captionText=el.EDIT_CAPTION_TEXTAREA.value;if(trim(captionText).length>250){alert("caption is too long");return}var def=Meetup.Http.post(Meetup.Data.chapter.url+"api/",MochiKit.Base.queryString({method:"updatePhotoComment",arg_eventPhotoId:currentPhotoId,arg_member:Meetup.Data.member.id,arg_urlname:Meetup.Data.chapter.urlname,arg_comment:captionText}));var succeed=function(r){el.CAPTION.innerHTML=escapeHTML(captionText);el.EDIT_CAPTION_LINK.innerHTML=Meetup.Copy.editCaption;get1st("h3",null,el.EDIT_CAPTION_DIALOG).innerHTML=Meetup.Copy.editCaption;signal(el.EDIT_CAPTION_DIALOG,"dismiss");if(hasElementClass(el.DELETE_CAPTION_LINK,"displaynone")){removeElementClass(el.DELETE_CAPTION_LINK,"displaynone")}bustCache(currentPhotoId);debug("successfully edited photo caption")};var fail=function(){alert("could not edit photo caption");signal(el.EDIT_CAPTION_DIALOG,"dismiss")};def.addCallbacks(succeed,fail)};var deleteCaption=function(e){if(e){e.stop()}var def=Meetup.Http.post(Meetup.Data.chapter.url+"api/",MochiKit.Base.queryString({method:"updatePhotoComment",arg_eventPhotoId:currentPhotoId,arg_member:Meetup.Data.member.id,arg_urlname:Meetup.Data.chapter.urlname,arg_comment:""}));var succeed=function(r){el.CAPTION.innerHTML="";el.EDIT_CAPTION_TEXTAREA.value="";el.EDIT_CAPTION_LINK.innerHTML=Meetup.Copy.addCaption;get1st("h3",null,el.EDIT_CAPTION_DIALOG).innerHTML=Meetup.Copy.addCaption;signal(el.DELETE_CAPTION_DIALOG,"dismiss");addElementClass(el.DELETE_CAPTION_LINK,"displaynone");bustCache(currentPhotoId);debug("successfully deleted photo caption")};var fail=function(){alert("could not delete photo caption");signal(el.DELETE_CAPTION_DIALOG,"dismiss")};def.addCallbacks(succeed,fail)};var cancelEditCaption=function(e){el.EDIT_CAPTION_TEXTAREA.value=el.CAPTION.innerHTML;Meetup.DomDeco.applyTo(el.EDIT_CAPTION_TEXTAREA,Meetup.DomDeco.CharCounter)};var newComment=function(e){if(e){e.stop()}var def=Meetup.Http.post(Meetup.Data.chapter.url+"api/",MochiKit.Base.queryString({method:"createPhotoComment",arg_eventPhotoId:el.COMMENTS_PHOTO_ID.value,arg_memberId:Meetup.Data.member.id,arg_text:el.COMMENTS_TEXTAREA.value,arg_language:Meetup.Language}));var succeed=function(r){el.COMMENTS_TEXTAREA.value="";Meetup.DomDeco.applyTo(el.COMMENTS_TEXTAREA,Meetup.DomDeco.CharCounter);bustCache(currentPhotoId);buildComment(r,true);Meetup.GAT.successCode="PH_CMNT";Meetup.GAT.triggerSuccess="ph";debug("added new photo comment")};var fail=function(){alert("could not add new photo comment")};def.addCallbacks(succeed,fail)};var confirmDeleteComment=function(e){if(e){e.stop()}deleteCommentId=null;deleteCommentId=getCommentId(e.target());debug("request to delete comment: "+deleteCommentId);signal(el.CONFIRM_DELETE_COMMENT_DIALOG,"appear")};var deleteComment=function(e){if(e){e.stop()}var def=Meetup.Http.post(Meetup.Data.chapter.url+"api/",MochiKit.Base.queryString({method:"deletePhotoComment",arg_eventPhotoId:el.COMMENTS_PHOTO_ID.value,arg_photoCommentId:deleteCommentId,arg_memberId:Meetup.Data.member.id}));var succeed=function(r){removeElement("comment_"+deleteCommentId);handleZeroCommentsDisplay();signal(el.CONFIRM_DELETE_COMMENT_DIALOG,"dismiss");deleteCommentId=null;bustCache(currentPhotoId);debug("deleted photo comment")};var fail=function(){alert("could not delete photo comment");deleteCommentId=null;signal(el.CONFIRM_DELETE_COMMENT_DIALOG,"dismiss")};def.addCallbacks(succeed,fail);debug("delete comment: "+deleteCommentId)};var handleZeroCommentsDisplay=function(){if(!el.COMMENTS_LIST){return}if(!get1st("li","D_photoGallery_comment",el.COMMENTS_LIST)){removeElement(el.COMMENTS_LIST);removeElement(get1st("h3",null,el.COMMENTS_LIST_WRAPPER));el.COMMENTS_LIST=null}};var editCommentMode=function(e){if(e){e.stop()}var commentId=getCommentId(e.target());addElementClass("comment_"+commentId,"commentEditMode");debug("edit comment: "+commentId)};var editComment=function(e){var commentId=getCommentId(e.target());var commentTextEl=get1st("p","commentText","comment_"+commentId);commentTextEl.innerHTML="...";var def=Meetup.Http.post(Meetup.Data.chapter.url+"api/",MochiKit.Base.queryString({method:"editPhotoComment",arg_eventPhotoId:el.COMMENTS_PHOTO_ID.value,arg_memberId:Meetup.Data.member.id,arg_text:get1st("textarea",null,"comment_"+commentId).value,arg_photoCommentId:commentId}));var succeed=function(r){debug("successfully edited photo comment to: "+r.text);commentTextEl.innerHTML=r.text;MochiKit.Visual.Highlight(commentTextEl);bustCache(currentPhotoId)};var fail=function(){alert("could not edit photo comment")};def.addCallbacks(succeed,fail)};var cancelEditComment=function(e){if(e){e.stop()}var commentEl="comment_"+getCommentId(e.target());removeElementClass(commentEl,"commentEditMode")};var getCommentId=function(el){var parentNode=getFirstParentByTagAndClassName(el,"li","D_photoGallery_comment");return parentNode.id.split("comment_")[1]};var buildComment=function(r,isNew){if(!r){debug("no data provided for build comment");return false}var thumbnail,url;if(isNew){thumbnail=Meetup.Data.member.thumb;url=Meetup.Data.member.url;name=Meetup.Data.member.name}else{thumbnail=r.memberPhoto;url=Meetup.Data.chapter.url+"members/"+r.memberId;name=r.memberName}var li=LI({id:"comment_"+r.photoCommentId,"class":"D_photoGallery_comment"},DIV({"class":"commentMemberPhoto"},(thumbnail)?A({href:url},IMG({src:thumbnail},null)):IMG({src:Meetup.Data.noPhotoPhoto},null)),DIV({"class":"commentContent"},SPAN({"class":"commentAuthor"},null),SPAN({"class":"commentMetadata"}," at "+r.ctimeString),P({"class":"commentText"},null),DIV({"class":"commentEdit"},TEXTAREA({"class":"maxChars4900 hasMaxLen"},null),P(null,INPUT({"class":"D_submit J_onClick J_photoGallery_editCommentSubmit",type:"submit",value:"Edit comment",name:"submit"},null)," or ",A({href:"","class":"J_onClick J_photoGallery_cancelEditComment"},"cancel")))));get1st("p","commentText",li).innerHTML=r.text;get1st("textarea",null,li).innerHTML=r.text;if(!name){get1st("span","commentAuthor",li).innerHTML=Meetup.Copy.formerMember}else{get1st("span","commentAuthor",li).innerHTML='<a class="commentAuthorAnchor" href="'+url+'">'+name+"</a>"}if(Meetup.Data.member.id==r.memberId){var commentControls=DIV({"class":"commentControls"},A({href:"","class":"J_onClick J_photoGallery_editComment canDo"},"Edit comment")," | ",A({href:"","class":"J_onClick J_photoGallery_deleteComment canDo"},"Delete comment"))}else{if(Meetup.Data.member.id!=r.memberId&&Meetup.Data.member.isCoord){var commentControls=DIV({"class":"commentControls"},A({href:"","class":"J_onClick J_photoGallery_deleteComment canDo"},"Delete comment"))}}insertSiblingNodesBefore(get1st("div",null,li),commentControls);if(!el.COMMENTS_LIST){debug("creating comments list and header");el.COMMENTS_LIST=UL({id:"D_photoGallery_comments"},null);el.COMMENTS_LIST.appendChild(li);insertSiblingNodesBefore(el.COMMENTS_FORM_WRAPPER,el.COMMENTS_LIST);insertSiblingNodesBefore(el.COMMENTS_LIST,H3(null,"Comments"))}else{el.COMMENTS_LIST.appendChild(li)}if(isNew){MochiKit.Visual.Highlight(li)}Meetup.DomDeco.applyTo(get1st("textarea",null,li),Meetup.DomDeco.CharCounter)};var toggleOrgControls=function(e){if(e){e.stop()}if(hasElementClass(el.ORG_CONTROLS,"isShowing")){removeElementClass(el.ORG_CONTROLS,"isShowing")}else{addElementClass(el.ORG_CONTROLS,"isShowing")}};var updateOrgControlDisplay=function(control,titleAttr){if(!control){return}if(currentPhotoId==groupPhotoId&&control==el.MAKE_GROUP_PHOTO||currentPhotoId==albumThumbnailId&&control==el.MAKE_ALBUM_THUMBNAIL){debug("control: "+control+" currentPhotoId: "+currentPhotoId+" groupPhotoId: "+groupPhotoId+" albumThumb: "+albumThumbnailId);removeElementClass(control,"actionAvailable");var input=get1st("input",null,control);input.checked=true;input.disabled=true;control.title=titleAttr}else{addElementClass(control,"actionAvailable");var input=get1st("input",null,control);input.checked=false;input.disabled=false;control.title=""}};var makeAlbumThumbNail=function(e){if(e){e.stop()}if(currentPhotoId==albumThumbnailId){debug("this photo is the thumbnail");return}var saveIndicator=DIV({"class":"saveIndicator"},"saving...");insertSiblingNodesAfter(el.MAKE_ALBUM_THUMBNAIL,saveIndicator);var def=Meetup.Http.post(Meetup.Data.chapter.url+"photo_ajax/",MochiKit.Base.queryString({photoId:currentPhotoId,albumId:Meetup.Data.photoAlbum.id,op:"defaultAlbum"}));var succeed=function(r){saveIndicator.innerHTML="saved!";setTimeout(function(){removeElement(saveIndicator)},4000);albumThumbnailId=currentPhotoId;updateOrgControlDisplay(el.MAKE_ALBUM_THUMBNAIL,Meetup.Copy.thisIsTheAlbumThumbnail);bustCache(currentPhotoId)};var fail=function(){alert("could not make album thumbnail")};def.addCallbacks(succeed,fail)};var makeGroupPhoto=function(e){if(e){e.stop()}if(currentPhotoId==groupPhotoId){debug("this photo is the group photo");return}var saveIndicator=DIV({"class":"saveIndicator"},"saving...");insertSiblingNodesAfter(el.MAKE_GROUP_PHOTO,saveIndicator);var def=Meetup.Http.post(Meetup.Data.chapter.url+"photo_ajax/",MochiKit.Base.queryString({photoId:currentPhotoId,op:"default"}));var succeed=function(r){saveIndicator.innerHTML="saved!";setTimeout(function(){removeElement(saveIndicator)},4000);groupPhotoId=currentPhotoId;updateOrgControlDisplay(el.MAKE_GROUP_PHOTO,Meetup.Copy.thisIsTheGroupPhoto);bustCache(currentPhotoId)};var fail=function(){alert("could not make album thumbnail")};def.addCallbacks(succeed,fail)};var loadThumbnails=function(){var classes=getElementsByTagAndClassName(null,"imgLoading");forEach(classes,function(item){var img=get1st("img",null,item);showElement(img);var src=getNodeAttribute(img,"url");setNodeAttribute(img,"src",src)})};var unescapeEntities=function(str){if(!str){return false}var retStr=str;retStr=retStr.replace(/&#039;/g,"'");retStr=retStr.replace(/&#034;/g,'"');retStr=retStr.replace(/&gt;/g,">");retStr=retStr.replace(/&lt;/g,"<");retStr=retStr.replace(/&amp;/g,"&");return retStr};var bustCache=function(key){debug("busting cache for: "+key);self.cache.photo.put(key,null)};var keyup=function(e){var targetTagName=e.target().tagName.toUpperCase();if(targetTagName=="INPUT"||targetTagName=="TEXTAREA"){return}switch(e.key().code){case 39:setHash(null,Meetup.Data.photoAlbum.next);debug("right-arrow");break;case 37:setHash(null,Meetup.Data.photoAlbum.previous);debug("left-arrow");break;default:debug("not a key we care about")}};var onHashChange=function(hash){if(hash){getImage(null,hash)}else{if(hashStart){getImage(null,startPhotoId)}}};var setHash=function(e,photoId){if(e){e.stop()}if(isGettingPhoto){return}hashStart=true;var id;if(!photoId){if(hasElementClass(e.target(),"J_photoGallery_getImage")){id=e.target().id.split("photoId_")[1]}else{if(e.src().id=="D_photoGallery_actionsNext"){id=Meetup.Data.photoAlbum.next}else{if(e.src().id=="D_photoGallery_actionsPrev"){id=Meetup.Data.photoAlbum.previous}else{debug("could not get photo");return false}}}}else{id=photoId}window.location.hash=id};var init=function(){if(typeof(Meetup.Data)=="undefined"||typeof(Meetup.Data.photoAlbum)=="undefined"){return}currentPhotoId=Meetup.Data.photoAlbum.photos[0].id;selectedPhoto=Meetup.Data.photoAlbum.photos[0];albumThumbnailId=Meetup.Data.photoAlbum.albumThumbnailPhotoId;groupPhotoId=Meetup.Data.chapter.photoId;currentImageHeight=getElementDimensions(el.PHOTO).h;startPhotoId=currentPhotoId;var photosGalleryDispatch=Meetup.Dispatcher.init(el.GALLERY_WRAPPER);photosGalleryDispatch.registerFunc("J_photoGallery_getImage",setHash);photosGalleryDispatch.registerFunc("J_photoGallery_getPage",getPage);if(el.NEXT&&el.PREV){connect(el.NEXT,"onclick",setHash);connect(el.PREV,"onclick",setHash);connect(document,"onkeyup",keyup)}var photoCommentsDispatch=Meetup.Dispatcher.init(el.COMMENTS_WRAPPER);photoCommentsDispatch.registerFunc("J_photoGallery_editComment",editCommentMode);photoCommentsDispatch.registerFunc("J_photoGallery_editCommentSubmit",editComment);photoCommentsDispatch.registerFunc("J_photoGallery_editCommentSubmit",cancelEditComment);photoCommentsDispatch.registerFunc("J_photoGallery_deleteComment",confirmDeleteComment);photoCommentsDispatch.registerFunc("J_photoGallery_cancelEditComment",cancelEditComment);if(el.COMMENTS_FORM){connect(el.COMMENTS_FORM,"onsubmit",newComment)}if(el.CONFIRM_DELETE_COMMENT_SUBMIT){connect(el.CONFIRM_DELETE_COMMENT_SUBMIT,"onclick",deleteComment)}tagging_instance=new Meetup.DomDeco.GalvPhotoViewer();tagging_instance.decorate("D_photoViewer");cachePhotoIds();if(el.ORG_CONTROLS){if(el.MAKE_ALBUM_THUMBNAIL){connect(el.MAKE_ALBUM_THUMBNAIL,"onclick",makeAlbumThumbNail)}if(el.MAKE_GROUP_PHOTO){connect(el.MAKE_GROUP_PHOTO,"onclick",makeGroupPhoto)}}if(el.EDIT_CAPTION_SUBMIT){connect(el.EDIT_CAPTION_SUBMIT,"onclick",editCaption);connect(get1st("a","J_signal",el.EDIT_CAPTION_DIALOG),"onclick",cancelEditCaption)}if(el.DELETE_CAPTION_SUBMIT){connect(el.DELETE_CAPTION_SUBMIT,"onclick",deleteCaption)}if(el.SLIDESHOW_VIEW){connect(el.SLIDESHOW_VIEW,"onclick",function(e){if(e){e.stop()}Meetup.Slideshow.start();Meetup.pageName="Photo Slideshow";Meetup.GA.track()})}connect(window,"onload",loadThumbnails);self.cache.photo=Meetup.Cache.bindToBucket("PhotoGalleryData");Meetup.History.IFRAME_SRC="/blank.jsp";Meetup.History.initialize(null,onHashChange,this);Meetup.History.MISEC_CHECK_INTERVAL=100;Meetup.History.start();if(el.MOVE_PHOTO){initMovePhoto()}};var hasInitiallyLoadedPager=false;var ev_onMovePhotoTogglerClick=null;var albumPager;var evs_onAlbumThumbClick=null;var initMovePhoto=function(){el.MOVE_PHOTO_TOGGLER=$("D_photoGallery_movePhotoToggler");el.MOVE_PHOTO_SAVE=$("D_photoGallery_confirmMovePhoto");el.MOVE_PHOTO_CONTROL=$("D_photoGallery_movePhotoControl");el.MOVE_PHOTO_PREV=$("D_photoGallery_movePhotoPrev");el.MOVE_PHOTO_NEXT=$("D_photoGallery_movePhotoNext");el.MOVE_PHOTO_ALBUMS=$("D_photoGallery_movePhotoThumbList");el.MOVE_PHOTO_DIALOG=$("D_photoGallery_movePhotoDialog");ev_onMovePhotoTogglerClick=connect(el.MOVE_PHOTO_TOGGLER,"onclick",onMovePhotoTogglerClick);connect(el.MOVE_PHOTO_SAVE,"onclick",onMovePhotoSaveClick);connect(el.MOVE_PHOTO_PREV,"onclick",onMovePhotoPrevClick);connect(el.MOVE_PHOTO_NEXT,"onclick",onMovePhotoNextClick)};var isMovePhotoControlShowing=function(){var result=true;if(hasElementClass(el.MOVE_PHOTO_CONTROL,"jsStartHidden")){result=false}return result};var onMovePhotoTogglerClick=function(ev){disconnect(ev_onMovePhotoTogglerClick);albumPager=Meetup.PhotoAlbumPager.init(Chapter.id,Member.id,Meetup.Data.albumCount,10,Meetup.Data.photoAlbum.id);albumPager.next(onAlbumPagerCallback)};var onAlbumPagerCallback=function(arr){if(hasInitiallyLoadedPager===false){hasInitiallyLoadedPager=true;var spinner=get1st("*","spinner",el.MOVE_PHOTO_CONTROL);el.MOVE_PHOTO_CONTROL.removeChild(spinner);spinner=null}var olds=$tagClass("li",null,el.MOVE_PHOTO_ALBUMS);if(olds.length>0){for(var j=0,jlen=evs_onAlbumThumbClick.length;j<jlen;++j){disconnect(evs_onAlbumThumbClick[j])}el.MOVE_PHOTO_ALBUMS.innerHTML=""}if(albumPager.hasPrev()){removeElementClass(el.MOVE_PHOTO_PREV,"jsStartHidden")}else{addElementClass(el.MOVE_PHOTO_PREV,"jsStartHidden")}if(albumPager.hasNext()){removeElementClass(el.MOVE_PHOTO_NEXT,"jsStartHidden")}else{addElementClass(el.MOVE_PHOTO_NEXT,"jsStartHidden")}generateAlbumThumb(el.MOVE_PHOTO_ALBUMS,arr)};var shorten_text=function(str){var result=str;var length=19;if(result.length>length){result=result.slice(0,length).replace(/^\s+|\s+$/g,"")+"&hellip;"}return result};var generateAlbumThumb=function(parent_ul,arr){evs_onAlbumThumbClick=[];var album,each_li,each_th,each_a;for(var i=0,len=arr.length;i<len;++i){album=arr[i];if(album){each_li=LI({"class":"D_photoGallery_albumThumbnailListItem"});each_li.setAttribute("photoAlbumId",album.photoAlbumId);each_th=SPAN({"class":"D_photoGallery_albumThumbnail D_verticalMiddle"});if(album.photo&&album.photo.urls){each_th.style.backgroundImage="url("+album.photo.urls.thumb+")"}each_a=A({"class":"D_photoGallery_albumThumbnailTitle D_verticalMiddle",href:"#"});each_a.innerHTML=shorten_text(album.title);each_a.onclick=function(){return false};each_li.appendChild(each_th);each_li.appendChild(each_a);parent_ul.appendChild(each_li);evs_onAlbumThumbClick[i]=connect(each_li,"onclick",onAlbumThumbnailListItemClick)}else{LOG.error("passed undefined..?")}}};var onAlbumThumbnailListItemClick=function(ev){Meetup.ActionDropdown.hide(el.MOVE_PHOTO_CONTROL);var li=ev.src();var ul=li.parentNode;var arr=$tagClass("li","selected",ul);for(var i=0,len=arr.length;i<len;++i){removeElementClass(arr[i],"selected")}addElementClass(li,"selected");prepareMovePhotoDialog(li);signal(el.MOVE_PHOTO_DIALOG,"appear")};var prepareMovePhotoDialog=function(li){var album_id=""+li.getAttribute("photoAlbumId");var album=albumPager.getById(album_id);var p=get1st("p","message",el.MOVE_PHOTO_DIALOG);var tmpl=""+p.getAttribute("template");if(tmpl==="null"){tmpl=""+p.innerHTML;p.setAttribute("template",tmpl)}var res=tmpl.replace("__ALBUM_NAME__",album.title);p.innerHTML=res};var onMovePhotoSaveClick=function(ev){ev.stop();var selected=get1st("li","selected",el.MOVE_PHOTO_ALBUMS);var album_id=""+selected.getAttribute("photoAlbumId");if(album_id==Meetup.Data.photoAlbum.id){alert("The selected photo album is the same album!");return false}movePhotoToOtherAlbum(album_id);return false};var movePhotoToOtherAlbum=function(dest){Meetup.History.stop();var form=FORM({method:"post",action:Meetup.Data.groupBaseUrl,style:"visibility: hidden;"});var inputs=[];inputs[inputs.length]=INPUT({type:"hidden",name:"op",value:"move"});inputs[inputs.length]=INPUT({type:"hidden",name:"photoId",value:currentPhotoId});inputs[inputs.length]=INPUT({type:"hidden",name:"photoAlbumId",value:Meetup.Data.photoAlbum.id});inputs[inputs.length]=INPUT({type:"hidden",name:"destAlbumId",value:dest});inputs[inputs.length]=INPUT({type:"hidden",name:"nextPhotoId",value:Meetup.Data.photoAlbum.next});for(var i=0,len=inputs.length;i<len;++i){form.appendChild(inputs[i])}document.body.appendChild(form);form.submit()};var onMovePhotoPrevClick=function(ev){if(isMovePhotoControlShowing()&&albumPager.hasPrev()){albumPager.previous(onAlbumPagerCallback)}};var onMovePhotoNextClick=function(ev){if(isMovePhotoControlShowing()&&albumPager.hasNext()){albumPager.next(onAlbumPagerCallback)}};Meetup.DOMReady.ready(init)})();Meetup.Slideshow={};(function(){var self=Meetup.Slideshow;var debug=function(msg){return false};var PADDING_SIZE=5;var WAIT=4500;var currentPhotoId;var isGettingPhoto;var isPaused=false;var maxImageHeight;var nextPhotoId;var previousPhotoId;var slideshowInstance=false;var timeout;var viewportDimensions;var slideshowImage;var outerImageContainer;self.start=function(){if(slideshowInstance){debug("returning since there is already a slideshow instance ");return}slideshowInstance=true;nextPhotoId=Meetup.Data.photoAlbum.next;previousPhotoId=Meetup.Data.photoAlbum.previous;viewportDimensions=getViewportDimensions();maxImageHeight=viewportDimensions.h-115;buildSlideshow();setTimeout(function(){if(!isPaused){self.play()}},WAIT)};self.play=function(){isPaused=false;showElement("D_slideshow_pause");hideElement("D_slideshow_play");getImage(nextPhotoId)};self.pause=function(){isPaused=true;hideElement("D_slideshow_pause");showElement("D_slideshow_play")};self.next=function(){self.pause();getImage(nextPhotoId)};self.prev=function(){self.pause();getImage(previousPhotoId)};self.close=function(){clearTimeout(timeout);isGettingPhoto=null;isPaused=false;slideshowInstance=false;map(disconnectAll,["D_slideshow_prev","D_slideshow_next","D_slideshow_play","D_slideshow_pause","D_slideshow_close"]);disconnectAll(window,"onresize","onResize");disconnectAll(window,"onscroll","onScroll");map(removeElement,["D_slideshow","D_slideshow_backdrop"])};var buildSlideshow=function(){var backdrop=DIV({id:"D_slideshow_backdrop"});setStyle(backdrop,{height:document.documentElement.scrollHeight+"px",opacity:0.96});var controls=DIV({id:"D_slideshow_controls","class":"inactive"},UL({},LI(null,A({id:"D_slideshow_prev",title:"previous photo"},IMG({src:Meetup.Data.Slideshow.prevImg,title:"previous photo"}))),LI(null,A({id:"D_slideshow_pause",title:"pause slideshow"},IMG({src:Meetup.Data.Slideshow.pauseImg,title:"pause slideshow"}))),LI(null,A({id:"D_slideshow_play",title:"play slideshow",style:"display: none;"},IMG({src:Meetup.Data.Slideshow.playImg,title:"play slideshow"}))),LI(null,A({id:"D_slideshow_next",title:"next photo"},IMG({src:Meetup.Data.Slideshow.nextImg,title:"next photo"}))),LI(null,A({id:"D_slideshow_close",title:"exit slideshow"},IMG({src:Meetup.Data.Slideshow.closeImg,title:"close slideshow"})))));var slideshowContainer=DIV({id:"D_slideshow"},null);setStyle(slideshowContainer,{height:viewportDimensions.h-30+"px",top:getScrollTop()+30+"px"});outerImageContainer=DIV({id:"D_slideshow_outerImageContainer"});setStyle(outerImageContainer,{width:viewportDimensions.w+"px",height:maxImageHeight+"px"});var imageDimensions=getElementDimensions("D_photoGallery_image");imageContainer=DIV({id:"D_slideshow_imageContainer"});setStyle(imageContainer,{width:imageDimensions.w+"px",height:imageDimensions.h+"px"});slideshowImage=IMG({src:$("D_photoGallery_image").src},null);imageContainer.appendChild(slideshowImage);outerImageContainer.appendChild(imageContainer);slideshowContainer.appendChild(outerImageContainer);slideshowContainer.appendChild(controls);appendChildNodes(document.body,backdrop,slideshowContainer);if(Meetup.UserAgent.isIE6()){forEach(getElementsByTagAndClassName("img",null,"D_slideshow_controls"),function(item){Meetup.DomDeco.applyTo(item,Meetup.DomDeco.PNGrite)})}connect("D_slideshow_prev","onclick",self.prev);connect("D_slideshow_next","onclick",self.next);connect("D_slideshow_play","onclick",self.play);connect("D_slideshow_pause","onclick",self.pause);connect("D_slideshow_close","onclick",self.close);connect(window,"onresize",onResize);connect(window,"onscroll",onScroll)};var onResize=function(){debug("Meetup.Slideshow.onResize()");setStyle("D_slideshow_backdrop",{width:document.documentElement.scrollWidth+"px",height:document.documentElement.scrollHeight+"px"});viewportDimensions=getViewportDimensions();maxImageHeight=viewportDimensions.h-115;setStyle(outerImageContainer,{width:viewportDimensions.w+"px",height:maxImageHeight+"px"});setStyle("D_slideshow",{height:viewportDimensions.h-30+"px",top:getScrollTop()+30+"px"})};var onScroll=function(){setTimeout(function(){if($("D_slideshow").style.top!=getScrollTop()+30){setStyle("D_slideshow",{top:getScrollTop()+30+"px"})}},500)};var getScrollTop=function(){return document.documentElement.scrollTop||document.body.scrollTop};var getImage=function(photoId){var id=photoId;if(isGettingPhoto||!slideshowInstance){debug("isGettingPhoto: "+isGettingPhoto+" slideshowInstance: "+slideshowInstance);return}isGettingPhoto=true;var currentImageTransitionComplete=false;var def=Meetup.Http.post(Meetup.Data.chapter.url+"photo_ajax/",MochiKit.Base.queryString({photoId:id,albumId:Meetup.Data.photoAlbum.id,op:"photo"}));var succeed=function(req){var r=evalJSONRequest(req);nextPhotoId=r.next;previousPhotoId=r.previous;currentPhotoId=r.id;var tempImage=IMG({src:r.six,style:"position: absolute; left: -5000px; top: 0;"},null);document.body.appendChild(tempImage);(function(){if(tempImage.complete&&currentImageTransitionComplete){var dims=getElementDimensions(tempImage);if(dims.h>maxImageHeight){tempImage.style.height=maxImageHeight+"px";tempImage.style.width="auto";slideshowImage.style.height=maxImageHeight+"px";dims=getElementDimensions(tempImage)}else{slideshowImage.style.height="auto";slideshowImage.style.width="auto"}removeElement(tempImage);Meetup.Tweener.addTween(imageContainer,{height:dims.h+"px",width:dims.w+"px",time:0.4,transition:"linear",onComplete:function(){if(!slideshowInstance){return}removeElementClass("D_slideshow_imageContainer","isLoading");slideshowImage.src=r.six;(function(){if(slideshowImage.complete){Meetup.Tweener.addTween(slideshowImage,{opacity:1,onComplete:function(){if(!slideshowInstance){return}isGettingPhoto=false;if(!isPaused){debug("setTimeout queued up");timeout=setTimeout(function(){if(r.index==Meetup.Data.photoAlbum.totalSize-1){return endSlideshow()}if(!isPaused){debug("setTimeout() fired");getImage(nextPhotoId)}else{debug("setTimeout skipping getImage() because slideshow is paused")}},WAIT)}}})}else{setTimeout(arguments.callee,10)}})()}})}else{setTimeout(arguments.callee,10)}})()};var fail=function(){isGettingPhoto=false;alert("could not get photo")};def.addCallbacks(succeed,fail);Meetup.Tweener.addTween(slideshowImage,{opacity:0,onComplete:function(){if(!slideshowInstance){return}addElementClass("D_slideshow_imageContainer","isLoading");currentImageTransitionComplete=true}})};var endSlideshow=function(){debug("endSlideshow()");hideElement("D_slideshow_controls");self.pause();Meetup.Tweener.addTween(get1st("img",null,"D_slideshow_imageContainer"),{opacity:0.25,time:1});setStyle("D_slideshow_imageContainer",{backgroundColor:"#000"});var dims=getElementDimensions("D_slideshow_imageContainer");var pos=getElementPosition("D_slideshow_imageContainer","D_slideshow_outerImageContainer");var restart=DIV({"class":"restart"},IMG({src:Meetup.Data.Slideshow.restartImg}),BR(),"Play again");var exit=DIV({"class":"exit"},"or",STRONG(null," Close"));var options=appendChildNodes(DIV({"class":"endOptions"},null),restart,exit);var endSlide=DIV({id:"D_slideshow_endSlide"},null);setStyle(endSlide,{width:dims.w+"px",height:dims.h+"px"});setStyle("D_slideshow_imageContainer",{padding:0,border:PADDING_SIZE+"px solid #fff"});appendChildNodes("D_slideshow_imageContainer",appendChildNodes(endSlide,options));connect(exit,"onclick",self.close);connect(restart,"onclick",self.restart)};self.restart=function(){debug("restart()");removeElement("D_slideshow_endSlide");showElement("D_slideshow_controls");setOpacity(get1st("img",null,"D_slideshow_imageContainer"),1);setStyle("D_slideshow_imageContainer",{padding:PADDING_SIZE+"px",border:"none",backgroundColor:"#fff"});self.play()}})();