$(function(){
	$("#commentsubmit").click(function(){
		$.post("/ajax/comment.php", {
			dare_id: $("#dare_id").val(),
			commentarea: $("#commentarea").val(),
			commentsubmit: 1
		},
		function(data) {
			$("#commenterrors").empty();
			if (data.substr(0,2)=="::")
			{
				// error'd!!
				var errorlines = data.split("\n");
				$.each(errorlines, function(){
					$("#commenterrors").append('<p>' + this.substr(2) + '</p>');
				});
			}
			else
			{
				$("#comment-none").remove();
				$("#comment").prepend(data);
				$("#commentarea").val('');
			}
		});
		return false; // no form submit
	});
});
