//***************************************************
//***** CODE COPYRIGHT PRACTICAL DATA, INC 2004 *****
//***** - USE WITHOUT PERMISSION IS PROHIBITED ******
//***************************************************
function getCookie(cookieName) {
	var allCookies = document.cookie;
	var cookieStart = allCookies.indexOf(cookieName)
	if(cookieStart == -1) return "";
	cookieStart = cookieStart + cookieName.length + 1;
	var cookieEnd = allCookies.indexOf(";", cookieStart);
	if(cookieEnd == -1) cookieEnd = allCookies.length;
	var cookieValue = allCookies.substring(cookieStart, cookieEnd);
	return cookieValue;
}

function getShoppingCart() {
	var storeCode = getStoreCode();
	var cartCookieInfoName = "pdsc_" + storeCode + "_info";
	var cartCookieName = "pdsc_" + storeCode + "_";
	var shoppingCart = new Object();
	shoppingCart.products = new Array();
	var pd_shoppingCartInfo = getCookie(cartCookieInfoName);
	var cookieValue = "";
	for(var i=0;i<pd_shoppingCartInfo;i++) {
		cookieValue += getCookie(cartCookieName + i);
	}
	cookieValue = unescape(cookieValue);
	try {
		if(cookieValue.length > 10)	eval(cookieValue);
	} catch(e) {
		//alert(cookieValue);
	}
	shoppingCart.subtotal = 0;
	if(shoppingCart.products) {
		for(var i=0;i<shoppingCart.products.length;i++) {
			shoppingCart.subtotal+= (shoppingCart.products[i].price * shoppingCart.products[i].qty); 
		}
	}
	return shoppingCart;
}

function getCurrentPagePath() {
	var url = String(location);
	url = url.replace("http://", "");
	var slashIndex = url.lastIndexOf("/");
	if(slashIndex == -1) slashIndex = url.length;
	var pagePath = url.substring(0, slashIndex);
	return pagePath;
}