var server = 0, rating = 0;
$('a#rating-up').click(function() {
	server = parseInt($(this).attr('data-id'));
	rating = parseInt($(this).attr('data-rating'));
	$('#server-rating-' + server).html('<i class="servermon-loading glyphicon glyphicon-refresh"></i>');
	$.ajax({
		url: '/servers/vote',
		type: 'POST',
		data: {'id':server,'rating':rating},
		success: function(answer) {
			$('#servermon-message').hide();
			console.log(answer);
			if(answer == 1) {
				rating = rating + 1;
				$('#server-rating-' + server).css({'color':'green'}).html(rating + '  <i class="linqee-vote-icon glyphicon glyphicon-ok"></i>');
				$('#servermon-message').html('<p class="alert alert-block alert-success">Ваш голос учтен</p>').fadeIn(500);
			}
			else if(answer == 2) {
				$('#server-rating-' + server).css({'color':'red'}).html('<i data-toggle="tooltip" data-placement="top" title="Вы уже голосовали сегодня."  class="linqee-vote-icon glyphicon glyphicon-remove"></i>');
				$('#servermon-message').html('<p class="alert alert-block alert-danger">Вы уже голосовали сегодня</p>').fadeIn(500);
			}
			else {
				$('#server-rating-' + server).css({'color':'red'}).html('<i title="Неизвестная ошибка" class="linqee-vote-icon glyphicon glyphicon-remove"></i>');
				$('#servermon-message').html('<p class="alert alert-block alert-danger">Не известная ошибка</p>').fadeIn(500);
			}
			console.log(answer);
		}
	});
});