// JavaScript Document
function removeFromCart(cartType, cartItem) {
	var cart = readCookie(cartType);
	var cartItems = null;
	var newCart = "";

	if (cart == null) return false;

	cartItems = cart.split('|');

	for (var i = 0; i < cartItems.length; i++) {
		if (cartItems[i] != cartItem) {
			if (newCart > "") newCart = newCart + "|";
			newCart = newCart + cartItems[i];
		}
	}
	
	if (newCart > "")
		createCookie(cartType, newCart, 365);
	else
		eraseCookie(cartType);
	
	if (document.getElementById("btn.CheckOut") != null)
		document.location.href = "shop?cmd=viewCart";
	else {
		ajaxRefreshCart();
	}
}

function clearCart(askConfirm) {
	
	if (askConfirm == null || askConfirm != false) {
		if (!confirm("Clear all items from your Shopping Cart?")) return;
	}
	
	createCookie("cdcart", "", -1);
	createCookie("cart", "", -1);
	createCookie("subcart", "", -1);
	
	if (document.getElementById("btn.CheckOut") != null)
		document.location.href = "shop?cmd=viewCart";
	else {
		ajaxRefreshCart();
	}
}