Meetup.DomDeco.MarkAsReadLink=function(){bindMethods(this)};Meetup.DomDeco.MarkAsReadLink.prototype={unreadDate:"1024027200",decorate:function(el){if(!el){LOG.error("No element passed into Meetup.DomDeco.MarkAsReadLink!!!");return false}this.base=el;var readEls=$tagClass("SPAN","iconNew",this.base);if(readEls.length==0){return}this.readMark=readEls[0];this.isNew=!(hasElementClass(this.readMark,"read"));var rEl=$("renderTime");if(!rEl){return}this.renderTime=rEl.value;var chapNumEl=$("chapterNumber");if(!chapNumEl){return}chapNum=chapNumEl.value;elId=this.readMark.id;this.threadId=this.getThreadId(elId);if(!this.threadId){return}var memCookie=(IS_DEV||IS_QA)?getCookie("MEETUP_MEMBER_DEV"):getCookie("MEETUP_MEMBER");var idMatch=memCookie.match(/\bid=(\d+)/);if(idMatch&&idMatch[1]){this.memberId=idMatch[1]}if(!memberId){return}var forumEl=$("forumId");if(!forumEl){return}this.forumId=forumEl.value;var iconName="icon_unread_off_topic.png";if($("contextName").value=="chapter"){iconName="icon_unread_off_chapter.png"}this.readImg=IMG({src:"http://img1.meetupstatic.com/img/"+iconName,alt:"Read","class":"icon unread png",width:"8",height:"15"});this.unreadImg=IMG({src:"http://img2.meetupstatic.com/img/261376935677367609/icon_unread_on.png",alt:"Unread","class":"icon unread png"});this.readMark.style.cursor=(IS_IE)?"hand":"pointer";this.readMark.setAttribute("title","Mark this thread as '"+(this.isNew?"read":"unread")+"'");connect(this.readMark,"onclick",this.toggle)},getThreadId:function(id){var idMatch=id.match(/.*?newMarker(\d+)/);return(idMatch&&idMatch[1])?idMatch[1]:0},prepareRpc:function(){if(!this.rpc){return}this.rpc.setArg("threadId",this.threadId);this.rpc.setArg("memberId",this.memberId);this.rpc.setArg("forumId",this.forumId);this.rpc.setArg("ts",this.renderTime);this.rpc.onSuccess=this.handleResponse;this.rpc.onError=this.showErrMsg;this.rpc.onTimeout=this.handleTimeout},toggle:function(){if(this.rpc){return}this.base.style.cursor="wait";this.isNew?this.markRead():this.markUnread()},handleResponse:function(data){if(data){if(this.rpc.method=="markThreadAsRead"){this.applyIsRead()}else{this.applyIsNew()}}else{this.showErrMsg()}this.rpc=null},handleTimeout:function(){this.base.style.cursor="";this.rpc=null;this.showErrMsg("We were unable to mark this thread as read. Reason: it took too long.")},applyIsRead:function(){this.isNew=false;killKids(this.readMark);this.readMark.appendChild(this.readImg);this.base.style.cursor="";this.readMark.className="iconNew read";this.readMark.setAttribute("title","Mark this thread as 'unread'");document.cookie=this.updateCookie("isRead");var png=new Meetup.DomDeco.PNGrite();png.decorate(this.readImg)},applyIsNew:function(){this.isNew=true;killKids(this.readMark);this.readMark.appendChild(this.unreadImg);this.base.style.cursor="";this.readMark.className="iconNew";this.readMark.setAttribute("title","Mark this thread as 'read'");document.cookie=this.updateCookie("isNew");var png=new Meetup.DomDeco.PNGrite();png.decorate(this.unreadImg)},updateCookie:function(type){var cookie_name="MEETUP_MARK2"+global_threadCookieSuffix;var cookie=getCookie(cookie_name);if(cookie==null){return}var threadIdRegex=new RegExp("\\b"+this.threadId+"=(\\d+)\\b");if(!cookie.match(threadIdRegex)){return}var cookieTime=(type=="isRead")?String(Number(this.renderTime.substring(0,this.renderTime.length-3))+10):this.unreadDate;var cookie=cookie.replace(threadIdRegex,this.threadId+"="+cookieTime);var path=(typeof(global_threadCookiePath)=="string"&&global_threadCookiePath.length>0?global_threadCookiePath:document.location.pathname);var dateObj=new Date();var expires_date=new Date(dateObj.getTime()+(1000*60*60*24));return cookie_name+"="+cookie+";path="+path+";domain=.meetup.com;expires="+expires_date.toGMTString()},showErrMsg:function(errStr){this.base.style.cursor="";this.rpc=null},markRead:function(){this.rpc=new Meetup.RpcCall("markThreadAsRead",undefined);this.rpc.enableStatus(this.readMark,"Marking...");this.prepareRpc();this.rpc.call()},markUnread:function(){this.rpc=new Meetup.RpcCall("unmarkThreadAsRead");this.rpc.enableStatus(this.readMark,"Marking...");this.prepareRpc();this.rpc.call()}};Meetup.DomDeco.applyByTagAndClass("TR","thread",Meetup.DomDeco.MarkAsReadLink);