Book.prototype.attachBook = function(bookContainer,oCart,oImgSrc,oImgWidth,oImgHeight) { var bImg = document.createElement('img'); bImg.setAttribute('src',oImgSrc); if(oImgSrc.indexOf('oCover') != -1) { oImgHeight = "108"; oImgWidth = "91"; } bImg.setAttribute('width',oImgWidth); bImg.setAttribute('height',oImgHeight); bImg.setAttribute('alt',this.title); bImg.setAttribute('id','cover_' + this.isbn); var bImgContainer = document.createElement('div'); bImgContainer.className = "imgContainer"; bImgContainer.appendChild(bImg); if(this.pubDate != "undefined") { var oDate = new Date(Date.parse(this.pubDate)); var dToday = new Date(); var one_day = 1000*60*60*24; var days = Math.floor((dToday - oDate) / one_day); if(days <= 180) { var oDiv = document.createElement('div'); oDiv.className = "labelNew"; oDiv.style.bottom = (parseInt(oImgHeight) - 45) + "px"; oDiv.style.left = (parseInt(oImgWidth) - 28) +"px"; bImgContainer.appendChild(oDiv); } } bookContainer.appendChild(bImgContainer); var titleLink = document.createElement('a'); titleLink.setAttribute('href',this.titleLink); titleLink.setAttribute('title',this.title); var titleLinkText = document.createTextNode(this.title); titleLink.appendChild(titleLinkText); var titleLinkContainer = document.createElement('p'); titleLinkContainer.className = "bTitle"; titleLinkContainer.appendChild(titleLink); bookContainer.appendChild(titleLinkContainer); var bPriceIsbnContainer = document.createElement('p'); var bPriceText = ""; if(this.price.toString().indexOf('$') == -1) { this.price = parseFloat(this.price).toFixed(2); bPriceText = "$" + this.price + " | "; } else { bPriceText = this.price + " | "; } bPriceIsbnContainer.appendChild(document.createTextNode(bPriceText + isbn10to13(this.isbn))); bookContainer.appendChild(bPriceIsbnContainer); this.priceAvailability = new PriceAvailability(this.isbn); if(this.isEClub()&&((typeof checkTC != "undefined")&&(checkTC == true))) { var ePriceContainer = document.createElement('p'); ePriceContainer.className = "eClubPrice"; ePriceContainer.appendChild(document.createTextNode('eClub Price: $' + this.eClubPrice())); bookContainer.appendChild(ePriceContainer); } if(!this.priceAvailability.available)//if book is not available { var oNotInStock = document.createElement('p'); oNotInStock.className = 'notAvailable'; oNotInStock.appendChild(document.createTextNode(this.priceAvailability.getShipDateString())); bookContainer.appendChild(oNotInStock); } if(oCart.isIsbnInCart(this.isbn)) { if(!oCart.isItemInspect(this.isbn)) { var addedToOrderContainer = document.createElement('p'); var classArray = new Array(); var anchorClass = ""; classArray.push('addedToOrder'); if(!this.priceAvailability.available)classArray.push('bookRequest'); if(classArray.length != 0)addedToOrderContainer.className = classArray.join(' '); addedToOrderContainer.innerHTML = oCart.getItemQuantity(this.isbn) + "added to order"; bookContainer.appendChild(addedToOrderContainer); var removeContainer = document.createElement('a'); var classArray = new Array(); var anchorClass = ""; classArray.push('removeFromOrder'); if(!this.priceAvailability.available)classArray.push('bookRequest'); 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); bookContainer.appendChild(removeContainer); } else { var removeContainer = document.createElement('a'); removeContainer.className = "removeInspect"; 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); bookContainer.appendChild(removeContainer); } } else { var spanTag = document.createElement('span'); //if(this.priceAvailability.available)//if book is not available //{ var bUnits = document.createElement('input'); bUnits.setAttribute('type','text'); bUnits.setAttribute('name','Num_' + this.isbn); bUnits.setAttribute('onchange', 'thisVal=this.value;'); bUnits.className = "bUnits"; spanTag.appendChild(bUnits); var bUnitsLabel = document.createElement('label'); bUnitsLabel.setAttribute('for','bUnits'); var bUnitsLabelText = document.createTextNode('Units'); bUnitsLabel.appendChild(bUnitsLabelText); spanTag.appendChild(bUnitsLabel); //} var addToCartContainer = document.createElement('a'); addToCartContainer.setAttribute('href','#'); var classArray = new Array(); var anchorClass = ""; if(!this.priceAvailability.available)classArray.push('bookRequest'); if(classArray.length != 0)addToCartContainer.className = classArray.join(' '); if(document.attachEvent) { addToCartContainer.onclick = function(oEvent){addItemToCart();}; } else { addToCartContainer.setAttribute('onclick','addItemToCart(event)'); } var addToCartContainerText = document.createTextNode('add to cart'); addToCartContainer.appendChild(addToCartContainerText); spanTag.appendChild(addToCartContainer); var buyBook = document.createElement('p'); buyBook.className = "buyBook"; buyBook.appendChild(spanTag); bookContainer.appendChild(buyBook); 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','#'); var inspectApprovalText = document.createTextNode('Inspect on Approval'); inspectApprovalContainer.appendChild(inspectApprovalText); bookContainer.appendChild(inspectApprovalContainer); } } /* if(!this.priceAvailability.available)//if book is not available { var oNotInStock = document.createElement('p'); oNotInStock.className = 'notAvailable'; oNotInStock.appendChild(document.createTextNode('Not in stock')); bookContainer.appendChild(oNotInStock); } */ }; Book.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('>'); }; Book.prototype.addToCart = function(oCart, quantity, requestClass) { if(this.inspectionCopies) { var inspecAvailable = "I"; } else { var inspecAvailable = "B"; } var price = this.price; /* 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('bookRequest') != -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 || requestClass == 'addToOrder')) { 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); }; Book.prototype.removeFromCart = function(oCart) { oCart.deleteFromCart(this.isbn); oCart.updateShoppingSummary(); }; /* Book.prototype.printPrintBook = function(oCart) { document.write('',this.title,''); document.write(''); document.write(''); document.write('$ ',(parseFloat(this.price)).toFixed(2),'|'); document.write(''); document.write('Units'); document.write(''); document.write('',(this.subject + " > " + this.area + " > " + this.series) ,''); }; */ Book.prototype.printPrintBook = function(oCart) { document.write('
'); document.write(''); document.write('ISBN:',isbn10to13(this.isbn),''); document.write('',(this.subject + " > " + this.area + " > " + this.series),''); document.write('
'); document.write(''); document.write('$',(parseFloat(this.price)).toFixed(2),''); document.write(''); document.write('Units'); document.write('
'); }; /* Book.prototype.checkNewLabel = function() { alert(typeof this.pubDate + " [" + this.puDate + "]"); document.write(''); var oD = new Date(Date.parse("01/20/2008")); var oDate = new Date(); var one_day=1000*60*60*24; alert(oDate.toString() + " " + oD.toString() + " " + ((oDate.getTime() - oD.getTime())/one_day)); }; */