function Pack(pNum) { this.pNum = pNum; this.pubDate = getPubDate(unescape(viewResults[pNum].viewCol5)); this.isbn = unescape(viewResults[pNum].viewCol6); this.title = unescape(viewResults[pNum].viewCol2); this.price = unescape(viewResults[pNum].viewCol7); this.series = unescape(viewResults[pNum].viewCol15); this.subject = unescape(viewResults[pNum].viewCol13); this.area = unescape(viewResults[pNum].viewCol14); this.buyInspect = ""; //this.passValues = this.isbn + "|" + this.title + "|" + this.price; //this.passBuy = this.isbn + "|" + this.title + "|" + this.price + "|B"; //this.passInspect = this.isbn + "|" + this.title + "|" + this.price + "|I"; //this.idString = ""; //this.addtoValue = "Num_" + unescape(viewResults[pNum].viewCol6); //this.innerID = "buypackid" + pNum; this.inspectionCopies = ((viewResults[pNum].viewCol17 == 1)||(viewResults[pNum].viewCol17 == "1")); this.inspectVar = "&bi=0"; if(this.inspectionCopies)this.inspectVar = "&bi=1"; this.titleLink = "/primary/onix/domisbn/" + this.isbn + "?open&div=" + args['div'].replace(/\s/ig,"+") + "&cat=" + args['cat'].replace(/\s/ig, "+") + this.inspectVar + "&ed=site/primed31.nsf"; this.priceAvailability = new PriceAvailability(this.isbn); if(this.priceAvailability.price) this.price = this.priceAvailability.price; if(typeof Pack._initialized == "undefined") { Pack.prototype.isEClub = function() { if(typeof division == "undefined") { var division = ""; if(args['div'])division = unescape(args['div']); } //alert(division + ">" + this.subject + ">" + this.area); //var eClub = new eClubDiscountList(); return eClub.isDiscounted(division + ">" + this.subject + ">" + this.area); }; Pack.prototype.eClubPrice = function() { if(this.price.indexOf('$') == -1) { var nPrice = Number(this.price); } else { var nPrice = Number(this.price.substring(1)); } return (nPrice * 0.9).toFixed(2); }; Pack.prototype.printPack = function(oCart) { document.write('
'); document.write('

'); document.write('',this.title,''); document.write('

'); var publishStr = ''; if(this.published() == false) { // publishStr = '
Coming ' + this.pubDate + ''; } //alert(this.pubDate); document.write('

AU',this.price,' | ',isbn10to13(this.isbn),' ',publishStr,'

'); if(this.priceAvailability.available && this.isEClub()&&((typeof checkTC != "undefined")&&(checkTC == true))) { document.write('

eClub Price: AU$',this.eClubPrice(),'

'); } if(!this.priceAvailability.available) { document.write('

',this.priceAvailability.getShipDateString(),'

'); } if(oCart.isIsbnInCart(this.isbn)) { if(!oCart.isItemInspect(this.isbn)) { document.write('

',oCart.getItemQuantity(this.isbn),'added to order

'); } else { document.write('Inspect on Approval'); } document.write('remove from order'); } else { document.write('

'); document.write(''); //document.write(''); document.write(''); var classArray = new Array(); var anchorClass = ""; if(!this.priceAvailability.available)classArray.push('packRequest'); if(classArray.length != 0)anchorClass = 'class="' + classArray.join(' ') + '"'; document.write('add to cart'); document.write('

'); // inspect if (this.inspectionCopies) { // inspection copies only allowed if col17 = 1 document.write('Inspect on Approval'); } } document.write('
'); }; Pack.prototype.updatePack = function(packContainer, oCart) { packContainer.innerHTML = ""; this.attachPack(packContainer, oCart); }; Pack.prototype.attachPack = function(packContainer,oCart) { var pTitle = document.createElement('p'); pTitle.className = "lTitle"; var pTitleLink = document.createElement('a'); pTitleLink.setAttribute('href','#'); pTitleLink.appendChild(document.createTextNode(this.title)); pTitle.appendChild(pTitleLink); packContainer.appendChild(pTitle); var pPrice = document.createElement('p'); pPrice.className = "lPrice"; pPrice.appendChild(document.createTextNode('AU' + this.price + ' | ' + isbn10to13(this.isbn))); packContainer.appendChild(pPrice); if(this.isEClub()&&((typeof checkTC != "undefined")&&(checkTC == true))) { var ePriceContainer = document.createElement('p'); ePriceContainer.className = "eClubPrice"; ePriceContainer.appendChild(document.createTextNode('eClub Price: AU$' + this.eClubPrice())); packContainer.appendChild(ePriceContainer); } this.priceAvailability = new PriceAvailability(this.isbn); if(!this.priceAvailability.available)//if book is not available { var oNotInStock = document.createElement('p'); oNotInStock.className = 'notAvailable'; oNotInStock.appendChild(document.createTextNode(this.priceAvailability.getShipDateString())); packContainer.appendChild(oNotInStock); } if(oCart.isIsbnInCart(this.isbn)) { if(!oCart.isItemInspect(this.isbn)) { var addedToOrderContainer = document.createElement('p'); addedToOrderContainer.className = "addedToOrder"; //addedToOrderContainer.appendChild(document.createTextNode('added to order')); addedToOrderContainer.innerHTML = oCart.getItemQuantity(this.isbn) + "added to order"; packContainer.appendChild(addedToOrderContainer); } else { var inspectedApprovalContainer = document.createElement('a'); inspectedApprovalContainer.className = "inspectApproval inspectedApproval"; //inspectedApprovalContainer.setAttribute('href','#'); var inspectedApprovalText = document.createTextNode('Inspect on Approval'); inspectedApprovalContainer.appendChild(inspectedApprovalText); packContainer.appendChild(inspectedApprovalContainer); } var removeContainer = document.createElement('a'); var classArray = new Array(); var anchorClass = ""; classArray.push("removeFromOrder"); if(!this.priceAvailability.available)classArray.push('packRequest'); if(classArray.length != 0)removeContainer.className = classArray.join(' '); removeContainer.setAttribute('href','#'); if(document.attachEvent) { removeContainer.onclick = function(oEvent){removeItemFromCart();}; } else { removeContainer.setAttribute('onclick','removeItemFromCart(event)'); } var removeContainerText = document.createTextNode('remove from order'); removeContainer.appendChild(removeContainerText); packContainer.appendChild(removeContainer); } else { var buyPack = document.createElement('p'); buyPack.className = "buyPack"; var lpUnits = document.createElement('input'); lpUnits.setAttribute('type','text'); lpUnits.setAttribute('name','Num_' + this.isbn); lpUnits.setAttribute('onchange', 'thisVal=this.value;'); lpUnits.className = "lpUnits"; buyPack.appendChild(lpUnits); var lpUnitsLabel = document.createElement('label'); lpUnitsLabel.setAttribute('for','lpUnits'); var lpUnitsLabelText = document.createTextNode('Units'); lpUnitsLabel.appendChild(lpUnitsLabelText); buyPack.appendChild(lpUnitsLabel); /* var hiddenInput = document.createElement('input'); hiddenInput.setAttribute('type','hidden'); hiddenInput.setAttribute('name','Hide_' + this.isbn); hiddenInput.setAttribute('id','Hide_' + this.isbn); hiddenInput.setAttribute('value',this.passBuy); buyPack.appendChild(hiddenInput); */ var addToCartContainer = document.createElement('a'); var classArray = new Array(); var anchorClass = ""; if(!this.priceAvailability.available)classArray.push('packRequest'); if(classArray.length != 0)addToCartContainer.className = classArray.join(' '); addToCartContainer.setAttribute('href','#'); if(document.attachEvent) { addToCartContainer.onclick = function(oEvent){addItemToCart();}; } else { addToCartContainer.setAttribute('onclick','addItemToCart(event)'); } //addToCartContainer.setAttribute('onclick','changeInnerBuy(this,"' + this.innerID + '",' + thisVal + ',"' + this.isbn + '");return false;'); //addToCartContainer.onclick = function(){changeInnerBuy(this,this.innerID,thisVal,this.isbn);}; addToCartContainer.appendChild(document.createTextNode('add to cart')); buyPack.appendChild(addToCartContainer); packContainer.appendChild(buyPack); if (this.inspectionCopies) { // inspection copies only allowed if col17 = 1 var inspectApprovalContainer = document.createElement('a'); inspectApprovalContainer.className = "inspectApproval"; if(document.attachEvent) { inspectApprovalContainer.onclick = function(oEvent){addItemToCart();}; } else { inspectApprovalContainer.setAttribute('onclick','addItemToCart(event)'); } inspectApprovalContainer.setAttribute('href','#'); inspectApprovalContainer.appendChild(document.createTextNode('Inspect on Approval')); packContainer.appendChild(inspectApprovalContainer); } } }; Pack.prototype.getCartDivCatStr = function() { var oStr = new Array(); if(typeof division != "undefined")oStr.push(division); if(typeof category != "undefined") { if(typeof category == "object") { oStr.push(category[0]); oStr.push(category[1]); } else { oStr.push(category); } } return oStr.join('>'); }; Pack.prototype.addToCart = function(oCart,quantity,requestClass) { if(this.inspectionCopies) { var inspecAvailable = "I"; } else { var inspecAvailable = "B"; } this.priceAvailability = new PriceAvailability(this.isbn,quantity); if(this.priceAvailability.available) { var price = this.price; } else { var price = '0'; if(this.buyInspect.toLowerCase() == 'i')price = this.price; } /* //variable to store messages var message = null; if((!this.priceAvailability.available) && (oCart.hasUnavailableBooks() == false) && (requestClass != null && requestClass.indexOf('packRequest') != -1)) { message = 'Items that are not in stock are added to the shopping cart as requests.'; message += '\nThe cost of these items does not affect the total cost of the order.'; message += '\nOur sales department will contact customers when processing orders in order to estimate the availability and delivery of such items.'; message += '\nPlease proceed to check out for further details.'; } if((!this.priceAvailability.available) && (requestClass == null)) { message = 'The following books are not available at the quantity requested:'; message += '\n\n- ' + this.title + ' (' + this.isbn + ')'; message += '\n\n' + 'They have been added to the shopping cart as requests.'; message += '\n\nItems that are not in stock are added to the shopping cart as requests.'; message += '\nThe cost of these items does not affect the total cost of the order.'; message += '\nOur sales department will contact customers when processing orders in order to estimate the availability and delivery of such items.'; message += '\nPlease proceed to check out for further details.'; } */ oCart.addToCart(this.isbn,this.title,price,(inspecAvailable + this.buyInspect),quantity,this.getCartDivCatStr(),this.priceAvailability.available); oCart.updateShoppingSummary(); //if(message)alert(message); }; Pack.prototype.removeFromCart = function(oCart) { oCart.deleteFromCart(this.isbn); oCart.updateShoppingSummary(); }; Pack.prototype.published = function() { if(!this.pubDate)return false; var pubDate = new Date(Date.parse(this.pubDate)); var today = new Date(); if(pubDate > today)return false; return true; }; /* Pack.prototype.isPackInCart = function() { if (!thisCookie || thisCookie.indexOf(this.isbn)==-1 || typeof thisArrayCookie == "undefined") return "not in cart"; for (var i=0;i