/**
 * @author Jay Jagpal
 */

var voted = false;

$(document).ready(function(){
	
	$('.vote-button').click(function(){
		
		var button = $(this);
		var id = $(this).attr('id');
		
		if(!voted)
			$.ajax({
				  url: 'ajax/voteForFavoritePlot.php?plot=' + id ,
				  success: function(data) {
					   if(data == '1')
					   {
						   $(button).val("Thanks!");
						   voted = true;
					   }
					   else
					   {
						   $(button).val("Try Again.");
					   }
						   
				  }
				});
		
	});
	
});

