function bindGetMoreCommentsEvent()
{
	// subject > showSuccess > debate _view > load more comments (append children)
	$('#commentloader').click(function() {
		var debate_id = $('#commentload_debate_id').val();
		var limit = parseInt($('#commentload_limit').val())
		var offset = parseInt($('#commentload_offset').val());
		var total = parseInt($('#commentload_total').val());
		if (offset < total)
			var newoffset = limit + offset;
		else
			$(this).css('display', 'none');
		
		//alert ("total/limit/offset/newoffset: " + total + "/" + limit + "/" + offset + "/" + newoffset + ".");
		
		if (debate_id && offset) {
			// loader icon is inside commentloader link
			$(this).attr('class', 'commentloader_loading');
			$.get($('#commentloaderform').attr('action'),
				{ id: debate_id, offset: offset, total: total },
				function(data) {
					$('#comments_list').append(data);
					$('#commentload_offset').val(newoffset);
					$('#commentloader').attr('class', 'commentloader');
				});
		}
	});
}

$(document).ready(function()
{
	bindGetMoreCommentsEvent();
});
