function bindGetMoreProfileCommentsEvent()
{
	// user > profileSuccess > load more comments (append children)
	$('#profilecommentloader').click(function() {
		var user_id = $('#profilecommentload_user_id').val();
		var limit = parseInt($('#profilecommentload_limit').val())
		var offset = parseInt($('#profilecommentload_offset').val());
		var total = parseInt($('#profilecommentload_total').val());
		if (offset < total)
			var newoffset = limit + offset;
		else
			$(this).css('display', 'none');
		
		//alert ("total/limit/offset/newoffset: " + total + "/" + limit + "/" + offset + "/" + newoffset + ".");
		
		if (user_id && offset) {
			// loader icon is inside commentloader link
			$(this).attr('class', 'commentloader_loading');
			$.get($('#profilecommentloaderform').attr('action'),
				{ id: user_id, offset: offset, total: total },
				function(data) {
					$('#profilecomments_list').append(data);
					$('#profilecommentload_offset').val(newoffset);
					$('#profilecommentloader').attr('class', 'commentloader');
				});
		}
	});
}

function bindGetMoreProfileArticlesEvent()
{
	// user > profileSuccess > load more comments (append children)
	$('#profilearticleloader').click(function() {
		var user_id = $('#profilearticleload_user_id').val();
		var limit = parseInt($('#profilearticleload_limit').val())
		var offset = parseInt($('#profilearticleload_offset').val());
		var total = parseInt($('#profilearticleload_total').val());
		if (offset < total)
			var newoffset = limit + offset;
		else
			$(this).css('display', 'none');
		
		//alert ("total/limit/offset/newoffset: " + total + "/" + limit + "/" + offset + "/" + newoffset + ".");
		
		if (user_id && offset) {
			// loader icon is inside articleloader link
			$(this).attr('class', 'commentloader_loading');
			$.get($('#profilearticleloaderform').attr('action'),
				{ id: user_id, offset: offset, total: total },
				function(data) {
					$('#profilearticles_list').append(data);
					$('#profilearticleload_offset').val(newoffset);
					$('#profilearticleloader').attr('class', 'commentloader');
				});
		}
	});
}

$(document).ready(function()
{
	bindGetMoreProfileCommentsEvent();
	bindGetMoreProfileArticlesEvent();
});
