$(function() {
	//ajax example
	//$.post('?test', {email:'email',user:'user'}, function(response) {
	//	alert(response);
	//});
	
	//ajax example
	//$.get('?get_featured_rant', function(response) {
		//alert(response);
	//});
	
	//each example
	//$("#frm_manage_users input[@type=checkbox]").each(function(){
		//alert($(this).val());
	//});
	
	$("#submit-comment").click(SubmitComment);
	$(".more-comments").click(MoreComments);
})

function MoreComments(){
	var item_id = $(this).attr("id").substr(9);
	
	var item_pos = $("#comments .item").length;
	
	$.post(HTTP + 'ajax?more-comments', {id:item_id,pos:item_pos}, function(response) {
		if(response['status'] == 1){
			//parse comments at the bottom of listing
			$("#comments").append(response['result']);
			
			//hide view more button if there are no more comments
			if(response['button'] == '')
				$(".more-comments").hide();
		}
	}, 'json');		
}

function SubmitComment(){
	$.post(HTTP + 'ajax?add-comment', $("#formAddComment").serialize(), function(response) {
		alert(response['error']);
		if(response['status'] == 1){
			//add comment
			$("#comments").prepend(response['comment']);
			$.scrollTo( $("#comments .item:first"), 800);
			
			//clear form values
			$("#description").val("");
			$("#number").val("");
		}
		
		Recaptcha.reload();

	}, 'json');		
}
