/* list center -- start */
var listNameArray=new Array();
var listIdArray=new Array();
var wishListNameArray=new Array();
var wishListIdArray=new Array();
var checkShowNewList="false";

// function to show create new list div
function createNewListModalHeader()
{
	checkShowNewList = "true";
	var windowHeight = ($(window).height() / 2) + $(window).scrollTop() - 105; //positioning the modal
	var windowWidth = ($(window).width() / 2) - 225;
	$('body').append('<div class="newListModalShadow"></div><div id="newListModal"></div>');
	$('.newListModalShadow').css({'top':windowHeight,'left':windowWidth, 'filter':'alpha(opacity=50)','; -moz-opacity': '0.5','opacity': '0.5'});
	$('#newListModal').css({'top':windowHeight+5,'left':windowWidth+5});
	if(requestType == 'https')
		$("#newListModal").load('CreateNewListViewHttps?fromHeader=true&storeId='+storeID+'&catalogId='+catalogID); //load html
	else
		$("#newListModal").load('CreateNewListView?fromHeader=true&storeId='+storeID+'&catalogId='+catalogID); //load html
}
// createNewWishListModalHeader
function createNewWishListModalHeader()
{
	var windowHeight = ($(window).height() / 2) + $(window).scrollTop() - 105; //positioning the modal
	var windowWidth = ($(window).width() / 2) - 225;
	$('body').append('<div class="newListModalShadow"></div><div id="newListModal"></div>');
	$('.newListModalShadow').css({'top':windowHeight,'left':windowWidth, 'filter':'alpha(opacity=50)','; -moz-opacity': '0.5','opacity': '0.5'});
	$('#newListModal').css({'top':windowHeight+5,'left':windowWidth+5});
	if(requestType == 'https')
		$("#newListModal").load('CreateNewListViewHttps?fromHeader=true&storeId='+storeID+'&catalogId='+catalogID+'&listType=wishlist'); //load html
	else
		$("#newListModal").load('CreateNewListView?fromHeader=true&storeId='+storeID+'&catalogId='+catalogID+'&listType=wishlist'); //load html
}

/*add shopping list start*/
function addShoppingList()
{
	var listName=document.getElementById("newShoppingListHeader").value;
	var listName = $.trim(listName);
	var validateStatus=fnListNameValidate(listName);
	if(validateStatus==false)
	{
		return false;
	}
	var newListName=listName;
	listName=encodeURIComponent(listName);
	if(requestType=='https')
	{
		var url="AddShoppingListCmdHttps?storeId="+storeID+"&catalogId="+catalogID+"&newShoppingListName="+listName+"&listType=shoppingList";
	}
	else if(requestType=='http')
	{
		var url="AddShoppingListCmd?storeId="+storeID+"&catalogId="+catalogID+"&newShoppingListName="+listName+"&listType=shoppingList";
	}
	if(checkMychoice == 'true'){
		ajaxCall(url,'addShoppingListView',0,newListName);
	}
	else
		ajaxCall(url,'addshoppingListDisplay',0,newListName);
	closeModal();
}
/*addShoppingList end*/

/*add wish list start*/
function addWishList()
{
	var listName=document.getElementById("newShoppingListHeader").value;
	var listName = $.trim(listName);
	var validateStatus=fnListNameValidate(listName);
	if(validateStatus==false)
	{
		return false;
	}
	var newListName=listName;
	listName=encodeURIComponent(listName);
	if(requestType=='https')
	{
		var url="AddShoppingListCmdHttps?storeId="+storeID+"&catalogId="+catalogID+"&newWishListName="+listName+"&listType=wishlist";
	}
	else if(requestType=='http')
	{
		var url="AddShoppingListCmd?storeId="+storeID+"&catalogId="+catalogID+"&newWishListName="+listName+"&listType=wishlist";
	}
	ajaxCall(url,'addWishListView',0,newListName);
	closeModal();
}

function addWishListView(request,listName)
{
	var url="ShoppingListSortCmd?catalogId="+catalogID+"&storeId="+storeID+"&listType=wishlist&listDesc="+listName;
	location.href=url;
}

function addShoppingListView(request,listName)
{
	var url="ShoppingListSortCmd?catalogId="+catalogID+"&storeId="+storeID+"&listType=shoppingList&listDesc="+listName;
	location.href=url;
}
/*function to get list names from cookie*/
function getListNames()
{
	var flag =1;
	var userIdFromCookie=getUserIdFromCookie;
	var SListFromCookie=getCookie('MyGoferShoppingListCookie_'+storeID+'_'+userIdFromCookie);
	var val1;
	var val2;
	var flagChar = true;
	if (SListFromCookie != null && SListFromCookie !== ''){	
		var	len = SListFromCookie.length;	
		val1 = SListFromCookie;
		if (val1.indexOf("") != -1){
			flagChar = false;
		}
		for(var i=0;i <SListFromCookie.length; i++){									
			val1 = val1.replace("", "~*#");
			if (val1.indexOf("") == -1) {
				break;
			}		
		}	
			SListFromCookie=val1;
	}
		
	if (flagChar && SListFromCookie != null && SListFromCookie !== ''){				
		val2 = SListFromCookie;
		if (val2.indexOf("~*#") == -1){
			val2 = val2.replace(/~/g, "~*#");	
		}									
		SListFromCookie=val2;
	}
	if(SListFromCookie=="\"\"")
    				SListFromCookie='';
	SListFromCookie = SListFromCookie + '~*#';
	var	len = SListFromCookie.length;
	len = len - 0;
	var i=0
	while(SListFromCookie.length > 1 && flag != 0)
	{
		len = SListFromCookie.length - 0;
		SListFromCookie = SListFromCookie.substring(3,len);
		if( SListFromCookie.indexOf(':') )
		{
			listIdArray[i] = SListFromCookie.substring(0,SListFromCookie.indexOf(':'));
			SListFromCookie = SListFromCookie.substring(SListFromCookie.indexOf(':'),len);
			listNameArray[i] = SListFromCookie.substring(1,SListFromCookie.indexOf('~*#'));
			SListFromCookie = SListFromCookie.substring(SListFromCookie.indexOf('~*#'),len);
		}
		i++;
	}
}

function getWishListNames()  
{
	var flag =1;
	var userIdFromCookie=getUserIdFromCookie;
	
	var SListFromCookie;
	SListFromCookie=getCookie('MyGoferWishListCookie_'+storeID+'_'+userIdFromCookie);
	var val1;
	var val2;
	var flagChar = true;
	if (SListFromCookie != null && SListFromCookie !== ''){	
		var	len = SListFromCookie.length;	
		val1 = SListFromCookie;
		if (val1.indexOf("") != -1){
			flagChar = false;
		}
		for(var i=0;i <SListFromCookie.length; i++){									
			val1 = val1.replace("", "~*#");
			if (val1.indexOf("") == -1) {
				break;
			}		
		}	
			SListFromCookie=val1;
	}
		
	if (flagChar && SListFromCookie != null && SListFromCookie !== ''){				
		val2 = SListFromCookie;
		if (val2.indexOf("~*#") == -1){
		val2 = val2.replace(/~/g, "~*#");										
		}
		SListFromCookie=val2;
	}
	if(SListFromCookie=="\"\"")   
    				SListFromCookie='';
	SListFromCookie = SListFromCookie + '~*#';
	var	len = SListFromCookie.length;
	len = len - 0;
	var i=0
	while(SListFromCookie.length > 1 && flag != 0)
	{
		len = SListFromCookie.length - 0;
		SListFromCookie = SListFromCookie.substring(3,len); 
		if( SListFromCookie.indexOf(':') )
		{
			wishListIdArray[i] = SListFromCookie.substring(0,SListFromCookie.indexOf(':'));
			SListFromCookie = SListFromCookie.substring(SListFromCookie.indexOf(':'),len);
			wishListNameArray[i] = SListFromCookie.substring(1,SListFromCookie.indexOf('~*#'));
			SListFromCookie = SListFromCookie.substring(SListFromCookie.indexOf('~*#'),len);
		}
		i++;
	}
}
// display shopping lists
function addshoppingListDisplay(responseText,listName)
{
	if(listName!="")
	{
		fnUpdateListCenter(listName);
	}
	getListNames();
	var listId='';
	var listDesc = '';
	var shoppingListContents='<dt>Shopping Lists</dt>';
		
	for(i=0;i<listIdArray.length;i++)
	{

		listId = listIdArray[i];
		listDesc = listNameArray[i];
		listDesc = listDesc.replace(/&#58/g,":");
		listDesc = listDesc.replace(/&#59/g,";");
		listDesc = listDesc.replace(/&#60/g,"<");
		listDesc = listDesc.replace(/&#61/g,"=");
		listDesc = listDesc.replace(/&#62/g,">");
		var listDisplayName = listDesc;
		if(listDisplayName.length > 15)
		{
			listDisplayName = listDisplayName.substring(0, 15) + "...." ;
		}
		
		shoppingListContents =shoppingListContents + '<dd><a href="ShoppingListSortCmd?catalogId='+catalogID+'&storeId='+storeID+'&listId='+ listId + '&listName=' + listDesc + '&listType=shoppingList" title="View My '+listDisplayName+' list ">'+listDisplayName+'</a></dd>';
	
	}
	var cnstShopping="Create a New Shopping List ";
	if(checkMychoice == 'true')
		shoppingListContents+='<dd><a class="newList" href="##" onclick="createNewListModalHeader();" title="Create New List">'+cnstShopping+'</a></dd>';	
	else
		shoppingListContents+='<dd><a class="newList" href="##" onclick="createNewListModalHeader();" title="Create New List">Create new list </a></dd>';	
	document.getElementById("existingLists").innerHTML="";
	document.getElementById("existingLists").innerHTML=shoppingListContents;								
}

function addwishListDisplay(responseText,listName)  
{
	if(listName!="")
	{
		fnUpdateListCenter(listName); 
	}
	getWishListNames();
	var listId='';
	var listDesc = '';

	var shoppingListContents='<dt>Wish Lists</dt>';
	for(i=0;i<wishListIdArray.length;i++)
	{
		listId = wishListIdArray[i];
		listDesc = wishListNameArray[i];
		listDesc = listDesc.replace(/&#58/g,":");
		listDesc = listDesc.replace(/&#59/g,";");   
		listDesc = listDesc.replace(/&#60/g,"<");
		listDesc = listDesc.replace(/&#61/g,"=");
		listDesc = listDesc.replace(/&#62/g,">");
		var listDisplayName = listDesc; 
		if(listDisplayName.length > 15)  
		{
			listDisplayName = listDisplayName.substring(0, 15) + "...." ;
		}
		shoppingListContents =shoppingListContents + '<dd><a href="ShoppingListSortCmd?catalogId='+catalogID+'&storeId='+storeID+'&listId='+ listId + '&listName=' + listDesc + '&listType=wishlist" title="View My '+listDisplayName+' list ">'+listDisplayName+'</a></dd>';
	
	}
	shoppingListContents+='<dd><a class="newList" href="##" onclick="createNewWishListModalHeader();" title="Create a new List">Create new Wish List </a></dd>';	
	document.getElementById("existingWishLists").innerHTML="";
	document.getElementById("existingWishLists").innerHTML=shoppingListContents;								
}
/****************************************************************************
* code for list Center page updation
****************************************************************************/
function fnUpdateListCenter(listName){
	var listCenter=pageCheck;
	var listNameNew=listName
	listName=encodeURIComponent(listName);
	if(listCenter!=null && listCenter!=""){
		var url="";
		if(listCenter=="ListCenterHome")
		{	arrArr[arrArr.length]=listNameNew;
			url="ListCenterListView?storeId="+storeID+"&catalogId="+catalogID+"&listDisplaySize=6&newShoppingListName="+listName;
			ajaxCall(url,'afterListCenterList');
		}
		else if(listCenter=="ShoppingListPage" || listCenter=="StarterListPage" || listCenter=="ItemHistoryPage")
		{
			arrArr[arrArr.length]=listNameNew;
			url="CopyTolistView?storeId="+storeID+"&catalogId="+catalogID;
			ajaxCall(url,'afterCopyList');
			if(listCenter=="ShoppingListPage"){
				var selList = $('.list-selector select option:selected').attr('text');
				url="ListCenterListView?storeId="+storeID+"&catalogId="+catalogID+"&newShoppingListName="+selList;
				ajaxCall(url,'afterShoppingList');
	  			document.getElementById("errorMessageOrderInformation").style.display ="none";	
			}
		}
		
	}
	
}
/****************************************************************************
* code for list Center page updation-- after ajax calls
****************************************************************************/
function afterListCenterList(responseText)
{
	if(listType == 'wishlist')
		$("#wishListPromo").html(responseText);
	else	
		$("#shoppingListPromo").html(responseText);
}

function afterShoppingList(responseText)
{
	document.getElementById("shoppingListPromo").innerHTML=responseText;
}

function afterCopyList(responseText)
{
	document.getElementById("CopyListPromo").innerHTML=responseText; 
	document.getElementById("CopyListPromoBottom").innerHTML=responseText;
}
/****************************************************************************
* end of----code for list Center page updation
****************************************************************************/
/*new list name validation*/
 function fnListNameValidate(listName)
  {
  	getListNames();
  	document.getElementById("listErrorMsgHeader").style.display = "none";
  	if(isEmpty(listName) == 0)
	{  
	   document.getElementById("listErrorMsgHeader").style.display = "block";
	   document.getElementById("listErrorMsgHeader").innerHTML = "Please enter a name for your Shopping List";
		return false;
	}
	
	for (var i=0; i<listNameArray.length; i++)
	{   
		 var dbValue=listNameArray[i].replace(/\s/g,"");
	     var newValue=listName.replace(/\s/g,"");
		 if( (dbValue.toLowerCase()) == (newValue.toLowerCase())){
		   document.getElementById("listErrorMsgHeader").style.display = "block";
		   document.getElementById("listErrorMsgHeader").innerHTML = "This Shopping List already exist.Please enter another name for your new Shopping List";
			return false;
		}
	}
  }
  
function fnStarterListDetailsSelect(starterCount)
{
   	var catalogId = catalogID;
   	var storeId = storeID;
   	var subCategory = document.getElementById("starterListsName_"+starterCount).value;
   	var stList = subCategory.split(" ");
   	var subCat="";
   	var flag = false;
   	for(var i=0;i<stList.length;i++){
   		if(flag){
   			subCat = subCat+"+";
	   		subCat = subCat+stList[i];
	   	}
   		else{
   			subCat = subCat+stList[i];
   			flag = true;
   		}
   	}
   	var url = dynamicCategoryUrl+"/slc_"+storeId+"_"+catalogId+"_"+starterListCategory+"_"+subCat+"_true";
   	location.href=url;
}


/* For Quickshop Start */

	
function ismaxlength(obj){
			var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
			if (obj.getAttribute && obj.value.length>mlength)
			obj.value=obj.value.substring(0,mlength)
		}

function getCookie(cookieName)
	{
	var cookieArray = document.cookie.split("; ");
	var searchString = cookieName+"=";
	var returnValue = '';
	for(var index = 0; index < cookieArray.length ; index++)
	{
		var cookie = cookieArray[index];
		var position = cookie.indexOf(searchString);

		if(position == 0)
		{
			var name_value = cookie.split("=");
			

			if(name_value[1] != '')
			{
					returnValue = name_value[1];
			}
			else
			{
				returnValue = '';
			}

		}
	}
	return returnValue;
}

//Sets a cookie in the session based on the cookiename and cookievalue
		
function setCookie(cookieName,cookieValue,path)
{
	
	if(null!=path)
	{
		document.cookie = cookieName + "=" + cookieValue + ";path="+path+";";
    }
    else
    {
    	document.cookie = cookieName + "=" + cookieValue + ";";
	}
}
function setCookieWithExpiry( name, value, expires, path, domain, secure ) 
	{
		// set time, it's in milliseconds
		var today = new Date();
		today.setTime( today.getTime() );
		
		/*
		if the expires variable is set, make the correct 
		expires time, the current script below will set 
		it for x number of days, to make it for hours, 
		delete * 24, for minutes, delete * 60 * 24
		*/
		if ( expires )
		{
		expires = expires * 1000 * 60 * 60 * 24;
		}
		var expires_date = new Date( today.getTime() + (expires) );
		
		document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
	}
	
function callQuickShopSearch(qsSearchStr, qsIndex, element) {
	if(element=="true")
		{
			
			var qsStr = escape(qsSearchStr);
			if(qsStr != null) {
				qsStr = qsStr.replace(/^\s+/,"");
				qsStr = qsStr.replace(/\s+$/,"");
			}
			 location.href = search_quickshop_url+"/qs_"+storeId+"_"+catalogId+"?keyword="+ qsStr+"&qsMode=search&qsi="+qsIndex+"&selectedQSIndex="+qsIndex;
		}
		}

/* For Quickshop End  */	


/* For SmartCart start  */
 /* smart cart code change starts*/
  var smartCartListEntries="";
 var rowIndicator = null;
 function enableSource(inputSource){
        inpSource = inputSource ;
   }
   
     
   /* changing the trim function as it was conflicting in checkout pages*/
 function trim_sc(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
   	var spuOnlyKSNListSC="";
 function genksnSCSpuLists() {
  		spuOnlyKSNListSC="";
	 
		for(i=0;i<smartCartListEntries.ksnvalues.length;i++)
		{	
			var catentId = smartCartListEntries.ksnvalues[i].catEntry;
			if(smartCartListEntries.ksnvalues[i].storePickUpOnly == "true")
			{
				spuOnlyKSNListSC=spuOnlyKSNListSC+"|"+smartCartListEntries.ksnvalues[i].ksn;
			}
			
		}
	}
	  	//Function for ajax call containing SPU only list and SPU eligible list
function changeSCStorePriceAvl() 
	{
	   	    var selectedStoreValue=$.cookie('selectedStore');
			genksnSCSpuLists();
			//When any store is selected for SPU only items
			if("" != spuOnlyKSNListSC && selectedStoreValue != null)
			{  
				request=$.getJSON('PageRefreshCmd?spuOnlyKSNList='+spuOnlyKSNListSC+'&spuEligKSNList=&rtiFlag=noRTI&storeId='+storeId,showResponseSC);  
				 
			}
			else {
				showResponseSC();
			}
		
	}
function showResponseSC(jsonResponse) 
	{	   
			var selectedStoreValue=$.cookie('selectedStore');
			if("" != spuOnlyKSNListSC  &&  selectedStoreValue != null ){	
			
			for(i=0;i<jsonResponse.jsonRegPriceAvi.price.length;i++)
			{	
				for(j=0;j<smartCartListEntries.ksnvalues.length;j++)
				{
					if(jsonResponse.jsonRegPriceAvi.price[i].pId == smartCartListEntries.ksnvalues[j].ksn)
					{   
					
					if("" != jsonResponse.jsonRegPriceAvi.price[i].rpr){					
							smartCartListEntries.ksnvalues[j].price = jsonResponse.jsonRegPriceAvi.price[i].rpr;
						}
						
					}
				}
			}
		}
		
		for(i=0;i<smartCartListEntries.ksnvalues.length;i++)
		{
			var catentId = smartCartListEntries.ksnvalues[i].catEntry;
			document.getElementById('sstory_'+i).innerHTML=	smartCartListEntries.ksnvalues[i].price;
			
		
		}		
	 
	}  	
       
function checkState_sc(forwardView)
        {    
        			checkShowCart = 'true';
        			if(disableCartLink=='true')
	  				{
	  					var message = jQuery('#emptyCart #message');
						//var originalMessage = "Cart qualifies for <em>Free Delivery</em>.";
	
						message.fadeTo(750, 0.00, function() {		// fade out original message
							message.html('Cart is Empty');	// change text
							message.addClass('exclamation'); 
							
							message.fadeTo(750, 1.0);	// fade message in
							message.animate({opacity: 1.0}, 1000);  // "pausing" message
							message.fadeTo(750, 0.0, function() {	// fade message out
								if(originalMessage == '')
								{
									message.removeClass('exclamation'); 
								}
								message.html(originalMessage);	// put original message back with HTML in tact
								message.fadeTo(750, 1.0);	// fade message in
								
							});
						});
	  					
	  					return false;
	  				}
                    loadingCart();
                    ajaxCall(forwardView,'showSmartCart');
                }
                	
function showSmartCart(value) 
        {
            document.getElementById("itemsInSmartCart").innerHTML = value;
            if(value.indexOf("Your session has timed out. Please login again to view your cart details.")!=-1){
               
                var redirectURL=window.location.href;
                redirectURL=redirectURL.substring(redirectURL.indexOf("shc/s/")+6);
                setCookie("redirectionURLCookie",escape(redirectURL));
                setCookie("redirectionStoreInfoCookie",registerStoreId+"~"+registerCatalogId);
                var url= "LogonFormView?storeId="+registerStoreId+"&catalogId="+registerCatalogId; 
                window.location=url;
            }
	  		var smartcartList =document.getElementById("masterVectorvalues").value;
	  	    smartCartListEntries= eval('(' + smartcartList + ')');
	  		
	  		changeSCStorePriceAvl();
           	showNewFullCart();
            enableActions();
           	//alternateRows();
        }
          var isZero = "false";
function updateQuantity(updateString, quantity) 
        {   
            var lv_pattern = /^[0-9]+$/;
            var passed = lv_pattern.test(quantity);
            if (!passed) {
                message("We're sorry, the value in the quantity field is not valid. The value must be numeric. Please enter a numeric value and try again.",'error');
                jQuery(rowIndicator).parent().find("input[@id=itemQuantity01]").val(document.getElementById("oldQty").value);
            }
            else {
                if(quantity == 0) 
                {
                    isZero = "true";
                }
                var cmdUrl = updateString + "&quantity_1=" +quantity;
                disableActions();
                ajaxCall(cmdUrl,'testUpdate');
            }       
        }
function testUpdate(value)
        {  
            document.getElementById("smartcartresponse").innerHTML=value;
            var status=document.smartcartresponseform.status.value;
            var updateFail=document.smartcartresponseform.updateFail.value;
            var trimVal = trim(status);
            if(trimVal== "SUCCESS") 
            {
                refreshDetails();
                if(isZero == "true") {
                    isZero = "false";
                    removeItemsEffect(rowIndicator.parent());
                }
                else {
                    updateCart();
                }
                 var MyGoferCartCookie=getCookie('MyGoferCartCookie_'+cStoreId);
                 var MyGoferCartQuanFromCookie=MyGoferCartCookie[0];
                 if(document.body.id=="storepickupbody") {
					if(MyGoferCartQuanFromCookie == 0)  {
						var loadURL ="OrderItemDisplay?storeId="+registerStoreId+"&catalogId="+registerCatalogId+"&orderId=.";
						window.location = loadURL;
					}
					else {
						window.location.reload();
					}
				}
				if(document.body.id=="shoppingcart") {
					window.location.reload();
				}
				if(document.body.id=="productOptions") {
					window.location.reload();
				}
                if(typeof $(rowIndicator)!='undefined'){
                	var $currObj=$(rowIndicator).parent();
                	var prodUrl=$currObj.find('a').attr('href');
                	var updQuan=$currObj.find("input[@id=itemQuantity01]").val();
                	prodUrl=prodUrl.substring(0,prodUrl.indexOf('itemQuantity'));
                	var updatedUrl=prodUrl+'itemQuantity='+updQuan+".0";
                	$currObj.find('a').attr('href',updatedUrl);
            }
            }
            else
            {
                message(trimVal,'error');
                 if('true' == updateFail)
                {
                	jQuery(rowIndicator).parent().find("input[@id=itemQuantity01]").val(document.getElementById("oldQty").value);
            }
            }
            enableActions();     
        }
          var deleteStatus = 'false';
        var deleteStatusUE = 'false';
        
function testDelete(value)
        {       
              
                document.getElementById("smartcartresponse").innerHTML=value;
                if(document.getElementById("smartcartresponse")==null)
                {
                    deleteStatus='false';
                    deleteStatusUE='false';
                    document.body.style.cursor='default';
                }else{
                var status=document.smartcartresponseform.status.value;
                var trimVal = trim(status);
                if(trimVal== "SUCCESS") 
                {
                    refreshDetails();
                    removeItemsEffect(rowIndicator.parent().parent());
                    var MyGoferCartCookie=getCookie('MyGoferCartCookie_'+cStoreId);
                    var MyGoferCartQuanFromCookie=MyGoferCartCookie[0];
                    if(document.body.id=="storepickupbody") {
						if(MyGoferCartQuanFromCookie == 0)  {
						    var loadURL ="OrderItemDisplay?storeId="+registerStoreId+"&catalogId="+registerCatalogId+"&orderId=.";
							window.location = loadURL;
						}
						else {
							window.location.reload();
						}
					}
					if(document.body.id=="shoppingcart") {
						window.location.reload();
					}
					if(document.body.id=="productOptions") {
						window.location.reload();
					}
					
                }
                else
                {
                    message(trimVal,'error');
                }
               
				deleteStatus='false';
            	deleteStatusUE='false';
            	document.body.style.cursor='default';
                }
             enableActions();  
        }
        
function deleteItems(itemId) {
            
            if(deleteStatus == 'false' && deleteStatusUE == 'false'){
             
                disableActions();
                deleteStatus='true';
                deleteStatusUE='true';
                document.body.style.cursor='wait';
                var smartCartDeleteURL="smartCartDeleteURL_"+itemId;
                var smartCartDelete=document.getElementById(smartCartDeleteURL).value;
                ajaxCall(smartCartDelete,'testDelete');
            }
        }

        var isZero = "false";
          function ajaxCall(url,callbackFunction,returnData,linkId) 
    { 
    
    //alert(url+callbackFunction);
    
        var httpRequest = false; 
    
        // Exit if this function is not supported
        if (!httpRequestSupported) {
            return;  
        }
        
        // check if supported
        httpRequest = isHttpRequestSupported();
        
        if (!httpRequest) { 
            httpRequestSupported = false;
            return false; 
        } 
       
        // Map the response to the callback function
        httpRequest.onreadystatechange = function() { 
            if (httpRequest.readyState == 4) {  
                if (httpRequest.status == 200) {
                    if (returnData) { 
                        eval(callbackFunction + '(httpRequest.responseXML,linkId)'); 
                    } else { 
                        eval(callbackFunction + '(httpRequest.responseText,linkId)'); 
                    } 
                } else { 
                    // TODO:  Keep this line commented in production.  The user will have no idea what this means.
                    //('The AJAX request was made to our backend server and the following error occurred: ' + httpRequest.status); 
                    eval(callbackFunction + '("")'); 
                } 
            }
            else{
                if(callbackFunction == 'displayTabContent'){
                    
                    htmlValue = "<img src= '"+ imagePath + "img/backgrounds/loading.gif' />";
                    document.getElementById(linkId).innerHTML = htmlValue;
                }
            } 
        } 
        
        httpRequest.open('GET', url, true); 
        httpRequest.send(null); 
    }
    
    /* AddToCart Ajax Function --Start */
    var smartCartArray = new Array();
    var $removeTemp;
    function smartCartRows(smartCartArr){
        smartCartArray = smartCartArr;
        
    }
 function addToCartAjax(value,displayValue)
   { 
							        	
        document.getElementById("smartcartresponse").innerHTML=value;
        var status="";
        // modified for ECOM-25590
        if(document.smartcartresponseform!=undefined)
        {
        	status=document.smartcartresponseform.status.value;
        }
        else
        {
        	status = "Item(s) cannot be added to cart."
        	document.getElementById("smartcartresponse").innerHTML=""
        }
        if(document.getElementById("smartplanind")!=undefined)
        {
        var smartplanind=document.getElementById("smartplanind").value;
        }
        else
        {
        	var smartplanind="false";
        	status = "Item(s) cannot be added to cart."
        	document.getElementById("smartcartresponse").innerHTML=""
        }  
        if(smartplanind=="true")
        {
        	subCatATCFlag=false;
        }
        else
        {
            	subCatATCFlag=true; 
            }
            var values = displayValue.split("^");
            var trimVal = trim(status);
            hideCart();
   
        if(trimVal== "SUCCESS") 
        {
        	
            refreshDetails();
            $(".menuMessage").remove(); //kill any instances of a message
            //if (values[2] == 'QuickShop'){
                //QSaddTocartHighlight();
           // }
            if(fromPage == "QuickShop" || fromPage == "SearchResults" || fromPage == "QuickView"){ 
            		
            		
                  
                    
                    $(productIndex).children('.inCart').remove(); //remove any "incart" "inlist" or "inorder" icons in the product div
					$(productIndex).prepend('<img alt="In Cart" src="'+imagePath+'img/quickshop/cart_inside.gif" class="inCart"/>'); //write an "incart" "inlist" or "inorder" icon in the product div
					
					highlightFlash('Cart'); //run that little blue flash animation over the products          
                    //highlightItem('cart', inpSource);
            }
   
				                		
				                		
    		$('#newNav ul#actionMenu li#cartNav').addClass('active'); //activate the cart menu item
			$('#newNav ul#actionMenu li#cartNav').children('.inactive').hide();//activate the cart menu item
			$('#newNav ul#actionMenu li#cartNav').children('.active').show();//activate the cart menu item
			$('#checkoutButton').addClass('active');//activate the cart menu item
			$('#rightCap').addClass('active');//activate the cart menu item
			var offset = $("#newNav ul#actionMenu li#cartNav").offset();//get the offset of the cart's menu item
    
    		$('body').append('<div id="cartMessage" class="menuMessage"><p>Item(s) Added to Cart</p></div>');//create the "added to cart" message for the menu
			$('#cartMessage').css( {'top': offset.top+33, 'left': offset.left-1 } );//position the message absolutely
			//here's where it gets tricky all these animations are part of a "queue" pronounced "Q"
			$('#cartMessage').slideDown(300); //open the message this takes 300 ms
			$('#cartMessage').fadeTo(1000, 1.0);//hold for 1000ms or 1sec
			$('#cartMessage').slideUp(300);//close the message in 300ms

			$('#cartMessage').queue(function(){
					killMessage();//kill the message
					reactivateCart();//reactive user interaction with the smart cart
					$(this).dequeue();//officially end this queue
			}); 
			 if(trim(jQuery("#itemsInSmartCart").html())!= '') 
			 {
				$('#itemsInSmartCart').append($('#addAnimation').html());
			 }
 			 if(smartplanind == "true"){
			              setTimeout("smartPlanDisplay()",3500);
		         }
		    if (values[2] == 'search'){
                var keyword = gup('keyword');
                var viewItems = gup('viewItems');
                var pageNum = gup('pageNum');
                var sortOption = gup('sortOption');
                var qsi = gup('qsi');
                var qsURL = "qs_"+values[3]+"_"+values[4]+"?vName=&cName=&sName=&keyword=" +keyword+ "&viewItems=" +viewItems+ "&pageNum=" +pageNum+ "&sortOption=" + sortOption+ "&qsi=" + qsi+ "&qsMode=" + values[2];
                setTimeout(function(){location.href = qsURL;},3500);        
            }
                if(document.addToCart!= null){
               		
               		if(document.addToCart.addToCartBtn != null){
               			document.addToCart.addToCartBtn.value=false;
               		}
               }
              
            }
		  else
      		  {
        
        	 	refreshDetails();
            	$('#newNav ul#actionMenu li#cartNav').addClass('active'); //activate the cart menu item
				$('#newNav ul#actionMenu li#cartNav').children('.inactive').hide();//activate the cart menu item
				$('#newNav ul#actionMenu li#cartNav').children('.active').show();//activate the cart menu item
				$('#checkoutButton').addClass('active');//activate the cart menu item
				$('#rightCap').addClass('active');//activate the cart menu item
				var offset = $("#newNav ul#actionMenu li#cartNav").offset();//get the offset of the cart's menu item
				$('#cartMessage').remove();
            	$('body').append('<div id="cartMessage" class="menuMessage"><p>'+trimVal+'</p></div>');//create the "added to cart" message for the menu
				$('#cartMessage').css( {'top': offset.top+33, 'left': offset.left-1 } );//position the message absolutely
				//here's where it gets tricky all these animations are part of a "queue" pronounced "Q"
				$('#cartMessage').slideDown(300); //open the message this takes 300 ms
				$('#cartMessage').fadeTo(1000, 1.0);//hold for 1000ms or 1sec
				$('#cartMessage').slideUp(300);//close the message in 300ms
	        	$('#cartMessage').queue(function(){
					killMessage();//kill the message
					reactivateCart();//reactive user interaction with the smart cart
					$(this).dequeue();//officially end this queue
				}); 
		         }           
						           
   	 }

        
    /* AddToCart Ajax Function --End */
    
    function smartPlanDisplay(){
        document.smartcartresponseform.submit();
    }
	/*smart cart code change ends*/   
/* For SmartCart  End  */
   // From Aqua Smart Cart Header
    var refreshDetails = function() 
    {
        var userIdFromCookie=getUserIdFromCookie;  
        var MyGoferCartCookie =  getCookie('MyGoferCartCookie_'+storeID).split('|');
        var MyGoferCartQuanFromCookie = MyGoferCartCookie[0];
            var MyGoferCartTotalFromCookie = MyGoferCartCookie[1];
            if(MyGoferCartTotalFromCookie.indexOf('.')!=-1)
        {
            MyGoferCartTotalFromCookie = MyGoferCartTotalFromCookie.substring(0,MyGoferCartTotalFromCookie.indexOf('.')+3);
            var dotIndex = MyGoferCartTotalFromCookie.indexOf('.');
            var roundOffVal = MyGoferCartTotalFromCookie.substring(dotIndex+2);
            if(roundOffVal == "")
            {
                MyGoferCartTotalFromCookie = MyGoferCartTotalFromCookie+"0";
            }
            if(MyGoferCartTotalFromCookie.indexOf(".")==0)
            {
                MyGoferCartTotalFromCookie = "0"+MyGoferCartTotalFromCookie;
            }
        }
        else
        {
            MyGoferCartTotalFromCookie = MyGoferCartTotalFromCookie+".00";
        }   
        var checkoutDivContents='<li><a href="javascript://" title="Click to hide cart contents">' +MyGoferCartQuanFromCookie+ ' items</a></li>';
        checkoutDivContents+='<li><a href="javascript://" title="Click to hide cart contents">$'+MyGoferCartTotalFromCookie+'</a></li>';
        jQuery("#itemsTotal").html(checkoutDivContents);
        if(MyGoferCartQuanFromCookie == 0) {
            document.getElementById("disableCheckoutButton").style.display='block'; 
            document.getElementById("enableCheckoutButton").style.display='none';    
            disableCartLink ="true";   
            hideCart();
      
        }
        else {
           if(typeof insideCartNav =='undefined')
           {
           		$('#cartNav').click(function(){
           			var insideCartNav = "";
				if(checkShowCart=="false" && $('#fullCart').attr('style')=="display: none;"){
            		location.href='OrderItemDisplay?storeId='+storeID+'&catalogId='+catalogID+'&orderId=.';
            	}
            	checkShowCart="false";
            });
           }
            document.getElementById("enableCheckoutButton").style.display='block';
            document.getElementById("disableCheckoutButton").style.display='none';  
            disableCartLink ="false";
        }
        originalMessage = setCartMessage();
            
    }
    var setCartMessage = function() {
//       calculate the message and set global var originalMessage
        var cartMessage="";
        //var limit = '${freeLimit}';
        if(jQuery("#smartcartresponse").html() == '') {
            var inStock = InStock;
        }
        else {          
            if(jQuery("#InStockUpdate").val() != "false")
                inStock = "true";
            else
                inStock = "false";
        }
        var MyGoferCartCookie =  getCookie('MyGoferCartCookie_'+storeID).split('|');
        var cartTotal = MyGoferCartCookie[1];
        if(inStock == "false") {
            cartMessage = "Some items are no longer available. Click items for Recommendations.";
            originalClass = "exclamation";
        }
        else
        {
            
            originalClass = "";
        }
        return cartMessage;
    }   

    
    // smartCart
function initPageLoadSmartCart()
{
	if( ($.cookie("EacyMealDap")=="EacyMealInd")&&(userTypeVal != null)&&(userTypeVal != "")){						
 		var selectedLocation = locationId;		 													
 		var MGDefaultLocationId = defaultLocId;
		var MGDefaultUnitNumber = unitNoFrmLoc;
		if(fnCheckCookie()){
 	
 			if((easyMealsLocations.indexOf(MGDefaultLocationId) >= 0)&&(unitNo==MGDefaultUnitNumber)&&((userTypeVal=='C'))){
 				EacyMealNo="";
				document.cookie="EacyMealDap="+EacyMealNo;
  				document.location.href = "/shc/s/c_10152_10108_Food+%26+Grocery_Prepared+Foods";									
      		}else{
      			EacyMealNo="";
				document.cookie="EacyMealDap="+EacyMealNo;
				document.location.href = "/shc/s/dap_10152_10108_DAP_easyMealNA";
      		} 
	   	}else{
	   		EacyMealNo="";
			document.cookie="EacyMealDap="+EacyMealNo;
			document.location.href = "/shc/s/dap_10152_10108_DAP_easyMealNA";
	   		}				
	}
	var MyGoferCartCookie =  getCookie('MyGoferCartCookie_'+storeID).split('|');
	var MyGoferCartQuanFromCookie=MyGoferCartCookie[0];
	var MyGoferCartTotalFromCookie=MyGoferCartCookie[1];
	if(MyGoferCartQuanFromCookie == '') {
		MyGoferCartQuanFromCookie = 0;
	}
	if(MyGoferCartTotalFromCookie.indexOf('.')!=-1)
	{
		MyGoferCartTotalFromCookie = MyGoferCartTotalFromCookie.substring(0,MyGoferCartTotalFromCookie.indexOf('.')+3);
		var dotIndex = MyGoferCartTotalFromCookie.indexOf('.');
		var roundOffVal = MyGoferCartTotalFromCookie.substring(dotIndex+2);
		if(roundOffVal == "")
		{
			MyGoferCartTotalFromCookie = MyGoferCartTotalFromCookie+"0";
		}
		if(MyGoferCartTotalFromCookie.indexOf(".")==0)
		{
			MyGoferCartTotalFromCookie = "0"+MyGoferCartTotalFromCookie;
		}
		
	}
	else
	{
		if(MyGoferCartTotalFromCookie == '') {
			MyGoferCartTotalFromCookie = 0;
		}
		MyGoferCartTotalFromCookie = MyGoferCartTotalFromCookie+".00";
	}
	var checkoutDivContents='<li><a href="javascript://" title="Click to show cart contents">' +MyGoferCartQuanFromCookie+ ' items</a></li>';
	checkoutDivContents+='<li><a href="javascript://" title="Click to show cart contents">$'+MyGoferCartTotalFromCookie+'</a></li>';
	document.getElementById("itemsTotal").innerHTML = checkoutDivContents;
	if(MyGoferCartQuanFromCookie == 0) {
	document.getElementById("disableCheckoutButton").style.display='block';	
	document.getElementById("enableCheckoutButton").style.display='none';	  
	disableCartLink ="true";
	}
	else {
	document.getElementById("enableCheckoutButton").style.display='block';
	document.getElementById("disableCheckoutButton").style.display='none';
	disableCartLink ="false";
	$('#cartNav').click(function(){
		var insideCartNav = "";
				if(checkShowCart=="false" && $('#fullCart').attr('style')=="display: none;"){
            		location.href='OrderItemDisplay?storeId='+storeID+'&catalogId='+catalogID+'&orderId=.';
		}
            	checkShowCart="false";
            });
		}
	originalMessage = setCartMessage();
	jQuery("#message").html(originalMessage);
	if(userTypeId == 'R') {
			var starterListFromView=document.getElementById("starterListValue").value;
			if(starterListFromView=="\"\"")
			starterListFromView='';
			var starterListContents='<dt>Starter Lists</dt>';
			var starterListArray = starterListFromView.split(",");
			for(var index = 0; index < starterListArray.length ; index++)
			{
				var starterListItem = starterListArray[index];
				var stList = starterListItem.split(" ");
				var subCat="";
				var flag = false;
				for(var i=0;i<stList.length;i++){
					if(flag){
						subCat = subCat+"+";
						subCat = subCat+stList[i];
					}
					else{
						subCat = subCat+stList[i];
						flag = true;
					}
				}
				starterListContents =starterListContents + '<dd><a href="'+dynamicCategoryUrl+'/slc_'+storeId+'_'+catalogId+'_'+starterListCategory+'_'+subCat+'_true" title="View the '+starterListItem+' Starter List">'+starterListItem+'</a></dd>';

			}
			if(document.getElementById("starterList")!= null)
			if(typeof document.getElementById("starterList")!= 'undefined')
			{
			document.getElementById("starterList").innerHTML="";
			document.getElementById("starterList").innerHTML=starterListContents;
			}
		}
		var contents = '';
		var flag =1;
		var SListFromCookie=getCookie('MyGoferShoppingListCookie_'+storeID+'_'+getUserIdFromCookie);
		var val1;
		var val2;
		var flagChar = true;
		if (SListFromCookie != null && SListFromCookie !== ''){					
			var	len = SListFromCookie.length;	
			val1 = SListFromCookie;
			if (val1.indexOf("") != -1){
				flagChar = false;
			}
			for(var i=0;i <SListFromCookie.length; i++){					
					val1 = val1.replace("", "~*#");
					if (val1.indexOf("") == -1) {
			
						break;
					}					
			}	
			SListFromCookie=val1;
		}
		
		if (flagChar && SListFromCookie != null && SListFromCookie !== ''){				
			val2 = SListFromCookie;
			if (val2.indexOf("~*#") == -1){
				val2 = val2.replace(/~/g, "~*#");
			}										
			SListFromCookie=val2;
		}
		
		if(SListFromCookie=="\"\"")
        				SListFromCookie='';
		var shoppingListContents='<dt>Shopping Lists</dt>';
		SListFromCookie = SListFromCookie + '~*#';
		var	len = SListFromCookie.length;
		len = len - 0;
		while(SListFromCookie.length > 1 && flag != 0)
		{
			var listId;
			var listDesc;
			len = SListFromCookie.length - 0;
			SListFromCookie = SListFromCookie.substring(3,len);
			if( SListFromCookie.indexOf(':') )
			{
				listId = SListFromCookie.substring(0,SListFromCookie.indexOf(':'));
				SListFromCookie = SListFromCookie.substring(SListFromCookie.indexOf(':'),len);
				listDesc = SListFromCookie.substring(1,SListFromCookie.indexOf('~*#'));
				listDesc = listDesc.replace(/&#58/g,":");
				listDesc = listDesc.replace(/&#59/g,";");
				listDesc = listDesc.replace(/&#60/g,"<");
				listDesc = listDesc.replace(/&#61/g,"=");
				listDesc = listDesc.replace(/&#62/g,">");
				var listDisplayName = listDesc;
				if(listDisplayName.length > 15)
				{
					listDisplayName = listDisplayName.substring(0, 15) + "...." ;
				}
				SListFromCookie = SListFromCookie.substring(SListFromCookie.indexOf('~*#'),len);
				shoppingListContents +='<dd><a href="ShoppingListSortCmd?catalogId='+parentCatalogID+'&storeId='+storeID+'&listId='+ listId + '&listName=' + listDesc + '" title="View My '+listDisplayName+' list">'+listDisplayName+'</a></dd>';
			}
		}
		shoppingListContents+='<dd><a class="newList" href="##" onclick="createNewListModalHeader();" title="Create New List">Create new list </a></dd>';														
		
		var userTypeCookie =userTypeVal;
		if (userTypeVal == 'P' || userTypeVal == 'C' || isRemembered()){
				$("#existingLists").append(shoppingListContents);
				$('#listsNav').click(function(){
					if(checkShowNewList!="true"){
						location.href='MGStarterListCmd?storeId='+storeID+'&catalogId='+catalogID+'&listDisplaySize=6';
		}
					checkShowNewList = "false";
				});
		}
		else {
			$("#existingLists").append("<dd>Make your next shopping list online, add it to a scheduled order or checkout right away. Save it and it's ready the next time you need to shop.</dd> <dd>You can also get ideas for special occasions and everyday needs from the starter lists mygofer has ready for you.</dd>"+"<dd><a href='"+manageShopList+"'>Register</a> to manage all your shopping lists.</dd>");
		}
		
}
function initPageLoadMyChoiceSmartCart(){
	var eacyMealInd_dap= "_DAP_easyMeal";						
	if( ($.cookie("EacyMealDap")=="EacyMealInd")){
		var selectedLocation = locationId;		 													
	 	var MGDefaultLocationId = defaultLocId;
		var MGDefaultUnitNumber = unitNoFrmLoc;
		if(fnCheckCookie()){
			if((easyMealsLocations.indexOf(MGDefaultLocationId) >= 0)&&(unitNo==MGDefaultUnitNumber)&&(userTypeVal=='C')){
	 			EacyMealNo="";
				document.cookie="EacyMealDap="+EacyMealNo;
  				document.location.href = "/shc/s/c_10152_10108_Food+%26+Grocery_Prepared+Foods";									
      		} 
	   	}				
	}
	var contents = '';
	var flag =1;
	var SListFromCookie=getCookie('MyGoferShoppingListCookie_'+storeID+'_'+getUserIdFromCookie);
	var val1;
	var val2;
	var flagChar = true;
	if (SListFromCookie != null && SListFromCookie !== ''){					
		var	len = SListFromCookie.length;	
		val1 = SListFromCookie;
		if (val1.indexOf("") != -1){
			flagChar = false;
			}
			for(var i=0;i <SListFromCookie.length; i++){					
				val1 = val1.replace("", "~*#");
				if (val1.indexOf("") == -1) {
					break;
				}		
			}	
			SListFromCookie=val1;
		}

		if (flagChar && SListFromCookie != null && SListFromCookie !== ''){				
			val2 = SListFromCookie;
			if (val2.indexOf("~*#") == -1){
				val2 = val2.replace(/~/g,"~*#");	
			}								
			SListFromCookie=val2;
		}
		if(SListFromCookie=="\"\"")
        				SListFromCookie='';
		var shoppingListContents='<dt>Shopping Lists</dt>';
		SListFromCookie = SListFromCookie+ '~*#';
		var	len = SListFromCookie.length;
		len =len - 0;
		while(SListFromCookie.length > 1 && flag !=0)
		{
			var listId;
			var listDesc;
			len = SListFromCookie.length - 0;
			SListFromCookie = SListFromCookie.substring(3,len);
			if( SListFromCookie.indexOf(':'))
			{
				listId = SListFromCookie.substring(0,SListFromCookie.indexOf(':'));
				SListFromCookie = SListFromCookie.substring(SListFromCookie.indexOf(':'),len);
				listDesc = SListFromCookie.substring(1,SListFromCookie.indexOf('~*#'));
				listDesc = listDesc.replace(/&#58/g,":");
				listDesc = listDesc.replace(/&#59/g,";");
				listDesc = listDesc.replace(/&#60/g,"<");
				listDesc = listDesc.replace(/&#61/g,"=");
				listDesc = listDesc.replace(/&#62/g,">");
				var listDisplayName = listDesc;
				if(listDisplayName.length > 15)
				{
					listDisplayName = listDisplayName.substring(0, 15) +"...." ;
				}
				SListFromCookie = SListFromCookie.substring(SListFromCookie.indexOf('~*#'),len);
				if($('#pageCheck').val()=="THANKYOU"){
				shoppingListContents += '<dd><a href="shc/s/ShoppingListSortCmd?catalogId='+parentCatalogID+'&storeId='+storeID+'&listId='+ listId + '&listType=shoppingList&listName=' + listDesc + '" title="View My '+listDisplayName+' list">'+listDisplayName+'</a></dd>';
				}else{
				shoppingListContents += '<dd><a href="ShoppingListSortCmd?catalogId='+parentCatalogID+'&storeId='+storeID+'&listId='+ listId + '&listType=shoppingList&listName=' + listDesc + '" title="View My '+listDisplayName+' list">'+listDisplayName+'</a></dd>';
				}
			}
			}
	var cnstShopping=' ';
		cnstShopping=' Shopping ';
		var WListFromCookie=getCookie('MyGoferWishListCookie_'+storeID+'_'+getUserIdFromCookie);
		var val1;
		var val2;
		var flagChar = true;
		if (WListFromCookie != null && WListFromCookie !== ''){					
			var	len = WListFromCookie.length;	
			val1 = WListFromCookie;
			if (val1.indexOf("") != -1){
				flagChar = false;
			}
			for(var i=0;i <WListFromCookie.length; i++){					
				val1 = val1.replace("", "~*#");
				if (val1.indexOf("") == -1) {
					break;
				}		
			}	
			WListFromCookie=val1;
		}

		if (flagChar && WListFromCookie != null && WListFromCookie !== ''){				
			val2 = WListFromCookie;
			if (val2.indexOf("~*#") == -1){
			val2 = val2.replace(/~/g, "~*#");	
			}									
			WListFromCookie=val2;
		}
		if(WListFromCookie=="\"\"")
        				WListFromCookie='';
		var wishListContents='<dt>Wish Lists</dt>';
		WListFromCookie = WListFromCookie + '~*#';
		var	len = WListFromCookie.length;
		len = len - 0;
		while(WListFromCookie.length > 1 && flag != 0)
		{
			var listId;
			var listDesc;
			len = WListFromCookie.length - 0;
			WListFromCookie = WListFromCookie.substring(3,len);
			if( WListFromCookie.indexOf(':') )
			{
				listId = WListFromCookie.substring(0,WListFromCookie.indexOf(':'));
				WListFromCookie = WListFromCookie.substring(WListFromCookie.indexOf(':'),len);
				listDesc = WListFromCookie.substring(1,WListFromCookie.indexOf('~*#'));
				listDesc = listDesc.replace(/&#58/g,":");
				listDesc = listDesc.replace(/&#59/g,";");
				listDesc = listDesc.replace(/&#60/g,"<");
				listDesc = listDesc.replace(/&#61/g,"=");
				listDesc = listDesc.replace(/&#62/g,">");
				var listDisplayName = listDesc;
				if(listDisplayName.length > 15)
				{
					listDisplayName = listDisplayName.substring(0, 15) + "...." ;
				}
				WListFromCookie = WListFromCookie.substring(WListFromCookie.indexOf('~*#'),len);
				if($('#pageCheck').val()=="THANKYOU"){
				wishListContents += '<dd><a href="shc/s/ShoppingListSortCmd?catalogId='+parentCatalogID+'&storeId='+storeID+'&listId='+ listId + '&listType=wishlist&listName=' + listDesc + '" title="View My '+listDisplayName+' list">'+listDisplayName+'</a></dd>';
				}else{
				wishListContents += '<dd><a href="ShoppingListSortCmd?catalogId='+parentCatalogID+'&storeId='+storeID+'&listId='+ listId + '&listType=wishlist&listName=' + listDesc + '" title="View My '+listDisplayName+' list">'+listDisplayName+'</a></dd>';
			}
		}
		}
	var MyGoferCartCookie =  getCookie('MyGoferCartCookie_'+storeID).split('|');
	var MyGoferCartQuanFromCookie=MyGoferCartCookie[0];
	var MyGoferCartTotalFromCookie='';
	MyGoferCartTotalFromCookie=MyGoferCartCookie[1];
	if(MyGoferCartQuanFromCookie == '') {
		MyGoferCartQuanFromCookie = 0;
	}
	if(MyGoferCartTotalFromCookie.indexOf('.')!=-1)
	{
		MyGoferCartTotalFromCookie = MyGoferCartTotalFromCookie.substring(0,MyGoferCartTotalFromCookie.indexOf('.')+3);
		var dotIndex = MyGoferCartTotalFromCookie.indexOf('.');
		var roundOffVal = MyGoferCartTotalFromCookie.substring(dotIndex+2);
		if(roundOffVal == "")
		{
			MyGoferCartTotalFromCookie = MyGoferCartTotalFromCookie+"0";
		}
		if(MyGoferCartTotalFromCookie.indexOf(".")==0)
		{
			MyGoferCartTotalFromCookie = "0"+MyGoferCartTotalFromCookie;
		}
	}
	else
	{
		if(MyGoferCartTotalFromCookie == '') {
			MyGoferCartTotalFromCookie = 0;
		}
		MyGoferCartTotalFromCookie = MyGoferCartTotalFromCookie+".00";
	}
	shoppingListContents+='<dd><a class="newList" href="##" onclick="createNewListModalHeader();" title="Create New List">Create new'+cnstShopping+'list </a></dd>';														
	var checkoutDivContents='<li><a href="javascript://" title="Click to show cart contents">' +MyGoferCartQuanFromCookie+ ' items</a></li>';
	checkoutDivContents+='<li><a href="javascript://" title="Click to show cart contents">$'+MyGoferCartTotalFromCookie+'</a></li>';
	if(document.getElementById("itemsTotal"))
	document.getElementById("itemsTotal").innerHTML = checkoutDivContents;
	if(MyGoferCartQuanFromCookie == 0) {
		disableCartLink ="true";
	}
	else {
		disableCartLink ="false";
	}
	if(pageType=="true")
	{
		originalMessage = setCartMessage();
		jQuery("#message").html(originalMessage);		
	}
	var userTypeCookie =userTypeVal;
	var userTypeIdCookie = userTypeId;
		 if (userTypeCookie == null || userTypeCookie == "" || userTypeCookie == "loggedOut" || userTypeIdCookie == "G" || userTypeIdCookie == null || userTypeIdCookie == "") {
        	$("#existingLists").append("<dd>Make your next shopping list online, add it to a scheduled order or checkout right away. Save it and it's ready the next time you need to shop.</dd> <dd>You can also get ideas for special occasions and everyday needs from the starter lists mygofer has ready for you.</dd>"+"<dd><a href='"+logonFormURL+"'>Register</a> to manage all your shopping lists.</dd>");
			document.getElementById("existingWishLists").style.display = "none";
		
		} else if (userTypeCookie == 'C' || userTypeCookie == 'P' ) {	
		    $("#existingLists").append(shoppingListContents);
		   	wishListContents+='<dd><a class="newList" href="##" onclick="createNewWishListModalHeader();" title="Create New List">Create new Wish List </a></dd>';														
		    $("#existingWishLists").append(wishListContents);
										
	}
	
}
