// based on http://ca.rroll.net/2009/05/10/improving-django-comments-user-experience-with-ajax/  

function submitComment() { 
    $('#comment_form form input.submit-preview').remove();
    $.ajax({  
		type: "POST",  
		data: $('#comment_form form').serialize(),  
		url: "/comments/post/",  
		cache: false,  
		dataType: "html",  
		success: function(html, textStatus) {
			$('#comment_form form').replaceWith(html);
			if ($('#comment_form h1').html() === "Thank you for your comment.") { // if this changes, bad things
				$("#submitComment").remove();
			}
			$('#comment_form form input.submit-preview').remove();
			$('#comment_form form input.submit-post').remove();
			 
		},  
		error: function (XMLHttpRequest, textStatus, errorThrown) {  
			$('#comment_form').html('Oops. Couldn\'t post your comment.');
		}  
	});  
	return false;
};
