function GetContentRatings(nid, comments) {
    $.getJSON(
            '/rating.php',
            {
                action: 'getNodeRating',
                nid: nid,
                comments: comments
            },
            function(reply) {
                if(reply.result) {
                    var rating = (reply.rating == null ? 0 : reply.rating ) ;
                    if(reply.myvote == 1)
                    {
                        $("#rating_node" + nid + " > li[class='pm p']").removeClass("pm p").addClass("pm p-act");
                    }
                    else if(reply.myvote == -1)
                    {
                        $("#rating_node" + nid + " > li[class='pm m']").removeClass("pm m").addClass("pm m-act");
                    }
                    
                    $($("#rating_node" + nid + " > li[class='pmn']")[0]).html(rating);
                    

                    if(reply.commentRatings)
                    {

                        $(reply.commentRatings).each(function(i, rating){
                            var comment = $("#rating_comment" + rating.content_id);
                            
                            if(comment.length == 1) { //коммент существует.
                                if(rating.myvote == 1)
                                {
                                    $("li[class='pm p']", comment)
                                        .removeClass("pm p").addClass("pm p-act");
                                }
                                else if(rating.myvote == -1)
                                {
                                    $("li[class='pm m']", comment)
                                        .removeClass("pm m").addClass("pm m-act");
                                }
                                $($("li[class='pmn']", comment)[0]).html(rating.rating);
                            }
                        });
                    }
                }
            }
        );
}

  
        function RateContent(nid, vote, type, parentId) {
            $.getJSON(
                '/rating.php',
                {
                    action: 'rateContent',
                    nid: nid,
                    vote: vote,
                    contentType: type,
                    parentId: parentId
                },
                function(reply) {
                    if(reply.result) {
                        var rating = $($('#rating_' + type + nid + "> li[class='pmn']")[0]).html();
                        $($('#rating_' + type + nid + "> li[class='pmn']")[0]).html(rating++ + vote); //rating++ чтобы обращался с ним как с числом а не как со строкой 
                        if(vote == 1)
                        {
                            $("#rating_" + type + nid + " > li[class='pm p']").removeClass("pm p").addClass("pm p-act");
                        }
                        else if(vote == -1)
                        {
                            $("#rating_" + type + nid + " > li[class='pm m']").removeClass("pm m").addClass("pm m-act");
                        }
                        
                    }
                    else 
                    {
                        alert(reply.message);
                    }
                }
            );
        }
        
        
function RaiseError(mes)
{
    $.jGrowl(mes, { 
        theme: 'alert'
    });
}

function RaiseInfo(mes)
{
    $.jGrowl(mes);
}