var ajaxObjects = new Array();
function AddToBasket(iItemID) {
var bError = false;
var sMsg = 'Before you can add an item you must:\n';
var iItemCount = document.getElementById('ItemCount' + iItemID).value;
if (iItemCount.length == 0 || isNaN(iItemCount)) {
bError = true;
sMsg += '\nChoose number of items.';
}
var iColorID = document.getElementById('Color' + iItemID).value;
if (iColorID.length == 0) {
bError = true;
sMsg += '\nChoose a color/variant.';
}
var iSizeID = document.getElementById('Size' + iItemID).value;
if (iSizeID.length == 0) {
bError = true;
sMsg += '\nChoose a size.';
}
if (bError) {
alert(sMsg);
} else {
var ajaxIndex = ajaxObjects.length;
ajaxObjects[ajaxIndex] = new sack();
ajaxObjects[ajaxIndex].requestFile = '/shop/addProduct.asp?itemid=' + iItemID + '&itemcount=' + iItemCount + '&colorid=' + iColorID + '&sizeid=' + iSizeID;
ajaxObjects[ajaxIndex].onCompletion = function() {
UpdateBasket(ajaxIndex);
};
ajaxObjects[ajaxIndex].runAJAX();
}
}
function UpdateBasket(ajaxIndex) {
objShoppingCart = document.getElementById('ShoppingCart');
objShoppingCartItem = document.getElementById('ShoppingCartItem');
objShoppingCartTotal = document.getElementById('ShoppingCartTotal');
//ItemID|||ColorID|||SizeID|||Title|||Variant|||Price|||Count|||OrderTotal
var aResponse = ajaxObjects[ajaxIndex].response.split('|||');
objShoppingCartItem.innerHTML = unescape(aResponse[3]) + '
' + unescape(aResponse[4]) + '
' + aResponse[6] + ' á £ ' + unescape(aResponse[5]);
objShoppingCartTotal.innerHTML = unescape(aResponse[7]);
objShoppingCart.style.display = '';
ajaxObjects[ajaxIndex] = false;
}