
$(document).ready(function() {

	$("input[name='ReviewOpinion']").click(function() {
		
		var reviewID = $(this).parents("div:eq(0)").children("input[name='ReviewID']").val();
		$.get( baseUrl + "/reviews/logIsHelpful", { choice: $(this).val(), ReviewID: reviewID });
		
		$(this).parents("div:eq(0)").slideUp();
   	});


});

function updateReview() {
	$.get('/reviews/processReview', $('#RatingForm').serialize(), function(data)
		{
			if (data == "") 
				closeReview();
			$("#pastVisits").load(baseUrl + "/reservations/getPastVisits",
				function() {
					//$('#RatingForm : radio.star').rating(); 
					initRating();
				}
			);
		}
	);
	
}

function showWriteReview(reviewID,wineryID,bookingID) {
	$("#review").load(baseUrl + "/reviews/loadReview", { ReviewID : reviewID, WineryID : wineryID, BookingID : bookingID },
		function() {
			$('#RatingForm : radio.star').rating(); 
			initRating();
		}
	);
}

function closeReview() {
	$("#review").text('');
}
