// jQuery script used to post reviews on the show detail page.
jQuery(document).ready(function($){

	// user has clicked 'i am attending this show'
	var bindAttendShow = function() {
		// Bind the onclick event 
		$('#attendShow').bind (
			'click',
			function(){
				
				var tourdate_id = $('#tourdate_id').val(); // get current tourdate_id
				
				$('#attendingShowControlLoading').show();
				
				$('#attendingShowControl').hide().load('/ajax/addAttendingShow.php?tourdate_id=' + tourdate_id, function() {
					$('#attendingShowControlLoading').hide();
					$(this).fadeIn();
					if (typeof(pageTracker) !== 'undefined') {
						pageTracker._trackPageview('/ajax/addAttendingShow.php'); // track this AJAX call in google analytics
					}
				});
				return false; // return false so the link doesn't actually click anywhere					
			}
		);
	};
	
	// user has clicked 'i am no longer attending this show'
	var bindRemoveAttendShow = function() {
		// Bind the onclick event 
		$('#removeAttendShow').bind (
			'click',
			function(){
				
				var tourdate_id = $('#tourdate_id').val(); // get current tourdate_id
				
				$('#attendingShowControlLoading').show();
				
				$('#attendingShowControl').hide().load('/ajax/removeAttendingShow.php?tourdate_id=' + tourdate_id, function() {
					$('#attendingShowControlLoading').hide();
					$(this).fadeIn();
					if (typeof(pageTracker) !== 'undefined') {
						pageTracker._trackPageview('/ajax/removeAttendingShow.php'); // track this AJAX call in google analytics
					}
				});
				return false; // return false so the link doesn't actually click anywhere					
			}
		);
	};

	bindAttendShow();
	bindRemoveAttendShow();
	
});