function followUser(id) {
  // Ajax通信
  new $.ajax({
    type: 'post',
    url: '/follow_user/',
    data: {
        'follow_user_id': id
    },
    success: function(data){
        idName = 'follow' + id;
        document.getElementById(idName).innerHTML = '<img onclick="unfollowUser(' + id + ');" style="cursor:pointer" src="/images_new/btn_bookmark_on.gif" alt="" />';
    }
  });
}
function unfollowUser(id) {
  // Ajax通信
  new $.ajax({
    type: 'post',
    url: '/unfollow_user/',
    data: {
        'follow_user_id': id
    },
    success: function(data){
        idName = 'follow' + id;
        document.getElementById(idName).innerHTML = '<img onclick="followUser(' + id + ');" style="cursor:pointer" src="/images_new/btn_bookmark.gif" alt="" />';
    }
  });
}
function addFavorite(id) {
  // Ajax通信
  new $.ajax({
    type: 'post',
    url: '/kuchikomi_favorite/',
    data: {
        'id': id
    },
    success: function(data){
        idName = 'favorite' + id;
        document.getElementById(idName).innerHTML = '<a onclick="deleteFavorite(\'' + id + '\');" style="cursor:pointer">お気に入りを解除</a> <span style="color:red">お気に入りに追加しました</span>';
    }
  });
}
function deleteFavorite(id) {
  // Ajax通信
  new $.ajax({
    type: 'post',
    url: '/kuchikomi_unfavorite/',
    data: {
        'id': id
    },
    success: function(data){
        idName = 'favorite' + id;
        document.getElementById(idName).innerHTML = '<a onclick="addFavorite(\'' + id + '\');" style="cursor:pointer">お気に入りに追加</a> <span style="color:red">お気に入りに解除しました</span>';
    }
  });
}
