Back to Scripts page
Click in the box below, select all and copy to grab the script
// This file contains the JavaScript for animating portfolio category buttons. // It is used by both cat_change.html & workbook.port.intro.fcgi // This script copyright 1997, The Workbook. // This script appeared in "JavaScript for the WWW, Visual QuickStart Guide, 2nd Edition." // This script may be used and modified, but the copyright notice must remain intact. var firstTime = 1 photoButton = new Array illButton = new Array digButton = new Array designButton = new Array repButton = new Array imgArray = new Array for (i=0; i<2; i++) { photoButton[i] = new Image illButton[i] = new Image digButton[i] = new Image designButton[i] = new Image repButton[i] = new Image } // Pre-load the animated graphics if (document.images) { photoButton[0].src = "http://www.workbook.com/img/photo/button_00.jpg" photoButton[1].src = "http://www.workbook.com/img/photo/button_01.jpg" illButton[0].src = "http://www.workbook.com/img/ill/button_00.jpg" illButton[1].src = "http://www.workbook.com/img/ill/button_01.jpg" digButton[0].src = "http://www.workbook.com/img/digital/button_00.jpg" digButton[1].src = "http://www.workbook.com/img/digital/button_01.jpg" designButton[0].src = "http://www.workbook.com/img/design/button_00.jpg" designButton[1].src = "http://www.workbook.com/img/design/button_01.jpg" repButton[0].src = "http://www.workbook.com/img/reps/button_00.jpg" repButton[1].src = "http://www.workbook.com/img/reps/button_01.jpg" imgArray = new Array(photoButton[0], photoButton[1], illButton[0], illButton[1], designButton[0], designButton[1], digButton[0], digButton[1], repButton[0], repButton[1]) } else { document.photo = "" document.ill = "" document.dig = "" document.design = "" document.rep = "" } function rotate() { if (firstTime == 1) { buttonArray = new Array(document.photo, document.ill, document.design, document.dig, document.rep) lastButton = -1 firstTime = 0 } randomImg = Math.floor(Math.random() * 10) randomButton = Math.floor(randomImg / 2) if (lastButton != randomButton) { buttonArray[randomButton].src = imgArray[randomImg].src lastButton = randomButton } setTimeout('rotate()',200) }