function submitComment() {
	url = "/post_comment.php";
	var ajaxRequest = new Ajax.Request(url, {
    method:       'post', 
    parameters:   $('comment_form').serialize(true),
    asynchronous: true,
    onSuccess:   function(transport) {
    		parseResponse(transport.responseText);
    		
    		
    	}
	});
}

function parseResponse(response) {
   responseArr = response.split("|");

   if (responseArr[0] == 'Error') {
   		$('formError').show();
   		$('formSuccess').hide();
   		$('formError').innerHTML = responseArr[1];
   } else {
   		$('formError').hide();
   		$('formSuccess').show();
   		$('formSuccess').innerHTML = responseArr[1];
   		updateComments();
    	resetCaptcha();
    	resetForm();
   }
}


function updateComments() {
	url = "/update_comments.ajax.php";
	var ajaxRequest = new Ajax.Request(url, {
    method:       'post', 
    parameters:   $('comment_form').serialize(true),
    asynchronous: true,
    onSuccess:   function(transport) {
    		$('comments').innerHTML = transport.responseText;
    	}
	});
}

function resetCaptcha() {
	Recaptcha.create("6Ld7qQQAAAAAAFssby3_OADyCb25yJUW6s7ysKeq",
		"mycaptcha", {
   		theme: "red",
   		callback: Recaptcha.focus_response_field
	});

}

function resetForm() {
	$('comment').clear();
	$('author_name').clear();
	$('author_email').clear();
}