if(typeof ShoppingCart._initialized == "undefined") { CartItem.prototype.isEClub = function() { var discounted = eClub.isDiscounted(this.divCatStr); return discounted; }; CartItem.prototype.getBookLink = function() { var bookLink = ["/primary/newonix/domisbn/" + this.isbn + "?open"]; var divCatSplit = this.divCatStr.split('>'); bookLink.push("&div=" + escape(divCatSplit[0])); if(divCatSplit.length == 3) { bookLink.push("&cat=" + escape(divCatSplit[1]) + ">" + escape(divCatSplit[2])); } else { bookLink.push("&cat=" + escape(divCatSplit[1])); } if(this.buyInspect.substring(0,1) == "I") { bookLink.push("&bi=1"); } else { bookLink.push("&bi=0"); } bookLink.push("&ed=site/primed3.nsf"); return bookLink.join(""); }; ShoppingCart.prototype.attachItem = function(i) { var oTR = document.createElement('tr'); var tdIsbn = document.createElement('td'); tdIsbn.appendChild(document.createTextNode(isbn10to13(this.items[i].isbn))); oTR.appendChild(tdIsbn); var tdTitle = document.createElement('td'); tdTitle.className = "title"; var titleLink = document.createElement('a'); var bookLink = this.items[i].getBookLink(); //var bookLink = "/primary/newonix/domisbn/" + this.items[i].isbn + "?open&template=domPrimary&ed=site/primed3.nsf"; titleLink.setAttribute('href',bookLink); titleLink.title = this.items[i].title; titleLink.appendChild(document.createTextNode(this.items[i].title)); tdTitle.appendChild(titleLink); oTR.appendChild(tdTitle); var tdPrice = document.createElement('td'); if((typeof checkTC == "undefined")||((typeof checkTC == "boolean")&&(checkTC == false)) ||!this.items[i].isEClub()) { if(this.items[i].price.indexOf('$') == -1) { var ePrice = "$" + this.items[i].price; } else { var ePrice = this.items[i].price; } } else { var ePrice = "-"; } tdPrice.appendChild(document.createTextNode(ePrice)); oTR.appendChild(tdPrice); var tdClubPrice = document.createElement('td'); if(this.items[i].isEClub()&&((typeof checkTC != "undefined")&&(checkTC == true))) { if(this.items[i].price.indexOf('$') == -1) { var ePrice = "$" + this.eClubPrice(i); } else { var ePrice = this.eClubPrice(i); } } else { var ePrice = "-"; } tdClubPrice.appendChild(document.createTextNode(ePrice)); oTR.appendChild(tdClubPrice); var tdQuantity = document.createElement('td'); var iQuantity = document.createElement('input'); iQuantity.setAttribute('type','text'); iQuantity.className = "units"; iQuantity.setAttribute('value',this.items[i].quantity); if(this.items[i].buyInspect == "II") { iQuantity.disabled = true; } tdQuantity.appendChild(iQuantity); oTR.appendChild(tdQuantity); var tdInspect = document.createElement('td'); var iInspect = document.createElement('input'); iInspect.setAttribute('type','radio'); iInspect.setAttribute('name',('ib' + i)); iInspect.setAttribute('value','I'); if(this.items[i].buyInspect.substring(0,1) == "I") { if(document.attachEvent) { iInspect.onclick = function(oEvent){updateInspectBuy();}; } else { iInspect.setAttribute('onclick','updateInspectBuy(event)'); } } else { iInspect.disabled = true; } tdInspect.appendChild(iInspect); oTR.appendChild(tdInspect); var tdBuy = document.createElement('td'); var iBuy = document.createElement('input'); iBuy.setAttribute('type','radio'); iBuy.setAttribute('name',('ib' + i)); iBuy.setAttribute('value','B'); if(document.attachEvent) { iBuy.onclick = function(oEvent){updateInspectBuy();}; } else { iBuy.setAttribute('onclick','updateInspectBuy(event)'); } tdBuy.appendChild(iBuy); oTR.appendChild(tdBuy); var tdRemove = document.createElement('td'); tdRemove.className = "last"; /* var aRemove = document.createElement('a'); aRemove.setAttribute('href','#'); aRemove.setAttribute('name',i); aRemove.className = "remove"; if(document.attachEvent) { aRemove.onclick = function(oEvent){removefromOverviewCart();}; } else { aRemove.setAttribute('onclick','removefromOverviewCart(event)'); } aRemove.appendChild(document.createTextNode('remove')); */ var aRemove = document.createElement('input'); //aRemove.setAttribute('href','#'); aRemove.setAttribute('name',i); aRemove.setAttribute('type','button'); aRemove.value = 'remove'; aRemove.className = "remove"; if(document.attachEvent) { aRemove.onclick = function(oEvent){removefromOverviewCart();}; } else { aRemove.setAttribute('onclick','removefromOverviewCart(event)'); } tdRemove.appendChild(aRemove); oTR.appendChild(tdRemove); return oTR; }; ShoppingCart.prototype.removeFromCartOverview = function(n) { this.deleteFromCart(this.items[n].isbn); this.updateShoppingCartOverview(); this.updateShoppingSummary(); }; ShoppingCart.prototype.updateCartOverview = function(iQuantity) { var tempItems = new Array(); for(var i=0; i < iQuantity.length; i++) { if(iQuantity[i] != -1)this.items[i].quantity = iQuantity[i]; var tempArray = new Array(); tempArray.push(this.items[i].isbn); tempArray.push(this.items[i].title); tempArray.push(this.items[i].price); tempArray.push(this.items[i].buyInspect); tempArray.push(this.items[i].quantity); tempArray.push(this.items[i].divCatStr); tempItems.push(new CartItem(tempArray)); } this.items = new Array(); for(var i=0; i < tempItems.length; i++) { if(tempItems[i].quantity != 0) { var tempArray = new Array(); tempArray.push(tempItems[i].isbn); tempArray.push(tempItems[i].title); tempArray.push(tempItems[i].price); tempArray.push(tempItems[i].buyInspect); tempArray.push(tempItems[i].quantity); tempArray.push(tempItems[i].divCatStr); this.items.push(new CartItem(tempArray)); } } this.save(); this.updateShoppingCartOverview(); this.updateShoppingSummary(); }; ShoppingCart.prototype.updateInspectBuy = function(i,ib) { this.items[i].buyInspect = this.items[i].buyInspect.substring(0,1) + ib; if(this.items[i].buyInspect == "II") { this.items[i].quantity = 1; } this.save(); this.updateShoppingCartOverview(); this.updateShoppingSummary(); }; ShoppingCart.prototype.getCheckoutConfirmationTable = function() { var oText = "
| ISBN | Title | RRP | e-Club price | Quantity | Inspect | Buy | '; oText += '||||
|---|---|---|---|---|---|---|---|---|---|---|
| ' + isbn10to13(this.items[i].isbn) + ' | '; oText += '' + this.items[i].title + ' | '; if(this.items[i].isEClub()&&((typeof checkTC != "undefined")&&(checkTC == true))) { oText += '- | $' + this.eClubPrice(i) + ' | '; } else { oText += '' + this.items[i].price + ' | - | '; } oText += '' + this.items[i].quantity + ' | '; if(this.items[i].buyInspect.substring(1) == "I") { oText += 'inspect | '; } else { oText += ' | buy | '; } oText += '
Total purchase
$' + this.getEClubTotal() + '
Total purchase
$' + this.getTotal() + '