(function(b){var a={addTodo:function(e,f,c){if(f){var d=c.find(".pics");var g=b('<a href="'+Gulu.user.url+'" id="self_'+gUSER_ID+'" target="blank" cid="" title="'+Gulu.user.name+'" class="user_pic_xsmall_noshadow fL"><img src="'+Gulu.user.photo.image26x26+'" width="26" height="26" alt="'+Gulu.user.name+'"></a>');d.append(g)}else{b("#self_"+gUSER_ID).remove()}}};b.fn.likeBtn=function(c){b(this.selector).die("click");b(this.selector).live("click",function(i){i.stopPropagation();i.preventDefault();var h=b(this);var g=h.attr("id").split("_");var j=new Date();var f="/like/toggle/"+g[0]+"/"+g[1]+"/?_="+j.getTime();b.ajax({url:f,type:"POST",data:{view_session_id:gViewSessionID},dataType:"json",success:function(d){h.text(d.label);b(c).trigger("updateLikeInfo",{pk:g[1],html:d.html});if(d.is_metoo&&d.object_id){a.addTodo(d,d.is_liker,b(".ui_todo_group."+d.object_id))}if(_.size(h.parents(".functions").siblings(".show_likes").children())>0||h.parents(".functions").siblings(".comment_content").find(".comment_box").size()>0){h.parents(".functions").siblings(".comment_content").find("form").addClass("on")}else{h.parents(".functions").siblings(".comment_content").find("form").removeClass("on")}},error:function(d,k,e){if(d.status==200){autoShowDialogAjax({url:"/ajaxloginpopup/",nail:140,tpye:"GET",data:"",dataType:"html",cache:false,callback:function(){},callback_close:function(){}});return false}}});return false});this.each(function(){var d=b(this);if(d.hasClass("in_todo")){if(d.parents(".ui_todo_group").find(".pics .self").size()>0){d.siblings(".slice_line").remove();d.remove()}}});return this};b.fn.likeInfo=function(){b(this.selector).die("updateLikeInfo");b(this.selector).live("updateLikeInfo",function(d,f){var e=b(this);var c=e.attr("id").split("_");if(f.pk==c[1]){e.html(f.html)}});return this}})(jQuery);
