function comments_submit() {
	d = $('#comments_form').serialize(true);
	$('#comments_form').find('input, textarea').each(function(I_i, I_item){
		$(I_item).attr('disabled', 'disabled');
	});
	$.ajax({
	   type: "POST",
	   url: ('/comments/ajax-submit/'),
	   data: d,
	   success: function(I_r) {
		$('#comments_form').find('.errorlist').hide();
			
		$('#comments_form').find('input, textarea').each(function(I_i, I_item){
			$(I_item).attr('disabled', '');
		});
		r = {};
		try {
			r = eval('(' + I_r + ')');
		} catch (e) {
		}
		if ('error' == r['result']) {
			for (n in r['body']) {
				err = r['body'][n];
				$('#' + n).parent().append(err);
			}
		} else {
			$('#comments_form').find('input[type=text]').each(function(I_i, I_item){
				$(I_item).attr('value', '');
			});
			$('#comments_form').find('textarea').each(function(I_i, I_item){
				I_item.innerHTML = '';
			});
			$('#comments_list').append(r['body']);
		}
	   }
	});
}

$(document).ready(function(){
	$('#comments_form').find('#submit_comment').click(function(){
		comments_submit();
	});
});
