$(document).ready(
	function() {
		$('form.rating_form').each(
			function() {
				bindRatingsForm($(this));
			}
		);
	}
)

function bindRatingsForm(form) {
	form.find('input[type=radio]').rating(
		{
			callback: function(value, link) {
				form.find('span.rating_complete').css('display', 'block');
				form.find('span.rating_complete').hide();
				
				$.post(
					form.attr('action') + '?ajax=1',
					form.serialize(),
					function(data) {
						if(data == 'OK') {
							form.find('span.rating_complete').fadeIn();
						}
					},
					'text'
				);
			}
		}
	);
}