var xmlHTTP = new Array();
var nc = 1;
var hc = 1;

function rotateNewest(){
	if (xmlHTTP[0].readyState == 4 || xmlHTTP[0].readyState == "complete"){
		document.getElementById("newest_items_cell").innerHTML = xmlHTTP[0].responseText;
		window.setTimeout("reloadNewest()", 10000);
	}
}

function rotateHandmade(){
	if (xmlHTTP[1].readyState == 4 || xmlHTTP[1].readyState == "complete"){
		document.getElementById("handmade_items_cell").innerHTML = xmlHTTP[1].responseText;
		window.setTimeout("reloadHandmade()", 10000);
	}
}

function showMarketplaceAdmin(){
	if (xmlHTTP[2].readyState == 4 || xmlHTTP[2].readyState == "complete"){
		document.getElementById("featured_marketplace").innerHTML = xmlHTTP[2].responseText;
	}
}

function reloadNewest(){
	var url = "/marketplace_rotate.php?c=" + nc;
	xmlHTTP[0] = GetXmlHttpObject();
	xmlHTTP[0].onreadystatechange = rotateNewest;
	xmlHTTP[0].open("GET", url, true);
	xmlHTTP[0].send(null);
	return nc++;
}

function reloadHandmade(){
	var url = "/marketplace_rotate.php?mode=handmade&c=" + hc;
	xmlHTTP[1] = GetXmlHttpObject();
	xmlHTTP[1].onreadystatechange = rotateHandmade;
	xmlHTTP[1].open("GET", url, true);
	xmlHTTP[1].send(null);
	return hc++;
}

function callMarketplaceAdmin(redirect){
	var url = "/hp_featured_mp.php?redirect=" + redirect;
	xmlHTTP[2] = GetXmlHttpObject();
	xmlHTTP[2].onreadystatechange = showMarketplaceAdmin;
	xmlHTTP[2].open("GET", url, true);
	xmlHTTP[2].send(null);
}

function initRotation(){
	if (document.getElementById("newest_items_cell")){
		window.setTimeout("reloadNewest()", 10000);
	}
	if (document.getElementById("handmade_items_cell")){
		window.setTimeout("reloadHandmade()", 10000);
	}
}

window.onload = initRotation;