// ставим оценку посту

function estimate_post (post_id, rating)
{
  $('.blog-item-estimate .ajax-loader').removeClass('hidden');
  $.post('/ajax/estimate_post', { post_id: post_id, rating: rating }, function (data) {
    $('.blog-item-estimate-result .inner').html(data.result_str);
    $('.blog-item-estimate').addClass('hidden');
    $('.blog-item-estimate-result').removeClass('hidden');
    $('.blog-post-info .rating span').html(data.new_rating);
    if (data.new_rating > 0) $('.blog-post-info .rating').addClass('rating-plus');
    else if (data.new_rating < 0) $('.blog-post-info .rating').addClass('rating-minus');
    else { $('.blog-post-info .rating').removeClass('rating-minus').removeClass('rating-plus') }
  }, "json" );
}



// добавляем пост в избранное

function change_post_in_favorites (post_id)
{
    //$('#blog-post-info-'+parseInt(post_id)+' .favorites').addClass('fav-load');
  if ($('#blog-post-info-'+post_id+' .favorites').hasClass('fav-in'))
  {
    $.post('/ajax/del_post_from_favorites', { post_id: post_id }, function(data) {
      if (data.status)
      {
        //$('#blog-post-info-'+post_id+' .favorites').removeClass('fav-load').removeClass('fav-in').find('a').attr('title', 'Добавить в избранное');
        //Alert.show('Уведомление', 'Публикация удалена из избранного', 'message');
      }
    }, "json");
  }
  else
  {
    $.post('/ajax/add_post_to_favorites', { post_id: post_id }, function(data) {
      if (data.status)
      {
        //$('#blog-post-info-'+parseInt(post_id)+' .favorites').removeClass('fav-load').addClass('fav-in').find('a').attr('title', 'Удалить из избранного');
          $('#blog-post-info-'+parseInt(post_id)+' .favorites').removeClass('fav-load').htn;
        //Alert.show('Уведомление', 'Публикация добавлена в избранное', 'message');
      }
    }, "json");
  }
}



function post_slider_change (img, slide_num)
{
    $('.post-slider li').addClass('hidden');
    $('.post-slider-thumbs li').removeClass('active');

    $('.post-slider li.img-'+slide_num).removeClass('hidden');
    $(img).parent().addClass('active');
    post_slider_current_img = slide_num;
}


function post_slider_change_by_click ()
{
    post_slider_current_img++;
    if (post_slider_current_img > $('.post-slider-thumbs li').size()) post_slider_current_img = 1;

    $('.post-slider li').addClass('hidden');
    $('.post-slider-thumbs li').removeClass('active');

    $('.post-slider li.img-'+post_slider_current_img).removeClass('hidden');
    $('.slider-thumb-'+post_slider_current_img).addClass('active');
}
