﻿
var arrCheckout = new Array();

//--------------------------------------------------------------------------------------------

function AddToCheckout(str)		{ arrCheckout[arrCheckout.length]=str; DrawPaneCart(""); }
function GetFromCheckout(n)		{ return arrCheckout[n]; }
function CountCheckout()		{ return ((onlineShopping) ? arrCheckout.length : 0); }

function RemoveFromCheckout(n,bRedo)	{ arrCheckout.splice(n,1); if(bRedo) DrawPaneCart(pageViewBasket); }

//--------------------------------------------------------------------------------------------

function SummaryCheckout()
{
	var o="";

	if(CountCheckout())
	{
		o=arrCheckout.length+" ";
		o+=(CountCheckout()>1) ? gTxt("items") : gTxt("item");
		o+=" "+gTxt("inbasket");
	}

	return o;
}

//--------------------------------------------------------------------------------------------

function CleanCheckout(page)
{
	while(CountCheckout())
	{
		RemoveFromCheckout(0,false);
	}

	if(page && page.length) DrawPaneCart(page);
}

//--------------------------------------------------------------------------------------------

function SaveTheBasket()
{
	var theBasket="";

	for(var i in arrCheckout) { if(i>0) theBasket+="|"; theBasket+=arrCheckout[i]; }

	$.cookie(COOKIE_BASKET,theBasket,COOKIE_options_day);
	$.cookie(COOKIE_BASKET_AREA,DeliveryArea,COOKIE_options);
}

//--------------------------------------------------------------------------------------------

function LoadTheBasket()
{
	var theBasket=$.cookie(COOKIE_BASKET);
	var da=$.cookie(COOKIE_BASKET_AREA);

	if(da!=null && da.length) DeliveryArea=da;

	if(theBasket && theBasket.length)
	{
		var arr=theBasket.split("|");

		for(var i in arr) arrCheckout[arrCheckout.length]=arr[i];
	}
}

//--------------------------------------------------------------------------------------------


