
	$(document).ready(function() {
		
		$('a[class=nyroModal]').nyroModal();
		
		$('.helpful_vote').click(function(){
			var value = $(this).attr('value');
			var param = $(this).attr('href');
			var secondParam = param.split("&");
			var review_id_container = secondParam[1].split("=");
			var review_id = review_id_container[1];
			$.ajax({
				type:"GET",
				cache: false,
				url: 'index.php?component=review_helpful&action='+value,
				data: param,
				success:function(msg){
					if(Number(msg) == 1){
						var original = $('#yes'+review_id).html();
						var new_number = Number(original)+1;
						$('#yes'+review_id).html(new_number);
						$.facebox('We are glad that you liked this review. Thank you for your feedback!');
					}
					else if(Number(msg) == 2){
						var original = $('#no'+review_id).html();
						var new_number = Number(original)+1;
						$('#no'+review_id).html(new_number);
						$.facebox('Thank you for your feedback!')
					}
					else
						$.facebox(msg);
				}
			});
			return false;
		}); //End of Helpful Vote Click
		$('#delete_link').click(function(){
			var param = $(this).attr('href');
			var secondParam = param.split("&");
			var finalParam = secondParam[1]+'&'+secondParam[2];
			var continue_submit = confirm('Do you really want to delete this review?\n\nNote: The photos uploaded with the review will not be deleted when you delete a review. ');
			if(!continue_submit)
				return false;
			$.ajax({
				type:"GET",
				cache: false,
				url: 'index.php?component=view_restaurant_reviews&action=deleteReview',
				data: finalParam,
				success:function(msg){
					if(msg == 'Review not specified. Please reload page and try again.' || msg == 'Review and logged in member information do not match, please re-login and try again.')
						$.facebox(msg);
					else 
						window.location.reload();
				}
			});
			return false;
		}); // End of Delete Link
	});

	$(function(){		
		$('.inner').corner({
		  tl: { radius: 5 },
		  tr: { radius: 5 },
		  bl: { radius: 5 },
		  br: { radius: 5 }});
	});