// JavaScript Document /* Fields */ var flipBookLocks = new Array(); /* Functions */ function FlipBookImg(id, fadeTime, imgPathNormal, imgPathCurrent, imgExtension, hover, hoverPathOut, hoverPathOver) { this.lockID = id; this.book = toLayer(id); this.fadeTime = (fadeTime == null) ? 0 : fadeTime; this.page = id + '_Page_0'; this.link = null; this.imgPathNormal = imgPathNormal; this.imgPathCurrent = imgPathCurrent; this.imgExtension = imgExtension; this.hover = (hover == null) ? false : hover; if(this.hover) { this.hoverPathOut = (hoverPathOut == null) ? 'Out/' : hoverPathOut; this.hoverPathOver = (hoverPathOver == null) ? 'Over/' : hoverPathOver;; } else { this.hoverPathOut = ''; this.hoverPathOver = ''; } flipBookLocks[this.lockID] = false; var bookNodes = this.book.childNodes; for(var i = 0; i < bookNodes.length; i++) { if(bookNodes[i].id == id + '_Links') { var first = true; var linkNodes = bookNodes[i].childNodes; for(var j = 0; j < linkNodes.length; j++) { if(linkNodes[j].tagName == 'A') { if(first) { linkNodes[j].childNodes[0].src = this.imgPathCurrent + this.hoverPathOut + linkNodes[j].childNodes[0].alt + this.imgExtension; this.link = linkNodes[j]; first = false; linkNodes[j].current = true; } else { linkNodes[j].childNodes[0].src = this.imgPathNormal + this.hoverPathOut + linkNodes[j].childNodes[0].alt + this.imgExtension; linkNodes[j].current = false; } // Configure the behavior of the links linkNodes[j].book = this; if(this.hover) { linkNodes[j].onmouseover = function() { this.childNodes[0].src = ((this.current) ? this.book.imgPathCurrent : this.book.imgPathNormal) + this.book.hoverPathOver + this.childNodes[0].alt + this.book.imgExtension; } linkNodes[j].onmouseout = function() { this.childNodes[0].src = ((this.current) ? this.book.imgPathCurrent : this.book.imgPathNormal) + this.book.hoverPathOut + this.childNodes[0].alt + this.book.imgExtension; } } linkNodes[j].onclick = function() { // Name of this page var linkString = new String(this.href); var parts = linkString.split('#', 2); if(!flipBookLocks[this.book.lockID] && parts[1] != this.book.page) { // Execute fades if(this.book.fadeTime > 0) { // Fade out, then fade in fadeLayer(this.book.page, 1, 0, this.book.fadeTime); setTimeout("fadeLayer('" + parts[1] + "', 0, 1, " + this.book.fadeTime + ")", this.book.fadeTime); // Lock the links while animating flipBookLocks[this.book.lockID] = true; setTimeout("flipBookLocks['" + this.book.lockID + "'] = false;", this.book.fadeTime * 2); } else { // Hide and show directly showLayer(parts[1]); hideLayer(this.book.page); } // Set current this.book.page = parts[1]; // Change the old link back to normal/out this.book.link.childNodes[0].src = this.book.imgPathNormal + this.book.hoverPathOut + this.book.link.childNodes[0].alt + this.book.imgExtension; this.book.link.current = false; // Change the new link to current/over this.childNodes[0].src = this.book.imgPathCurrent + this.book.hoverPathOver + this.childNodes[0].alt + this.book.imgExtension; this.current = true; this.book.link = this; // Remove focus for visual reasons this.blur(); } else { // Remove focus for visual reasons this.blur(); // Don't let the browser move to the anchor return false; } } } } } else if(bookNodes[i].id == id + '_Pages') { var first = true; var pageNodes = bookNodes[i].childNodes; for(var j = 0; j < pageNodes.length; j++) { var idString = new String(pageNodes[j].id); if(idString.match(id + '_Page_') == id + '_Page_') { //pageNodes[j].style.position = 'absolute'; if(first) { first = false; showLayer(pageNodes[j].id); } else { hideLayer(pageNodes[j].id); } } } } } }