// Book Preview// John A. Huebner II (jhuebner@trainor.com)// for Trainor Interactive 2006// Number of pages in previewvar numberOfPages = 18;// curent page// usually set at 1 to startvar currentPage = 1;// the next few variable tell the program what page to start at for each section.// if the preview does not include a section enter a 0 (zero) for that item// front cover page usually 1var imageSet = new Array();imageSet["front"] = 1;// Copyright page;imageSet["copyright"] = 3;// Table of Contents start pageimageSet["toc"] = 6;// forward page startimageSet["forward"] = 5;// exerpt start pageimageSet["excerpt"] = 7;// Index start pageimageSet["index"] = 13;// Back cover page usually = # of pagesimageSet["back"] = 0;// border images// this is the location where the borders and arrow images are locatedvar borderImages = "images/preview/border/";// book images// this is the location of the images of the book pagesvar bookImages = "images/preview/book/";// size of book page images// widthvar bookWidth = 425;// height// note when creating images// book height must be be set so that when you subtract the arrowRowHeight and// 2 time the rowSecondHeight that the reamainder is divisable by 2// example: 550 - 72 - 2 * 27 = 424 / 2 = 212var bookHeight = 550;// left & right column widthvar columnsLeftRightWidth = 36;// top & bottom row heightvar rowTopBotHeight = 9;// second row in heightvar rowSecondHeight = 27;// arrow row heightvar arrowRowHeight = 72;// all images should be named the same as in page#.gif where number is the number of the page// image prefix as in page or whatever comes before the page numbervar imagePrefix = "pages";// image suffix, including the preciieding . (dot)var imageSuffix = ".jpg";// border image file names (see illustrator file for more information)var left1 = "left01.gif";var left2 = "left02.gif";var leftStretch = "leftstretch.gif";var leftArrowNormal = "leftArrowWhite.gif";var leftArrowHover = "leftArrowRed.gif";var left6 = "left06.gif";var left7 = "left07.gif";var right1 = "right01.gif";var right2 = "right02.gif";var rightStretch = "rightstretch.gif";var rightArrowNormal = "rightArrowWhite.gif";var rightArrowHover = "rightArrowRed.gif";var right6 = "right06.gif";var right7 = "right07.gif";var topBot = "top_bot.gif";// these next variables are calculated// table widthvar tableWidth = bookWidth + columnsLeftRightWidth * 2;// the left an right stretch areasvar stretch = (bookHeight - rowSecondHeight * 2 - arrowRowHeight) / 2;// this next section writes the CSS	document.write('<style>');	document.write('#bookPrieview a {font-weight: bold; white-space: nowrap;}');	document.write('#bookPrieview a:link, #bookPrieview a:visited {text-decoration: none;}');	document.write('#bookPrieview a:focus, #bookPrieview a:hover, #bookPrieview a:active {text-decoration: underline;}');	document.write('#bookPrieview .topbot {background: url(' + borderImages + topBot + ') repeat-x;}');	document.write('#bookPrieview .left1 {background: url(' + borderImages + left1 + ') no-repeat;}');	document.write('#bookPrieview .left2 {background: url(' + borderImages + left2 +') no-repeat;}');	document.write('#bookPrieview .leftStretch {background: url(' + borderImages + leftStretch + ') repeat-y;}');	document.write('#bookPrieview .leftArrow a {display: block; height: ' + arrowRowHeight + 'px; width: ' + columnsLeftRightWidth + 'px; margin: 0; padding: 0;}');	document.write('#bookPrieview .leftArrow a span {display: none;}');	document.write('#bookPrieview .leftArrow a:link, #bookPrieview .leftArrow a:visited {background: url(' + borderImages + leftArrowNormal + ') no-repeat;}');	document.write('#bookPrieview .leftArrow a:hover, #bookPrieview .leftArrow a:active {background: url(' + borderImages + leftArrowHover + ') no-repeat;}');	document.write('#bookPrieview .left6 {background: url(' + borderImages + left6 + ') no-repeat;}');	document.write('#bookPrieview .left7 {	background: url(' + borderImages + left7 + ') no-repeat;}');	document.write('#bookPrieview .right1 {background: url(' + borderImages + right1 + ') no-repeat;}');	document.write('#bookPrieview .right2 {background: url(' + borderImages + right2 + ') no-repeat;}');	document.write('#bookPrieview .rightStretch {background: url(' + borderImages + rightStretch + ') repeat-y;}');	document.write('#bookPrieview .rightArrow a {display: block; height: ' + arrowRowHeight + 'px; width: ' + columnsLeftRightWidth + 'px; margin: 0; padding: 0;}');	document.write('#bookPrieview .rightArrow a span {display: none;}');	document.write('#bookPrieview .rightArrow a:link, #bookPrieview .rightArrow a:visited {background: url(' + borderImages + rightArrowNormal + ') no-repeat;}');	document.write('#bookPrieview .rightArrow a:hover, #bookPrieview .rightArrow a:active {background: url(' + borderImages + rightArrowHover + ') no-repeat;}');	document.write('#bookPrieview .right6 {background: url(' + borderImages + right6 + ') no-repeat;}');	document.write('#bookPrieview .right7 {background: url(' + borderImages + right7 + ') no-repeat;}');	document.write('</style>');// the pageSetup() function creates a table in the page where the images will be shown.// the width of the table is controlled by the size of the image// the links that appear are controlled by variables in this document// images in the table are controlled by the CSS file that was loaded abovefunction pageSetup() {	var count = 0;	document.write('<a name="previewAnchor"></a>');	document.write('<table align="center" width="497" cellpadding="0" cellspacing="0" border="0" id="bookPrieview">');	document.write('<tr><td colspan="3" align="center">');	if (imageSet["front"] != 0) {		document.write('<a href="#previewAnchor" onclick="setBookImage(\'front\');">&laquo; Front &raquo;</a>');		count += 1;	}	if (imageSet["copyright"] != 0) {		if (count > 0) {			document.write('&nbsp;&nbsp;');		}		document.write('<a href="#previewAnchor" onclick="setBookImage(\'copyright\');">&laquo; Copyright &raquo;</a>');		count += 1;	}	if (imageSet["forward"] != 0) {		if (count > 0) {			document.write('&nbsp;&nbsp;');		}		document.write('<a href="#previewAnchor" onclick="setBookImage(\'forward\');">&laquo; Forward &raquo;</a>');		count += 1;	}	if (imageSet["toc"] != 0) {		if (count > 0) {			document.write('&nbsp;&nbsp;');		}		document.write('<a href="#previewAnchor" onclick="setBookImage(\'toc\');">&laquo; TOC &raquo;</a>');		count += 1;	}	if (imageSet["excerpt"] != 0) {		if (count > 0) {			document.write('&nbsp;&nbsp;');		}		document.write('<a href="#previewAnchor" onclick="setBookImage(\'excerpt\');">&laquo; Excerpt &raquo;</a>');		count += 1;	}	if (imageSet["index"] != 0) {		if (count > 0) {			document.write('&nbsp;&nbsp;');		}		document.write('<a href="#previewAnchor" onclick="setBookImage(\'index\');">&laquo; Index &raquo;</a>');		count += 1;	}	if (imageSet["back"] != 0) {		if (count > 0) {			document.write('&nbsp;&nbsp;');		}		document.write('<a href="#previewAnchor" onclick="setBookImage(\'back\');">&laquo; Back &raquo;</a>')	}	document.write('</td></tr>');	document.write('<tr><td width="' + columnsLeftRightWidth + '" height="' + rowTopBotHeight + '" class="left1"></td><td width="' + bookWidth + '" class="topbot"></td><td width="' + columnsLeftRightWidth + '" class="right1"></td></tr>');	document.write('<tr><td height="' + rowSecondHeight + '" class="left2"></td><td rowspan="5" class="bookImages"><img src="' + bookImages + imagePrefix + currentPage + imageSuffix + '" width="' + bookWidth + '" height="' + bookHeight + '" alt="book excerpt" name="pageImage" id="pageImage" class="none" /></td><td class="right2"></td></tr>');	document.write('<tr><td height="' + stretch + '" class="leftStretch"></td><td class="rightStretch"></td></tr>');	document.write('<tr><td height="' + arrowRowHeight + '" class="leftArrow"><a href="#previewAnchor" onclick="prevBookImage();"><span>prev</span></a></td><td class="rightArrow"><a href="#previewAnchor" onclick="nextBookImage();"><span>next</span></a></td></tr>');	document.write('<tr><td height="' + stretch + '" class="leftStretch"></td><td class="rightStretch"></td></tr>');	document.write('<tr><td height="' + rowSecondHeight + '" class="left6"></td><td class="right6"></td></tr>');	document.write('<tr><td height="' + rowTopBotHeight +  '" class="left7"></td><td class="topbot"></td><td class="right7"></td></tr>');	document.write('<tr><td colspan="3" align="center"><a href="#previewAnchor" onclick="prevBookImage();">&laquo; Previous &raquo;</a>&nbsp;&nbsp;<a href="#previewAnchor" onclick="nextBookImage();">&laquo; Next &raquo;</a></td></tr>');	document.write('</table>');	return;}// set image function called by other functions to actually set the image src for book pagefunction setImageSrc(page) {		document.pageImage.src = bookImages + imagePrefix + page + imageSuffix;		return;	}// set book image is called by the links to different sectionsfunction setBookImage(page) {	if (imageSet[page] != 0) {		currentPage = imageSet[page];		setImageSrc(currentPage);	}	return;}function nextBookImage() {	if (currentPage < numberOfPages) {		currentPage += 1;		setImageSrc(currentPage);	}	return;}function prevBookImage() {	if (currentPage > 1) {		currentPage -= 1;		setImageSrc(currentPage);	}	return;	}