Meetup.DomDeco.MarkAsReadLink=function(){bindMethods(this)};Meetup.DomDeco.MarkAsReadLink.prototype={unreadDate:"1024027200",decorate:function(e){if(!e){LOG.error("No element passed into Meetup.DomDeco.MarkAsReadLink!!!");return false}this.base=e;var b=$tagClass("SPAN","iconNew",this.base);if(b.length==0){return}this.readMark=b[0];this.isNew=!(hasElementClass(this.readMark,"read"));var d=$("renderTime");if(!d){return}this.renderTime=d.value;var h=$("chapterNumber");if(!h){return}chapNum=h.value;elId=this.readMark.id;this.threadId=this.getThreadId(elId);if(!this.threadId){return}var c=(IS_DEV||IS_QA)?getCookie("MEETUP_MEMBER_DEV"):getCookie("MEETUP_MEMBER");var g=c.match(/\bid=(\d+)/);if(g&&g[1]){this.memberId=g[1]}if(!memberId){return}var f=$("forumId");if(!f){return}this.forumId=f.value;var a="icon_unread_off_topic.png";if($("contextName").value=="chapter"){a="icon_unread_off_chapter.png"}this.readImg=IMG({src:"http://img3.meetupstatic.com/img/"+a,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(b){var a=b.match(/.*?newMarker(\d+)/);return(a&&a[1])?a[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(a){if(a){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 a=new Meetup.DomDeco.PNGrite();a.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 a=new Meetup.DomDeco.PNGrite();a.decorate(this.unreadImg)},updateCookie:function(g){var b="MEETUP_MARK2"+global_threadCookieSuffix;var f=getCookie(b);if(f==null){return}var d=new RegExp("\\b"+this.threadId+"=(\\d+)\\b");if(!f.match(d)){return}var e=(g=="isRead")?String(Number(this.renderTime.substring(0,this.renderTime.length-3))+10):this.unreadDate;var f=f.replace(d,this.threadId+"="+e);var a=(typeof(global_threadCookiePath)=="string"&&global_threadCookiePath.length>0?global_threadCookiePath:document.location.pathname);var c=new Date();var h=new Date(c.getTime()+(1000*60*60*24));return b+"="+f+";path="+a+";domain=.meetup.com;expires="+h.toGMTString()},showErrMsg:function(a){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);