$(document).ready(
    function()
    {
        disabled = $('#loggedin')[0].value!='true';
        $("#stars-wrapper").stars(
            {inputType:"select",
            disabled:disabled,
             oneVoteOnly: true,
            callback: function(ui, type, value)
            {
                $('rat').hide();
                $('loader').show();
                post_url =  $('#rat')[0].action;
                $.post(post_url, {rate:value}, function(db)
                    {
                        ui.select(Math.round(db.avg));
                        $("#avg").text(db.score);
                        $("#votes").text(db.votes);
                        $("#loader").hide();
                        $("#rat").show();
                    }, "json");

            }}
        );
    }
);
