function AjaxList() {
	var _this = this;
	
	var nodes = {};
	var url = '';
	var total = null;
	
	var busy = false;
	var itemCount = 0;
	var _pendingData = '';
	var ajaxComplete = true;
	var friendlyDelayComplete = true;
	var hasStatusLabel = false;
	
	var defaultStatusLabel = '';
	
	function init(root) {
		// Set nodes
		nodes.root = $(root);
		nodes.list = $('.list', nodes.root);
		nodes.loadMore = $('.btnLoadMore', nodes.root);
		nodes.statusLabel = $('.jStatusLabel', nodes.root);
		
		// Set events
		nodes.loadMore.bind('click', onClickLoadMore);
		
		// Misc
		url = nodes.loadMore.attr('href');
		itemCount = nodes.list.children().length;
		
		// See if the total number of items is known
		if(nodes.root.attr('m:total')) {
			total = nodes.root.attr('m:total');
		}
		
		if(nodes.statusLabel.length > 0) {
			hasStatusLabel = true;
			defaultStatusLabel = nodes.statusLabel.text();
		}
	}
	
	function addData() {
		if(!ajaxComplete || !friendlyDelayComplete)
			return;
		
		if($.trim(_pendingData) == '') {
			// Hide load more button
			//nodes.loadMore.parent().detach();
			onLastItem();
		}
		else {
			nodes.list.append(_pendingData);
			
			itemCount = nodes.list.children().length;
			
			if(total !== null && itemCount >= total) {
				onLastItem();
			}
			
			nodes.list.animate({
				height: nodes.list.get(0).scrollHeight
			},
			400,
			'easeOutCubic',
			function() {
				nodes.list.height('');
			});
			

			if(hasStatusLabel) {
				nodes.statusLabel.text(defaultStatusLabel);
			}
			
			// Force redraw for IE
			document.body.className = document.body.className;
		}
		
		busy = false;
	}
	
	function onLastItem() {
		nodes.loadMore.replaceWith('<div class="'+nodes.loadMore.get(0).className+'">Er zijn geen items meer</div>');
	}
	
	function onClickLoadMore(event) {
		event.preventDefault();
		
		if(!busy) {
			busy = true;
			ajaxComplete = false;
			friendlyDelayComplete = false;
			// Fix list current height so we can tween it when the new content is loaded
			nodes.list.height(nodes.list.height());
			if(hasStatusLabel) {
				nodes.statusLabel.text('Laden...');
			}
			
			requestUrl = url.replace(/start=[0-9]+/, 'start='+itemCount);
			$.get(requestUrl, onSuccessLoad);
			setTimeout(onFriendlyDelay, 1000);
		}
	}
	
	function onSuccessLoad(data, textStatus, jqXHR) {
		_pendingData = data;
		ajaxComplete = true;
		addData();
	}
	
	function onFriendlyDelay() {
		friendlyDelayComplete = true;
		addData();
	}
	
	init.apply(this, arguments);
	
	return _this;
}
