    function reloadPage(_url, response) {
        // если пользователь только что авторизовался
        if (response && response.loginOn) {
            $.post(
                _url + "?section=get_comment_form",
                {},
                function(data) {
                    tinyMCE.execCommand('mceRemoveControl', false, 'commentTextArea');
                    $("#commentList").html(data);
                    $('#commentTextArea').val('');
                    bindSimpleAjaxForm ();
                    initEditorValues();
                    createAudioPlugin();
                    tinyMCE.execCommand('mceAddControl', false, 'commentTextArea');
                    // инициализируем mp3-плеер
                    initMp3Player();
                }
            );            
            
        } else if (response && response.sendNews) {
            // после отправки ссылки другу
            $("#sendByEmail").hide();
            $("#isSent").show();
        } else if (response && response.commentEdit) {
            // после редактирования комментария
            reloadPage(response.afterEditUrl);
        } else {
            $.post(
                _url,
                {},
                function(data) {
                    tinyMCE.execCommand('mceRemoveControl', false, 'commentTextArea');
                    $("#commentList").html(data);
                    $('#commentTextArea').val('');
                    bindSimpleAjaxForm ();
                    initEditorValues();
                    createAudioPlugin();
                    tinyMCE.execCommand('mceAddControl', false, 'commentTextArea');
                    // инициализируем mp3-плеер
                    initMp3Player();
                }
            );
        }
    }

    var stripBlogComments = function()
    {
        $("#blogContent").val($("#blogContent").val().replace(/&lt;!--.*?--&gt;/gi, '').replace(/<!--.*?-->/gi, ''));
    }

    
    // ответ в гостевой
    var replyTo = function (commentId, userId)
    {
        $("#toUserName").html('Ответ пользователю: ' + $("#comment" + commentId).html()).show();
        $("#toUserNameDel").show();
        $("#toUserId").val(userId);
        $("#commentForm").show();
        return false;
    }
    
    var deleteReply = function (link)
    {
        $('#toUserName').empty().hide();
        $('#toUserId').val('');
        $(link).hide();
        return false;
    }
    
    $(document).ready(function() {
        if ($("#newsVote")) {
            $("#newsVote").click(function(e) {
                e.preventDefault();
                
                if (confirm("Мне нравится!")) {
                    var sendUrl = $(this).attr("href");
                	$.ajax({
		          		url: sendUrl,
		          		data: {},
		          		success: function(data) {
		                    $("#voteCount").html("&nbsp;" + data.voteCount);
		                    $("#voteButton").remove();
		                },
		                type: 'post',
              			dataType: 'json'
              		});
                }
            });
        }
    });
    
    // удалить комментарий
    var delComment = function (newsUrl, commentId)
    {
        if (confirm('Удалить комментарий?')) {
            $.getJSON(newsUrl + "?section=delcomment&commentId=" + commentId, function(data) {
                if (data.reloadUrl) {
                    reloadPage(data.reloadUrl);
                } else {
                    doRedirect(newsUrl);
                }
            });
        }
        return false;
    }    
    
    //функция показа картинок в галерее новости
    function showNewsImages (link, startFrom)
    {
        var href = $(link).attr('href');
        startFrom--;
        
        // затемняем экран
        fsShadowBox.addOnClick( function(){ $('#newsImages').remove(); } );
        fsShadowBox.show({
            opacity: 0.92,
            backgroundColor: '#e8e8e6'
        });
        
        $.post(
            href,
            {},
            function(data) {
                var _width = 840;
                var _height = 600;
                $("body").append(data);
                var _top = $(document).scrollTop() + ($(window).height() / 2 - _height /2);
                if (_top < 0) _top = 0;
                var _left = $(document).scrollLeft() + ($(window).width() / 2 - _width /2);
                $('#newsImages').css(
                    {
                        top:  _top,
                        left:  _left,
                        //width: _width + "px",
                        height: _height + "px",
                        display: "block",
                        zIndex: 10000                    
                    }
                );
                // вешаем карусель изображений
                $(".showBlock").jCarouselLite({
                    start: startFrom,
                    btnNext: ".next",
                    btnPrev: ".prev",
                    circular: true,
                    visible: 1,
                    mouseWheel: true
                });                
            }
        );
        return false;
    }