var httpreq = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();

function init() {
	showslide(0);
}

function showslide(index){
	if (!document.images || !document.images.slide || typeof(slides) == "undefined" || slides.length == 0)
		return;
	if (index >= slides.length)
		index = 0;
	document.images.slide.src = "flash_images/" + slides[index];
	setTimeout("showslide(" + (index + 1) + ")", slidedelay);
}

function pickitem() {
	httpreq.open('POST',"AddItem.php", false);
	httpreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	var formdata = "style=" + document.pickform.ShoeStyle.value 
		+ "&color=" + document.pickform.ShoeColor.value 
		+ "&size=" + document.pickform.ShoeSize.value 
		+ "&width=" + document.pickform.ShoeWidth.value 
		+ "&qty=" + document.pickform.ItemQty.value;
	httpreq.send(formdata);
	var count = httpreq.responseText.replace(/\D/g, "");
	document.getElementById("itemcount").innerHTML = "(" + count + ")";
}

function removeitem(itemindex) {
	httpreq.open('POST',"RemoveItem.php", false);
	httpreq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	httpreq.send("item=" + itemindex);
	location.reload(true);
}

function checkout() {
	document.getElementById("itemcount").innerHTML.match(/\(\d+\)/);
	var count = eval(RegExp.$1);
	if (count == 0) {
		alert("No items in cart.");
		return;
	}
	document.location = "checkout.php";
}
