function etoileOver(f_id, id_etoile) {
    if($.cookie('fiche_guide_' + f_id) == undefined) {
        n_etoile = id_etoile.substring(7,6);

        for(i=1; i<=n_etoile; i++) {
            if($('#etoile'+i).hasClass('off')) {
                $('#etoile'+i).removeClass('off');
                $('#etoile'+i).addClass('on');
            }
        }

        if(n_etoile < 5) {
            etoileOut(f_id, parseInt(n_etoile)+1);
        }
    }
}

function etoileOut(f_id, n_etoile) {
    if($.cookie('fiche_guide_' + f_id) == undefined) {
        for(i=n_etoile; i<=5; i++) {
            $('#etoile'+i).removeClass('on');
            $('#etoile'+i).addClass('off');
        }
    }
}

function setArticleVote(f_id, f_nbstars){
    if($.cookie('fiche_guide_' + f_id) == undefined){

        $.post("/ajax/votearticle/",
            { id: f_id, nbstars: f_nbstars },
            function(datas){

                if (datas) {

                    $("#count").html(datas.nbvotant);

                } else alert("La requête à la base de données n'a pu aboutir.");
            }, "json"
        );

            $.cookie('fiche_guide_' + f_id, true, { expires: 1 });

    }else{
        alert('Limite d\'un vote par jour pour chaque article');
    }

    return false;
}

function setFicheGuideVote(f_id, f_nbstars){
    if($.cookie('fiche_guide_' + f_id) == undefined){

        $.post("/ajax/voteficheguide/",
            { id: f_id, nbstars: f_nbstars },
            function(datas){

                if (datas) {

                    $("#nb_votes").html(datas.nbvotant);
                    //setNbEtoiles(datas.nbstars);

                } else alert("La requête à la base de données n'a pu aboutir.");
            }, "json"
        );

            $.cookie('fiche_guide_' + f_id, true, { expires: 1 });

    }else{
        alert('Limite d\'un vote par jour pour chaque fiche.');
    }

    return false;
}
