jQuery(function($) {
    $('a.hijax-to-next').click(function(e){
        e.preventDefault();
        var el = $(this);
        if (el.parent().next().is(':visible')) {
            el.css('font-weight', 'normal');
            el.parent().next().empty();
            el.parent().next().hide();
        } else {
            $.ajax({
                url: el.attr('href'),
                dataType: 'html',
                beforeSend: function() {
                    el.css("opacity", 0.5);
                },
                error: function(XMLHttpRequest) {
                    //alert('Ошибка при загрузке данных.');
                    location.href = el.attr('href');
                },
                success: function(html) {
                    el.css("opacity", 1);
                    el.css('font-weight', 'bold');
                    el.parent().next().html($(html).find('.article .content'));
                    $('img.thumbnail').parents('a').fancybox({
                        'zoomSpeedIn': 0,
                        'zoomSpeedOut': 0,
                        'enableEscapeButton': true,
                        'showCloseButton': false
                    });
                    el.parent().next().show();
                }
            });
        }

    })
});
