function moreFriend(gid){
  $('#showMoreFriend_'+gid).hide();
  $('#moreFriend_'+gid).show();
  return false;
}
var group_comment =
{
    commentLoading: false,
    commentPosting: false,
    commentPage: 0,
    firstTime: true,
    insertSymbol: function(symbol)
    {
        var obj=$('#comment_content').get(0);
        if (document.selection)
        {
            obj.focus();
            sel = document.selection.createRange();
            sel.text = symbol;
        }
        else if (obj.selectionStart || obj.selectionStart == 0)
        {
            var startPos = obj.selectionStart;
            var endPos = obj.selectionEnd;
            obj.value = obj.value.substring(0, startPos)
                        + symbol
                        + obj.value.substring(endPos, obj.value.length);
        } 
        else
        {
            obj.value += symbol;
        }
    },
    loadComment:  function(nid, p)
     {
         if (this.commentLoading)
         {
             return false;
         }       
         $.ajax({
               type: "GET",
               url: "/group/wall/view/" + nid + "?page=" + p,
               beforeSend: function(req){
                   $("#cmt_loader").show();
                   group_comment.commentLoading=true;
               },
               complete: function(res, s){
                   $("#comment_area").html(res.responseText);
                   $("#cmt_loader").hide();
                   group_comment.commentLoading=false;
                   group_comment.commentPage=p;
                   if (!group_comment.firstTime)
                   {
                        location.href='#comment_section';
                   }
                   else
                   {
                        group_comment.firstTime=false;
                   }
                   
                }       
            });
         return false;
     },
     deleteComment: function(gid,cid)
     {
         if (!confirm("Bạn chắc chắn xóa bình luận này"))
             return false;
         $.ajax({
               type: "POST",
               url: "/group/wall/delete/"+gid+"/" + cid + "?page=" + this.commentPage,
               error: function(req, status, info){
                      alert("Có lỗi khi xóa bình luận. Hãy thử lại lần khác");
               },
               success: function(comment, status){
                      $("#comment_area").html(comment);
                      location.href='#comment_section';
               }
        });
        return false;
     },
    saveComment: function(nid, cid) 
    {
        if (cid == '') {
            textAreaID = "#comment_content";
        } else {            
            textAreaID = "#comment_content_" + cid;
        }
        if ($(textAreaID).val()=="")
            return;
        if (group_comment.commentPosting)
            return;                        
        $.ajax({
               type: "POST",
               url: "/group/wall/add/" + nid + "/" + cid,
               data: $(textAreaID).serialize(),
               beforeSend: function(req){
                   $("#cmt_loader").show();
                   group_comment.commentPosting=true;
               },
               error: function(req, status, info){
                      alert("Có lỗi khi cập nhật bình luận của bạn");
               },
               success: function(comment, status){
                      $("#comment_area").html(comment);
                      $(textAreaID).val("");
               },
               complete: function(res, s){
                   $("#cmt_loader").hide();
                   group_comment.commentPosting=false;
                   group_comment.commentPage=0;
                   location.href='#comment_section';
                }
        });
        return false;
    },
    showReplyBox: function(cid)
    {
        $("#reply_hint_" + cid).hide();
        $("#reply_box_" + cid).show();
        return false;
    },
    showReply: function(cid)
    {
        $('.reply_comment_' + cid).show();
        $('#display_reply_' + cid).hide();
        return false;
    }
}

function c_remove_member(username){
  return confirm('Bạn có chắc chắn muốn loại thành viên '+username+' ra khỏi nhóm?');
}