$(document).ready(function(){
    $(".being_there").live("click", function() {
	if($("#wp_logged_in").val() !== "logged_in") {
	    alert("You must log in to use this feature");
	}
	else {
	    the_show_id = $(this).attr("rel");
	    button = $(this);
	    if(!$(this).hasClass("already_there")) {
		jQuery.post(
		    // see tip #1 for how we declare global javascript variables
		    //MyAjax.ajaxurl,
		    "../../../wp-admin/admin-ajax.php",
		    {
			action : 'bt-record-being-there',
		 
			// other parameters can be added along with "action"
			show_id: the_show_id
		    },
		      function( response ) {
			//console.log(response);
			$(button).addClass("already_there");
			$(button).html("I Was There");
			$('.being-tiny').addClass('hidden');
			}
		)
	    }
	    else {
		//alert("Already there!");
	    }
	}
    });
    
    $(".remove-being-there").live("click", function() {
	the_show_id = $(this).attr("rel");
	button = $(this);
	
	jQuery.post(
	    // see tip #1 for how we declare global javascript variables
	    //MyAjax.ajaxurl,
	    "../../../wp-admin/admin-ajax.php",
	    {
		action : 'bt-remove-being-there',
	 
		// other parameters can be added along with "action"
		show_id: the_show_id
	    },
	     function( response ) {
		//console.log(response);
		$(button).parent().hide();
	    }
	)
    });
});

