/**
 * 
 */
var url_base = location.protocol + '//' + location.hostname;

function checkTextarea(){
	$('#comment-captcha-div').show('slow');
}

function processComment() {
	showPreloader('comment-block');

	$.ajax({
		url: url_base + '/post/comment',
		data: $('#comment-form').serialize() + '&date_timestamp='+new Date().getTime(),
        complete: function(res) {
        	var aResponse = $.parseJSON(res.responseText);
        	$('#comment-block').html(aResponse.content);
            
            hidePreloader();
            $('#comment-captcha-id').val('');
            
            if (aResponse.valid == true) {
            	$('#comment_nickname').val('');
            	$('#comment_text').val('');
            	//$('#comment-captcha-id').val('');
            	
            	processCommentList();
            }
        }
    });

	return true;
}

function processCommentList() {
	showPreloader('comment-list');
	
	$('#comment-list').load(	
		url_base + '/post/commentList',
		{ post_id: $('#comment_post_id').val() },
		function() { 
			hidePreloader();
			
			$('#comment-list a[rel!=noajax]').each(function(i) {
		        $(this).attr('href', '#' + $(this).attr('href'));
		    });
		}
	);

	return true;
}


