// Have to keep track of the cass instances for set timeouts var SlideshowInstances = new Object(); function Slideshow (imgList, hangTime) { this.photoDivs = imgList.split(/,/); this.photoTimeouts = new Array(); this.photoOpacs = new Array(); // Set up the arrays for (var i=0; i < this.photoDivs.length; i++) { this.photoTimeouts[i] = null; this.photoOpacs[i] = 0; } this.fadeAmount = 10; this.fadePause = 100; this.fadeHangtime = (hangTime ? hangTime : 5); this.lastSlide = -1; // Get a random number this.Id = Math.floor(Math.random() * 10000); // Now record the pointer SlideshowInstances[this.Id] = this; this.setOpacity = function (idx,opac) { var obj = document.getElementById('divPhoto' + this.photoDivs[idx]); if (!obj) return; if (opac > 0) obj.style.display = "block"; else obj.style.display = "none"; obj.style.opacity = (opac / 100); obj.style.MozOpacity = (opac / 100); obj.style.KhtmlOpacity = (opac / 100); obj.style.filter = "alpha(opacity=" + opac + ")"; // Do the display none or visible so we can click links // Set the array this.photoOpacs[idx] = opac; } this.doFade = function (idx,dir) { var amt = dir * this.fadeAmount; var obj = document.getElementById('divPhoto' + this.photoDivs[idx]); if (!obj) return; var opacity = this.photoOpacs[idx]; if (dir > 0 && opacity >= 100) { // Lets go to the next one in hangtime seconds idx++; if (idx >= this.photoDivs.length) idx = 0; if (this.photoDivs.length > 1) this.photoTimeouts[idx] = setTimeout("SlideshowInstances["+ this.Id +"].changeToSlide("+ idx +");", this.fadeHangtime * 1000); return; } if (dir < 0 && opacity <= 0) return; opacity += amt; // Set the property this.setOpacity(idx, opacity); // Do it again this.photoTimeouts[idx] = setTimeout("SlideshowInstances["+ this.Id +"].doFade("+ idx +", "+ dir +");", this.fadePause); } this.setDiamond = function (idx) { // K, go through all the diamonds, and set the image src and link classes appropriately for (var i=0; i < this.photoDivs.length; i++) { var clr = (i % 2) ? 'blue' : 'yellow'; if (obj = document.getElementById("slideLink" + (i + 1))) { obj.className = "nu " + (!(i % 2) && (i == idx) ? 'w' : 'blk'); if (obj.blur) obj.blur(); } if (document.images['slideDiamond'+(i+1)]) document.images['slideDiamond'+(i+1)].src = "/images/"+ clr + (i == idx ? "-over" : "") +"-diamond.gif"; } } this.setCounter = function (idx) { if (document.forms['counterForm'] && document.forms['counterForm'].counter) { document.forms['counterForm'].counter.value = document.forms['counterForm'].counter.value.replace(/^.+ of/,(idx + 1) + " of"); document.forms['counterForm'].counter.style.background = 'none'; } } this.shiftSlide = function (shft) { var nextOne = this.lastSlide + shft; if (nextOne >= this.photoDivs.length) nextOne = 0; if (nextOne < 0) nextOne = this.photoDivs.length - 1; this.changeToSlide(nextOne, 1); } this.changeToSlide = function (idx, force) { if (force) { // Cancel all timeouts and force 100% opacity to this one for (var i = 0; i < this.photoDivs.length; i++) { if (this.photoTimeouts[i]) clearTimeout(this.photoTimeouts[i]); this.setOpacity(i, (idx == i ? 100 : 0)); } } else if (this.lastSlide >= 0) this.doFade(this.lastSlide,-1); // Start the fading this.doFade(idx,1); // And set the diamond this.setDiamond(idx); // Or the input box this.setCounter(idx); this.lastSlide = idx; } this.start = function () { this.changeToSlide(0); } }