// jQuery script to handle the deletion of comments from the band profiles.
jQuery(document).ready(function($){

	// get comment type
	var comment_type = $('#comment_type').val();
	
	$('.deleteButton').each(
  
		// For each delete button, bind the onclick behavior.
		// The "indIndex" is the loop iteration index on the current element.
		function(intIndex){
  
			// Bind the onclick event 
			$(this).bind (
				'click',
				function(){
					
					if (confirmSubmit()) {
					
						// figure out the comment we are on
						//var comment_id_string	= $(this).parent().parent().parent().parent().attr('id'); // this should be like: delete11
						var comment_id_string	= $(this).attr('id'); // this should be like: delete11
						var comment_id 			= comment_id_string.substring(6); // trim off 'delete' so we have the ID
						//alert("comment_id_string: " + comment_id_string + "\ncomment_id: " + comment_id);
					
						$('#comment' + comment_id).hide().load('/ajax/deleteComment.php?id=' + comment_id + '&comment_type=' + comment_type, function() {
							$(this).fadeIn('slow').fadeOut(1500);
							if (typeof(pageTracker) !== 'undefined') {
								pageTracker._trackPageview('/ajax/deleteComment.php'); // track this AJAX call in google analytics
							}
						});
						
					} else {
						return false;
					}
					
					return false; // return false so the link doesn't actually click anywhere
					
				}
			);
		}
	);
});
