/*
-------------------------------------
AJAX загрузка форм отправки сообщений
-------------------------------------
*/

$(document).on('click', '#ajax-comments-button', function(e){
    
    var $that = $('.panel-bottom-comments-js');
    
    var link = $that.attr('action');
    
    $('#ajax-comments-button').html('<i class="fa fa-spinner fa-spin fa-fw"></i>');
    
    $.post(
      
      link,
      
      $(".panel-bottom-comments-js").serialize(),
      
      function(data) { 
        
        var title_ajax = $('div[title]').text();
        document.title = title_ajax;
        history.pushState(link, title_ajax, link);
        
        document.body.scrollTop = 0;
        document.documentElement.scrollTop = 0;
        
        open_modal = 0;
        var data = $(data);
        var elem = data.find('#content').html();
        $("#content").html(elem);
      
      }
    
    );
   
   e.preventDefault();
  
});