nVotosMessage = function(votos){
    var votosMessage;
    if(votos == 1) votosMessage = votos + ' voto';
    else votosMessage = votos + ' votos';
    return votosMessage;
}

sendRating=function(art_id,rating,votes) {
	art_id = parseInt(art_id);
	rating = parseInt(rating);
    $.ajax({
        type:"POST",
        url:"/action/rating",
        data:{ratingType:'artigo',ratingId: art_id.toString(), ratingValue: rating.toString()},
		  contentType: "application/x-www-form-urlencoded; charset=utf-8",
		  dataType: "text",
		  cache: false,
		  timeout: 10000,
        success: function(){
            $(".votes-row .stars li").unbind("mouseenter").unbind("mouseleave");
            $(".votes-row .stars li:lt("+rating+")").attr("class","active hand");
            $(".votes-row .stars li:gt("+rating+")").attr("class","hand");
            $(".votes-row:lt(2) .votos").html(nVotosMessage(parseInt(votes+1)));
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert("Erro na inserção do voto");
        }
    });
}
