

function basketSummary(data) {
ShoppingBasketWrapper.getTotalInBasket(loadGetTotalItems);
ShoppingBasketWrapper.getGrandTotalWithoutPP(loadGetGrandTotal);
}

function updateSizeBox(key, label) {  
var checked = dwr.util.getValue(key);
var s = key.split("-");
Item.updateBasket(s[1], label, null, checked, updateSizeBoxLoad);
}

function updateSizeBoxLoad(data) {  
basketSummary(data);
}


function init(whereAmI) {
//useCuteLoadingMessage("Please wait....loading");
useLoadingImage("/images/loader.gif") 

ShoppingBasketWrapper.getListOfItems(initLoad);
var s =  whereAmI.split(" ");
International.convertPrices( s[0], s[1], convertPricesLoad);
}

function convertPricesLoad(data) {
//go through map stock_codes and string (Price dollars: $xx.xx)
for(thing in data) {
var stockCodeAndPrice = "price-"+thing;
var convertedPrice = "(" + data[thing] + ")";
dwr.util.setValue(stockCodeAndPrice, convertedPrice, { escapeHtml:false });
}
}

function initLoad(data) {
//alert("inside initLoad");
if(data != null) {
basketSummary(data);
}
else {
dwr.util.setValue("totalItem", "Empty");
dwr.util.setValue("totalPrice", "alas!");
}
//////////////////////////
//loop through dom find checkbox and set to not checked or checked
var checkboxlist = document.getElementsByName("checkbox");
for(var x=0;x<checkboxlist.length;x++) {
$(checkboxlist[x].id).checked = false;
//alert("setting " + checkboxlist[x].id + " to false" );
}
/////////////////////////

for(thing in data) {
//alert("thing "+DWRUtil.toDescriptiveString(thing, 2));
var id = "sizeBox-"+data[thing].stockCode+":"+data[thing].size+":"+data[thing].colour+":"+data[thing].price+":"+data[thing].weight;
//alert("id is " +  id);
//alert(" "+ DWRUtil.toDescriptiveString(document.getElementById(id), 2));
//need to loop through each size for a stock
for(option in data[thing].options) {
//alert("option "+DWRUtil.toDescriptiveString(option, 2));
var id = "sizeBox-"+data[thing].options[option].stockCode+":"+data[thing].options[option].size+":"+data[thing].options[option].colour+":"+data[thing].options[option].price+":"+data[thing].options[option].weight;
//alert("inBasket " + data[thing].options[option].inBasket);
//$(id).checked = data[thing].options[option].inBasket;
if(document.getElementById(id) != null) {
document.getElementById(id).checked = data[thing].options[option].inBasket;
}
}
}
}







	