function shplst_updateList() {
	var updatedCookie = $.cookie("shoppingList");
	
	if (updatedCookie == '' || updatedCookie == null)
		{
		$("#shoppingList").html("<p>Currently there are no items in your shopping list. Please select products on the left to add them to your list.</p>");
		$("#clearList").css("display","none");	
		}
		else
		{
		var newShoppingListItems=updatedCookie.split("+|+");
		
		//alert( newShoppingListItems[0] );
		$("#shoppingList").html("<ol class=\"theList\"></ol>");
		for(var i=0; i < newShoppingListItems.length; i++)
			{
			$("#shoppingList ol.theList").append("<li>" + newShoppingListItems[i] + "</li>");
			}
		
		$("#clearList").css("display","block");
		}
}

function shplst_add(evt) {
	
	var currContents = $.cookie("shoppingList");
	var updatedContents;
	var chosenItem = $(this).attr("rel");
	if (currContents != "" && currContents != null )
		{
		updatedContents	= currContents + "+|+" + chosenItem; 
		}
		else
		{
		updatedContents	= chosenItem; 	
		}
	
	$.cookie("shoppingList", updatedContents);
	
	shplst_updateList();
	
	evt.preventDefault();
}
function shplist_clearList() {
		$.cookie("shoppingList","");
		shplst_updateList();
}
function shplst_setUpAddBtns() {
	$(".addItem").bind("click",shplst_add);
	$("#clearList a").bind("click",shplist_clearList);
}
$("document").ready(shplst_setUpAddBtns);
