$(document).on('click', '.js-authorized-load-popular', function () {
    if ($(this).data('loaded') == 0) {
        loadRestPopular($(this));
    } else {
        toggleRestPopular($(this));
    }
});

function toggleRestPopular(loadButton) {
    var $popularBlock = $(".cusongslist-authorized-popular");
    $popularBlock.toggleClass('authorized-popular-rest-hidden');
    if ($popularBlock.hasClass('authorized-popular-rest-hidden')) {
        $(loadButton).text('Смотреть все');
        $('html, body').animate({
            scrollTop: $('.authorized-prd-block__popular').offset().top - 100
        }, 200);
    } else {
        $(loadButton).text('Скрыть популярные ' + cot_sitename['padeg']['_i']);
    }
}

