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 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 dToday = new Date();
var one_day = 1000*60*60*24;
var days = Math.floor((dToday - pubDate) / 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 published = '';
if(this.published() != null && this.published() == false)published = '
Coming ' + this.pubDate + '';
var bPriceIsbnContainer = document.createElement('p');
if(this.price.toString().indexOf('$') == -1)
{
this.price = parseFloat(this.price).toFixed(2);
var bPriceIsbnText = document.createTextNode("$" + this.price + " | " + isbn10to13(this.isbn));
} else {
var bPriceIsbnText = document.createTextNode(this.price + " | " + isbn10to13(this.isbn));
}
bPriceIsbnContainer.appendChild(bPriceIsbnText);
if(this.published() != null && this.published() == false)
{
var oBr = document.createElement('br');
bPriceIsbnContainer.appendChild(oBr);
var oBold = document.createElement('b');
oBold.appendChild(document.createTextNode('Coming: ' + this.pubDate));
bPriceIsbnContainer.appendChild(oBold);
}
bookContainer.appendChild(bPriceIsbnContainer);
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(oCart.isIsbnInCart(this.isbn))
{
if(!oCart.isItemInspect(this.isbn))
{
var addedToOrderContainer = document.createElement('p');
addedToOrderContainer.className = "addedToOrder";
addedToOrderContainer.innerHTML = oCart.getItemQuantity(this.isbn) + "added to order";
bookContainer.appendChild(addedToOrderContainer);
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);
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');
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','#');
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);
}
}
};
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)
{
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();
};
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('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)); }; */