$(document).ready(function(){

    $(".score").click( function()
    {
        var id_note = $('.cla_id').val();
        var cookie = parsecookies("clanek"+id_note);



        if (cookie == true)
        {
            return false;
        }
        return true;
    });

    $('.vote,.vote_plus').mouseover( function() {
        var voters = $('.vote,.vote_plus');
        var score = this.value;
        for(var i = 0; i < score; i++)
        {
            $(voters[i]).removeClass('vote');
            $(voters[i]).addClass('vote_plus');
        }

        for(var j = score; j < 10; j++)
        {
            $(voters[j]).removeClass('vote_plus');
            $(voters[j]).addClass('vote');
        }
        return false;
    }).mouseout( function(){
        var voters = $('.vote,.vote_plus');
        var truevalue = parseInt($('#score_value').html(),'');
        for(var i = 0; i < truevalue; i++)
        {
            $(voters[i]).removeClass('vote');
            $(voters[i]).addClass('vote_plus');
        }
        for(var j = truevalue; j < 10; j++)
        {
            $(voters[j]).removeClass('vote_plus');
            $(voters[j]).addClass('vote');
        //voters[j].className='vote';
        }
    });

    var parsecookies = function(namex)
    {
        var cookieList=document.cookie.split("; ");
        var cookieArray = new Array();
        for (var i=0; i < cookieList.length; i++)
        {
            var name = cookieList[i].split("=");
            cookieArray[unescape(name[0])] = unescape(name[1]);
        }

        if (cookieArray[namex])
        {
            alert("Pro tento článek jste již hlasoval/a.");
            return true
        }
        return false
    };

});
