function reloadImage(source){ var target = source; var isbn = target.id.substring(6); var images = [("http://www.macmillan.com.au/mea/covers/" + isbn + ".jpg"),("templates/layout/$file/noCover.gif")]; var index = 1;if(target.src.indexOf(convISBN10toISBN13(preEditISBN(isbn))) != -1) index = 0;target.src = images[index]; } function resizeImg(source){ if(source.width > 108){ var percentage = ((108*100)/source.width)/100;var nHeight = Math.floor(source.height * percentage);var nWidth = Math.floor(source.width * percentage); if(nHeight > 131){ percentage = ((131*100)/nHeight)/100; nHeight = Math.floor(nHeight * percentage); nWidth = Math.floor(nWidth * percentage); } source.width = nWidth;source.height = nHeight; }else if(source.height > 131){ var percentage = ((131*100)/source.height)/100;var nHeight = Math.floor(source.height * percentage);var nWidth = Math.floor(source.width * percentage); if(nWidth > 108){ percentage = ((108*100)/nWidth)/100;nHeight = Math.floor(nHeight * percentage);nWidth = Math.floor(nWidth * percentage) } source.width = nWidth;source.height = nHeight; } checkNew(source, source.width, source.height); } function checkNew(source, nWidth, nHeight){ var oParent = source.parentNode;var oBookContainer = oParent.parentNode;var pNum = oBookContainer.getAttribute('id').substr(4); if(getPubDate(unescape(viewResults[pNum].viewCol5)) != "undefined") { var oDate = new Date(Date.parse(getPubDate(unescape(viewResults[pNum].viewCol5)))); 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 = (nHeight - 45) + "px"; oDiv.style.left = (nWidth - 28) +"px"; oParent.appendChild(oDiv); } } } function getPubDate(pubDate){var oSplitDate = pubDate.split("/");if(oSplitDate.length > 1){var oTemp = oSplitDate[1];oSplitDate[1] = oSplitDate[0];oSplitDate[0] = oTemp;return oSplitDate.join('/');} else {return "undefined";} } function Book(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.author = unescape(viewResults[pNum].viewCol4).replace(/,/ig,", "); this.summary = unescape(viewResults[pNum].viewCol10); this.buyInspect = ""; this.isAvail = checkIsAvailable(unescape(viewResults[pNum].viewCol5)); this.inspectionCopies = ((viewResults[pNum].viewCol17 == 1)||(viewResults[pNum].viewCol17 == "1")); this.imgSrc = "/files/" + convISBN10toISBN13(preEditISBN(this.isbn)) + ".jpg"; 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"; //load availability and price from new database this.priceAvailability = new PriceAvailability(this.isbn); if(this.priceAvailability.price) { this.price = this.priceAvailability.price; } if(typeof Book._initialized == "undefined") { Book.prototype.isEClub = function() { if(typeof division == "undefined") { var division = ""; if(args['div'])division = unescape(args['div']); } var discounted = eClub.isDiscounted(division + ">" + this.subject + ">" + this.area); return discounted; }; Book.prototype.printBookDetailPage = function(oCart) { document.write('
',this.title,'
'); document.write('Series: ',this.series,'
'); document.write(''); document.write('ISBN: ',isbn10to13(this.isbn),'
'); if(this.price.toString().indexOf('$') == -1) { this.price = parseFloat(this.price).toFixed(2); document.write('Price: $',this.price,'
'); } else { document.write('Price: ',this.price,'
'); } if(this.isEClub()) { document.write('eClub Price: $',this.eClubPrice(),'
'); } if(!this.priceAvailability.available) { document.write('',this.priceAvailability.getShipDateStringBookDetail(),'
'); } document.write('',priceIsbnString,'
'); this.printBookForm(oCart); document.write('eClub Price: $',this.eClubPrice(),'
'); } if(!this.priceAvailability.available)//if book is not 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
'); var classArray = new Array(); var anchorClass = ""; classArray.push('removeFromOrder'); if(!this.priceAvailability.available)classArray.push('bookRequest'); if(classArray.length != 0)anchorClass = 'class="' + classArray.join(' ') + '"'; document.write('remove from order'); } else { document.write('remove inspected item from order'); } } else { document.write(''); //if(this.priceAvailability.available)//if book is not available //{ document.write(''); document.write(''); //} var classArray = new Array(); var anchorClass = ""; if(!this.priceAvailability.available)classArray.push('bookRequest'); 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 var classArray = new Array(); var anchorClass = ""; classArray.push('inspectApproval'); if(!this.priceAvailability.available)classArray.push('bookRequest'); if(classArray.length != 0)anchorClass = 'class="' + classArray.join(' ') + '"'; document.write('Inspect on Approval'); } } }; Book.prototype.updateBookDetail = function(cartContainer,oCart) { cartContainer.innerHTML = ""; this.priceAvailability = new PriceAvailability(this.isbn); /* if(!this.priceAvailability.available) { cartContainer.innerHTML = 'Not in stock
'; return; } */ if(oCart.isIsbnInCart(this.isbn)) { if(!oCart.isItemInspect(this.isbn)) { var addedToOrder = document.createElement('span'); addedToOrder.className = "addedToOrder"; addedToOrder.innerHTML = oCart.getItemQuantity(this.isbn) + 'added to order'; cartContainer.appendChild(addedToOrder); var aremoveFromOrder = document.createElement('a'); var classArray = new Array(); var anchorClass = ""; classArray.push('removeFromOrder'); if(!this.priceAvailability.available)classArray.push('bookRequest'); if(classArray.length != 0)aremoveFromOrder.className = classArray.join(' '); aremoveFromOrder.setAttribute('href','#'); aremoveFromOrder.innerHTML = "remove from order"; if(document.attachEvent) { aremoveFromOrder.onclick = function(oEvent){removeItemFromCart();}; } else { aremoveFromOrder.setAttribute('onclick','removeItemFromCart(event)'); } cartContainer.appendChild(aremoveFromOrder); } else { var removeInspect = document.createElement('a'); removeInspect.className = "inspected"; removeInspect.setAttribute('href','#'); removeInspect.innerHTML = "remove inspected item from order"; if(document.attachEvent) { removeInspect.onclick = function(oEvent){removeItemFromCart();}; } else { removeInspect.setAttribute('onclick','removeItemFromCart(event)'); } cartContainer.appendChild(removeInspect); } } else { var units = document.createElement('input'); units.setAttribute('type','text'); units.setAttribute('name','bUnits'); units.className = "bUnits"; var unitsContainer = document.createElement('div'); unitsContainer.setAttribute('id','bUnitsContainer'); unitsContainer.appendChild(units); cartContainer.appendChild(unitsContainer); var unitsLabel = document.createElement('label'); unitsLabel.setAttribute('for','bUnits'); cartContainer.appendChild(unitsLabel); var aaddToOrder = document.createElement('a'); var classArray = new Array(); var anchorClass = ""; classArray.push('addToOrder'); if(!this.priceAvailability.available)classArray.push('bookRequest'); if(classArray.length != 0)aaddToOrder.className = classArray.join(' '); aaddToOrder.setAttribute('href','#'); aaddToOrder.innerHTML = "add to order"; if(document.attachEvent) { aaddToOrder.onclick = function(oEvent){addItemToCart();}; } else { aaddToOrder.setAttribute('onclick','addItemToCart(event)'); } cartContainer.appendChild(aaddToOrder); if (this.inspectionCopies) { var inspect = document.createElement('a'); inspect.className = "inspect"; inspect.setAttribute('href','#'); inspect.innerHTML = "inspect on approval"; if(document.attachEvent) { inspect.onclick = function(oEvent){addItemToCart();}; } else { inspect.setAttribute('onclick','addItemToCart(event)'); } cartContainer.appendChild(inspect); } } /* if(!this.priceAvailability.available) { var oP = document.createElement('p'); oP.className = 'notAvailable'; oP.appendChild(document.createTextNode(this.priceAvailability.getShipDateString())); cartContainer.appendChild(oP); } */ }; Book.prototype.updateBook = function(bookContainer,oCart) { var oImgContainer = document.getInnerElementByClassName(bookContainer,'div','imgContainer'); var oImg = oImgContainer.getElementsByTagName('img')[0]; var oImgSrc = oImg.src; var oImgWidth = oImg.width; var oImgHeight = oImg.height; bookContainer.innerHTML = ""; this.attachBook(bookContainer, oCart, oImgSrc, oImgWidth, oImgHeight); }; Book.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; }; } Book._initialized = true; }