/*---------------------------------
*									
* 	LOADER ELEMENT (arguments list)			
*							
*	container = div to reset load buttons		
*	parentItem = container item		
*	itemCopy = div to copy			
*	buttonType (a#infoLoadMore) long / (a#subLoadMore) short
*	ajaxUrl = url to send data to
*
---------------------------------*/		

function loadMore(container, parentItem, itemCopy, buttonType, ajaxUrl) { 
	$('.loadStatus').show();

	var lastId = $(itemCopy+':last').attr('id');
	/* alert(lastId); */
	
	$.ajax({
		type: 		"POST",
		cache: 		false,
		url: 		ajaxUrl,
		dataType:	'html',
		data: 		"lastId="+lastId,
		
		error: function() { 
			$(buttonType).text('Loading error - please try again');
			$(buttonType).attr('title', 'Loading error - please try again');
		},
		
		success: function(data) {
			if (data == 0) { 
				$(buttonType).text('No more posts to display');
				$('.loadStatus').hide();
				$(buttonType).delay(800).fadeOut();
			} else { 
				$(data).appendTo(parentItem);
				$('.loadStatus').hide(900).appendTo(container);
				$('.appendItem').hide();
                $(".appendItem").animate({"height": "toggle", "opacity": "toggle"}, "slow");
                $(itemCopy).removeClass('appendItem');

				$(buttonType).appendTo(container);
			}
		}
	});
}
