VoteBlock = {
    setup: function() {
	    $('.rateBlock').each(function(){
	            var subject = $(this).find('input[name="vote[subjectId]"]').attr('value');
	            var context = $(this).find('input[name="vote[context]"]').attr('value');
	            $('#rateBlock_'+context+'_'+subject).stars({
	                captionEl: $('#hover_'+context+'_'+subject),
	                cancelShow: false,
	                disabled: false,
	                oneVoteOnly: true,
	                callback: function(ui, type, value){
	                    $.ajax({
	                        type : 'post',
	                        dataType : 'json',
	                        url : makeUrl({module: "vote", action: "addVote"}),
	                        data : {
	                            'vote[subjectId]' : subject,
	                            'vote[context]'   : context,
	                            'vote[score]'     : value
	                        },
	                        beforeSend : function(){
	                            $.blockUI({message:null});
	                        },
	                        success : function(response,status){
	                            if (response.aMsg.type == SGL_MSG_ERROR) {
	                                $('#rateBlock_'+context+'_'+subject).data('stars').enable();
	                                console.log(this);
	                            } 
	                            $.unblockUI();
	                        }
	                    });
	                }
	            });
	    });
    }
}
