/* function isbn10to13(isbn) { if(isbn.length == 10) { return convISBN10toISBN13(preEditISBN(isbn)); } else { return isbn; } } */ 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]; /* target.onload = function() { //checkNew(target, target.width, target.height); resizeImg(target); }; */ } 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, nWidth, 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(viewResults[pNum].viewCol5 != 'undefined' && getPubDate(unescape(viewResults[pNum].viewCol5)) != "undefined") { var splitPubDate = (unescape(viewResults[pNum].viewCol5)).split('/'); var oDate = new Date(); var reDate = /^0/; //var day = (splitPubDate[0].substring(0,1) == '0') ? splitPubDate[0].substring(1) : splitPubDate[0]; //var month = (splitPubDate[1].substring(0,1) == '0') ? splitPubDate[1].substring(1) : splitPubDate[1]; var day = (reDate.test(splitPubDate[0]) == true) ? splitPubDate[0].substring(1) : splitPubDate[0]; var month = (reDate.test(splitPubDate[1]) == true) ? splitPubDate[1].substring(1) : splitPubDate[1]; var year = splitPubDate[2]; oDate.setFullYear(parseInt(year),((parseInt(month)) - 1),parseInt(day)); var dToday = new Date(); /* alert(unescape(viewResults[pNum].viewCol5) + '\n[' + day + '][' + month + '][' + year + ']' + '\npuDate: ' + oDate.toString() + '\ncurrentDate: ' + dToday.toString()); */ 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) { //if date is in GTM String format if(pubDate.indexOf('/') == -1) { var oRe = /,?\s/gi; var dateSplit = pubDate.split(oRe); var month = null; var months = ['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec']; for(var i = 0; i < months.length; i++) { if(pubDate.toLowerCase().indexOf(months[i]) != -1) { month = (i < 10) ? '0' + (i + 1).toString() : (i + 1); } } if(month == null)return 'undefined'; var day = (dateSplit[1].length == 1) ? '0' + dateSplit[1] : dateSplit[1]; return (day + '/' + month + '/' + dateSplit[2]); } else { /* 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"; } */ return pubDate; } } 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"; //link for book title this.inspectVar = "&bi=0"; if(this.inspectionCopies)this.inspectVar = "&bi=1"; this.titleLink = "/primary/newonix/domisbn/" + this.isbn + "?open&div=" + args['div'].replace(/\s/ig,"+") + "&cat=" + args['cat'].replace(/\s/ig, "+") + this.inspectVar + "&ed=site/primed3.nsf"; 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('
'); document.write('

',this.title,'

'); document.write('

Series: ',this.series,'

'); document.write('

Author: ',this.author,'

'); 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.published() != null && this.published() == false) { document.write('

Coming: ',this.pubDate,'

'); } document.write('
'); if(oCart.isIsbnInCart(this.isbn)) { if(!oCart.isItemInspect(this.isbn)) { document.write('',oCart.getItemQuantity(this.isbn),'added to order'); document.write('remove from order'); } else { document.write('inspected on approval'); } } else { document.write('
'); document.write(''); document.write('
'); document.write(''); document.write('add to order'); if (this.inspectionCopies) { document.write('inspect on approval'); } } document.write('
'); document.write('
'); } Book.prototype.getExtraClass = function() { var locSearch = document.location.toString(); if(locSearch.indexOf("Search+results") != -1)return ""; var reAt = /literacy/i; if(args['div'] && reAt.test(unescape(args['div']))) return ""; return " bookMargin"; }; Book.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); }; Book.prototype.printBook = function(oCart) { document.write('
'); document.write('
',this.title,''); //this.checkNewLabel(); document.write('
'); document.write('

',this.title,'

'); var isbnString = new Array(); var published = ''; if(this.published() != null && this.published() == false)published = 'Coming ' + this.pubDate + ''; if(this.price.toString().indexOf('$') == -1) { this.price = parseFloat(this.price).toFixed(2); document.write('

$',this.price,' | ',isbn10to13(this.isbn),' ',published,'

'); } else { document.write('

',this.price,' | ',isbn10to13(this.isbn),' ',published,'

'); } if(this.isEClub()) { document.write('

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

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

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

'); document.write('remove from order'); } else { document.write('remove inspected item from order'); } } else { document.write('

'); document.write(''); document.write(''); 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('
'); }; Book.prototype.updateBookDetail = function(cartContainer,oCart) { cartContainer.innerHTML = ""; 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'); aremoveFromOrder.className = "removeFromOrder"; 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'); aaddToOrder.className = "addToOrder"; 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); } } }; 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 || this.pubDate == 'undefined')return null; var splitPubDate = this.pubDate.split('/'); var pubDate = new Date(); var reDate = /^0/; //var day = (splitPubDate[0].length == 2 && splitPubDate[0].substring(0,0) == '0') ? splitPubDate[0].substring(1) : splitPubDate[0]; //var month = (splitPubDate[1].length == 2 && splitPubDate[1].substring(0,0) == '0') ? splitPubDate[1].substring(1) : splitPubDate[1]; var day = (reDate.test(splitPubDate[0]) == true) ? splitPubDate[0].substring(1) : splitPubDate[0]; var month = (reDate.test(splitPubDate[1]) == true) ? splitPubDate[1].substring(1) : splitPubDate[1]; var year = splitPubDate[2]; pubDate.setFullYear(parseInt(year),((parseInt(month)) - 1),parseInt(day)); var today = new Date(); if(pubDate > today) { //alert(this.title + '\npubDate: ' + this.pubDate + '--' + pubDate.toGMTString() + '> currentDate: ' + today.toGMTString()); return false; } return true; }; } Book._initialized = true; }