//Book Classvar bookList;function BookDetails (){	this.initialise =  initialise;;	this.generateViewHTML = generateViewHTML;	this.setFieldValue = setFieldValue;	this.getImageURL = getImageURL;	this.listNumber;	this.quantity;	this.generateDocumentHTML = generateDocumentHTML;	this.createCartActions = createCartActions;	this.generateContribHTML = generateContribHTML;	this.generateCategoryHTML = generateCategoryHTML;	this.clone = clone;	this.isInCart = false;						//wether we are in the cart yet or not	this.roundPrice = roundPrice;		function clone(s) {		for(p in s)		this[p] = (typeof(s[p]) == 'object')? new clone(s[p]) : s[p];	}	function roundPrice ()	{		var rightDigit;		var incremented = false;				if (this.price.toString().indexOf(".") > 0)		{			//Decimals so round the price							//round it to 2 decimalplaced			this.price = this.price.toString().substring (0, this.price.toString().indexOf (".")+ 3) *1;					rightDigit = this.price.toString().substring (this.price.toString().length -1) * 1; 			if (rightDigit > 0 && rightDigit < 5)			{ 				rightDigit = 5;			}					if (rightDigit > 5)			{				rightDigit = 0;				incremented = true;			}		  			var nPrice = (this.price.toString().substring(0, this.price.toString().length-1)+ rightDigit) * 1;					if (incremented == true)			{				//We need to add .1 to the price this will increment the rest				nPrice = nPrice + .1;			}					this.price = nPrice;			}	}		//sets the field values form the entered xml doc	function initialise (cDoc)	{		this.quantity = 0;		var fieldName = "";		var fieldValue = "";				//first lets default all our values to "" incase we never set them		this.ean = "";		this.isbn = "";		this.title = "";		this.price = 0;		this.description = "";		this.unid = "";		this.contributor1 = "";		this.contributor1Role = "";		this.contributor2 = "";		this.contributor2Role = "";		this.contributor3 = "";		this.contributor3Role = "";		this.shortTitle = "";		this.publisher="";		this.publicationDate="";		this.binding="";		this.bisac1="";		this.bisac2="";		this.bisac3="";		this.series="";		this.imageLocation="";						this.viewDescription = "";  //this is a shorter version of product description - so if the description is massive we dont pollute the view				var entryData = cDoc.getElementsByTagName ("entrydata");		var valNode;		for (var i=0; i < entryData.length; i++){			fieldName = entryData[i].getAttribute("name");			for (var j=0; j<entryData[i].childNodes.length; j++)			{				if (entryData[i].childNodes[j].nodeValue != "\n") valNode = entryData[i].childNodes[j]			}			if (valNode.firstChild)			{				fieldValue = valNode.firstChild.nodeValue;			}else			{				//empty value				fieldValue = "";			}			this.setFieldValue (fieldName, fieldValue);		} //end for					//check if we're in the cart		cart.isMember (this);					} //end initialiseProduct	function setFieldValue (fieldName, fieldValue)	{		//based on the field name (case statement) we set the required variable, add a case for		//each variable we need.		switch (fieldName.toUpperCase())		{			case "TITLE":				this.title = fieldValue.replace (/'/g, "&#39;");				break;			case "EAN":				this.ean = fieldValue;				break;			case "CONTRIBUTOR1":				this.contributor1 = fieldValue.replace (/'/g, "&#39;");				break;			case "CONTRIBUTOR1ROLE":				this.contributor1Role = fieldValue.replace (/'/g, "&#39;");				break;			case "CONTRIBUTOR2":				this.contributor2 = fieldValue.replace (/'/g, "&#39;");				break;			case "CONTRIBUTOR2ROLE":				this.contributor2Role = fieldValue.replace (/'/g, "&#39;");				break;			case "CONTRIBUTOR3":				this.contributor3 = fieldValue.replace (/'/g, "&#39;");				break;			case "CONTRIBUTOR3ROLE":				this.contributor3Role = fieldValue.replace (/'/g, "&#39;");				break;			case "DESCRIPTION":				this.Description = fieldValue.replace (/'/g, "&#39;");				this.viewDescription = fieldValue.slice (0, 150).replace (/'/g, "&#39;");				if (this.Description.length > 150)				{					this.viewDescription += " ... ";				}				break;			case "PRICE":				this.price = fieldValue * 1;				this.price = this.price / 1.73;  //original value				this.price = this.price * 1.70;	 //new price multiplier - change this as needed				this.roundPrice ();				break;			case "ISBN":				this.isbn = fieldValue;				break;				case "UNID":				this.unid=fieldValue;				break;			case "SHORTTITLE":				this.shortTitle=fieldValue.replace (/'/g, "&#39;");				break;			case "PUBLISHER":				this.publisher=fieldValue.replace (/'/g, "&#39;");				break;			case "PUBLICATIONDATE":				this.publicationDate=fieldValue;				break;			case "BINDINGTYPE":				this.binding=fieldValue.replace (/'/g, "&#39;");				break;			case "BISAC1":				this.bisac1=fieldValue.replace (/'/g, "&#39;");				break;			case "BISAC2":				this.bisac2=fieldValue.replace (/'/g, "&#39;");				break;			case "BISAC3":				this.bisac3=fieldValue.replace (/'/g, "&#39;");				break;						case "SERIES":				this.series=fieldValue.replace (/'/g, "&#39;");				break;			case "IMAGELOCATION":				this.imageLocation=fieldValue.replace (/'/g, "&#39;");				break;			default:				//nothing			} //end switch	} //end setFieldValue		function createCartActions ()	{		var addToCart = "<a href=\"#\" onClick=\"cart.addToCart (documentList[" + this.listNumber + "]); hideDocumentBox (); return false;\">Add to cart </a>";		var removeFromCart = "<a href=\"#\" onClick=\"cart.removeFromCart (documentList[" + this.listNumber + "]); hideDocumentBox (); return false;\">Remove from cart </a>";				var html;		if (cart.isMember (this)) 		{			html = removeFromCart;		}else		{			html = addToCart;		}				html += sp + sp + "<a href=\"#\" onClick=\"hideDocumentBox (); return false;\"> Close <a>";					return  html;	}			function generateDocumentHTML ()	{		//header		html = htmlStartTag ("table", "", "", "") + "<tr><td>" + htmlStartTag ("div", "FloatLeft noImageBG", "", "") + this.getImageURL () + de;		html += "</td><td>"		html += htmlStartTag ("div", "ContentHeader", "", "") + this.title+ de;		//main document details		html += htmlStartTag ("span", "ViewDocument", "", "") + htmlStartTag ("span", "bold", "", "") + "EAN:" +se +sp + this.ean + sp + sp + sp 		html += htmlStartTag ("span", "bold", "", "") + "ISBN:" + se + sp + this.isbn + se + "<br>";		html += htmlStartTag ("span", "ViewDocument", "", "");		html += htmlStartTag ("span", "bold", "", "") + "Price:" +se+sp+  formatCurrency(this.price) + " (ex-GST)<br>";		html += htmlStartTag ("span", "bold", "", "") + "Publisher:" +se+sp + this.publisher+"<br>";		html += htmlStartTag ("span", "bold", "", "") + "Publication Date:" +se+sp + this.publicationDate + "<br>";		html += htmlStartTag ("span", "bold", "", "") + "Binding:" +se+sp+ this.binding + se + ce + re + te;		html += htmlStartTag ("span", "ViewDocument", "", "");		html += this.generateContribHTML () + "<br><br>" ;		html += htmlStartTag ("span", "bold", "", "") + "Summary:" + se + "<br>";				html += this.Description  + "<br><br>";		html += htmlStartTag ("span", "bold", "", "") + "BISAC Categories:" +se + "<br>" + this.generateCategoryHTML ();		if (this.series != "") 		{		html += "<br><br>" + htmlStartTag ("span", "bold", "", "") + "Series:" +se + "<br>" 		html +=	"<a href='#' onClick='resetScreen (); vPosition=1; viewName=\"vw.Eastend.WebAllBySeries\"; retrieveViewDocuments (\"" +this.series+"\"); return false;'>"+this.series+"</a>";;		}				html += se;						html += htmlStartTag ("div", "ShoppingCartActions", "", "" ) + this.createCartActions () + de;				return html;	}// end generateDocumentHTML 			function generateViewHTML (itemNumber)	{		var html = "";		html = htmlStartTag ("table", "", "", "viewDoc" + itemNumber) + "<tr>";				html +=  "<td><div class='FloatLeft noImageBG'>" + this.getImageURL () + "</div><span class= 'ContentHeader ViewDocument'><a href='#' onclick='loadDocument(\"" + this.unid + "\", true, \"DocumentDetails\", \"viewDoc" + itemNumber + "\"); return false;'>" + this.shortTitle+ "</a>" +"</span><br>";		html += "<span class='ViewDocument'>" + "EAN:" +sp+ this.ean+ "<br>"		html +=  "Price:" +sp+ formatCurrency(this.price) + " (ex-GST)<br>";		html += "Publication Date:" +sp + this.publicationDate + "<br>"+ ce + re;		html += "<tr><td><span class='ViewDocument'>"+this.generateContribHTML () + "<br><br>";		html += this.viewDescription  + "</span>";		html += ce;				html += re + te;		return html;		} // end generateViewHTML	function getImageURL ()	{		var imgURL = "";		var itemNumber = this.listNumber + 1;		var src = "";				if (this.imageLocation == "") 		{			src="/ImagesDIR/"+ this.ean +".jpg";		}else		{		 src = this.imageLocation;		}		//imgURL = "<img alt='" + this.shortName + "' src='" + webImagePath + "/im.WebSite.NoImage' />";		imgURL = "<img class=\"hidden\" id=\"img" + this.listNumber + "\" alt='" + this.shortTitle + "' src='" + src + "' onclick=\"loadDocument('" + this.unid + "', true, 'DocumentDetails', 'viewDoc" + itemNumber + "'); return false;\" onLoad=\"checkImageFound (document.getElementById ('img" + this.listNumber + "')); return false;\"/>";		return imgURL;	} // end getImageURL	function generateContribHTML ()	{		var contribHTML ="<span class='bold'>Contributor(s):</span><br>";				if (this.contributor1Role && this.contributor1) contribHTML += "<a href='#' onClick='resetScreen (); vPosition=1; viewName=\"vw.Eastend.WebAllByContrib\"; retrieveViewDocuments (\""+ this.contributor1 +"\"); return false;'>"+ this.contributor1 +sp+ "("+ this.contributor1Role +")</a>";		if (this.contributor2Role && this.contributor2) contribHTML += "," + sp + sp + "<a href='#' onClick='resetScreen (); vPosition=1; viewName=\"vw.Eastend.WebAllByContrib\"; retrieveViewDocuments (\""+ this.contributor2 +"\"); return false;'>"+ this.contributor2 +sp+ "("+ this.contributor2Role +")</a>";		if (this.contributor3Role && this.contributor3) contribHTML += "," + sp + sp + "<a href='#' onClick='resetScreen (); vPosition=1; viewName=\"vw.Eastend.WebAllByContrib\"; retrieveViewDocuments (\""+ this.contributor3 +"\"); return false;'>"+ this.contributor3 +sp+ "("+ this.contributor3Role +")</a>";		return (contribHTML);	} // end generateContribHTML	function  generateCategoryHTML ()	{			var bisacHTML = "";			if (this.bisac1) bisacHTML += "<a href='#' onClick='resetScreen (); vPosition=1; viewName=\"vw.Eastend.WebAllByCategory\"; retrieveViewDocuments (\"" +this.bisac1+"\"); return false;'>"+this.bisac1+"</a>";			if (this.bisac2) bisacHTML += "," + sp + sp +"<a href='#' onClick='resetScreen (); vPosition=1; viewName=\"vw.Eastend.WebAllByCategory\"; retrieveViewDocuments (\"" +this.bisac2+"\"); return false;'>"+this.bisac2+"</a>";			if (this.bisac3) bisacHTML += "," + sp + sp +"<a href='#' onClick='resetScreen (); vPosition=1; viewName=\"vw.Eastend.WebAllByCategory\"; retrieveViewDocuments (\"" +this.bisac3+"\"); return false;'>"+this.bisac3+"</a>";						return (bisacHTML);	} //end generateCategoryHTML}
