$('#review').ajaxForm({
	dataType: 'json',
	success: function(data)
	{
		$.each(data, function(i, val)
		{
			if(i == 'e')
				bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
					[{
						"label" : "OK",
						"class" : "btn-small btn-primary",
					}]
				);

			if(i == 's')
				bootbox.dialog('<h3 class="red">Внимание</h3>Спасибо за отзыв, он был направлен на модерацию.',
					[{
						"label" : "OK",
						"class" : "btn-small btn-primary",
						callback: function () { location.href = '/reviews'; }
					}]
				);
		});

		loading(0);

		return false;
	}
});

function review_rating(id)
{
	$.getJSON(home+'reviews/id/'+id+'/rating', function(data)
	{
		$.each(data, function(i, val)
		{
			if(i == 'e')
				bootbox.dialog('<h3 class="red">Ошибка</h3>'+val,
					[{
						"label" : "OK",
						"class" : "btn-small btn-primary",
					}]
				);

			if(i == 's')
				$('#review_'+id+'_rating').html(val);

			if(i == 'red')
				$('#review_'+id+'_rating_color').addClass('reviews-red');

			if(i == 'black')
				$('#review_'+id+'_rating_color').removeClass('reviews-red');
		});
	});

	return false;
}