var $comment_sent = 0;
	
function showIt(data) {
    $("#comments_input_added").hide();    
    $("#comment").val('');
    $("#comments_input").fadeIn();
	$comment_sent = 0;    
}

function return_comments() {
    $("#post_comment").livequery('click', function() {
    	if ($comment_sent == 0) {
            $comment_sent = 1;
	        $hash = $("#hash").val();
	        $comment = $("#comment").val();
	        $code = $("#code").val();
	        
	        $uri = $("#uri").val();
	        $.post($uri+"?ajax=gc&hash="+$hash, {comment: $comment, code: $code}, function(data){
	            $comment = (data.indexOf("error_comment"));
	            $captcha = (data.indexOf("error_captcha"));
	            if (($comment < 0) && ($captcha < 0)) {
	                $('#comments_holder').attr('innerHTML', data);
	                $("#comments_input").hide();
	                $("#comments_input_added").show();
	                setTimeout("showIt()",2000);
	            }
	        });
	        return false;
    	} else {
    		return false;
    	}
    });
    
    $("#comments_holder > .comment > .commentHead > .commentUser > *").livequery('click', function() {
        if ($(this).attr('href') == 'del') {
            $hash = $("#hash").val();
            $uri = $("#uri").val();
            
            $comment_id = $(this).attr('id');
            $('#comments_holder').load($uri+"?ajax=gc&del=1&hash="+$hash+"&id="+$(this).attr('id'));
            return false;
        } else {
            return true;
        }
    });
    
}

$(document).ready(function(){
    return_comments();
});