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/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 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 published = ''; if(this.published() == false)published = 'Coming ' + this.pubDate + ''; document.write('

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

'); if(this.isEClub()&&((typeof checkTC != "undefined")&&(checkTC == true))) { 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

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

'); 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('
'); }; 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(this.price + ' | ' + isbn10to13(this.isbn))); if(this.published() != null && this.published() == false) { var oBr = document.createElement('br'); pPrice.appendChild(oBr); var oBold = document.createElement('b'); oBold.appendChild(document.createTextNode('Coming: ' + this.pubDate)); pPrice.appendChild(oBold); } 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: $' + this.eClubPrice())); packContainer.appendChild(ePriceContainer); } 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'); removeContainer.className = "removeFromOrder"; 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'); 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) { if(this.inspectionCopies) { var inspecAvailable = "I"; } else { var inspecAvailable = "B"; } oCart.addToCart(this.isbn,this.title,this.price,(inspecAvailable + this.buyInspect),quantity, this.getCartDivCatStr()); oCart.updateShoppingSummary(); /* addtoCart(this.idString,thisVal); if (getCookie('MacPrimary') && getCookie('MacPrimary')!="") { thisCookie = getCookie('MacPrimary'); thisCookieSplit = thisCookie.split(';'); thisArrayCookie = splitCookie('MacPrimary'); // split as an array } this.inCart = this.isPackInCart(); */ }; 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.published = function() { if(!this.pubDate || this.pubDate == 'undefined')return false; var splitPubDate = this.pubDate.split('/'); var pubDate = new Date(); var reDate = /^0/; 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; }; } Pack._initialized = true; //this.inCart = this.isPackInCart(); }