jQuery(document).ready(function(){
	jQuery('.entry #commentform').submit(function(){return false;});

	jQuery('.entry #commentform #submit').click(function(){
		var post_url   = jQuery('#commentform').attr("action");
		var com_author = jQuery('#author').val();
		var com_email  = jQuery('#email').val();
		var com_url    = jQuery('#url').val();
		var comment    = jQuery('#comment').val();
		var com_id     = jQuery('#comment_post_ID').val();
		com_id = jQuery('#commentform input[name=comment_post_ID]').val();
		var suceeded = false;

		jQuery.ajax({
			"url":post_url,
			"data":{	"author" :com_author,
				"email"  :com_email,
				"url"    :com_url,
				"comment":comment,
				"comment_post_ID":com_id
			},
			"success":function(){
				alert("コメントの投稿に成功しました。");
				succeeded = true;
			},
			"error":function(XMLHttpRequest, status, errorThrown){
				if(!succeeded){
					alert("コメントの投稿に失敗しました。");
				}
			},
			"type":"POST"
			}
		);

	});
});