var pList,pCursorOut;
var currentPage=0;

$(document).ready(function() {
	pList=$('.product-listing-small ul li');
});

function goPage(inc) {
	currentPage+=inc;
	pCursorOut=0;
	setTimeout('fadeOut()',10);
	$.ajax({
		type: "POST",
		url: "home_products_list_new.php",
		dataType: "xml",
		data: "page="+currentPage,
		success: loadPage
	});
}

function loadPage(data) {
	var products=data.getElementsByTagName("product");
	for (var i=0;i<pList.length;i++) {
		if (products[i]) $(pList.get(i)).html(products[i].childNodes[0].nodeValue);
		else $(pList.get(i)).html("");
	}
}

function fadeOut() {
	$(pList.get(pCursorOut)).html('<img class="ajax-load" src="images/ajax-loader.gif" />');
	pCursorOut++;
	if (pCursorOut<pList.length) setTimeout('fadeOut()',10);
}
