// // Slideshow // Copyright (c) 2006,2007 Mackley F. Pexton. All rights reserved. // // This version is integrated with SimpleImage image manipulation routines. var Slideshow = { interval: 5, // seconds images: [], // urls of slideshow images index: 0, // Public init: function(img) { // Arguments after img are url's for images in slideshow. if (typeof img == 'string') { img = document.getElementById(img); } this.img = img; if (arguments.length > 1) { for (var i=1;i tag prefetch: new Image, // cache timer: null, // slideshow setTimeout timer SimpleImage: { // saved SimpleImage urls and control structures for each slide urls: [], // actual urls of images[] using SimpleImage.php controls: [] // simple image control settings object }, display: function() { var i = this.index; var j = this.next_index(); if (window.SimpleImage) { // Slideshow with SimpleImage adjustments this.img.SimpleImage = this.SimpleImage.controls[i] ? this.SimpleImage.controls[i] : null; this.img.src = this.SimpleImage.urls[i] ? this.SimpleImage.urls[i] : this.images[i]; this.prefetch.src = this.SimpleImage.urls[j] ? this.SimpleImage.urls[j] : this.images[j]; } else { // Normal slideshow this.img.src = this.images[i]; this.prefetch.src = this.images[j]; } }, keyup: function(evt) { switch (evt.keyCode) { case 40: // arrow down case 39: // arrow right case 107: // numpad + case 34: // page down case 32: // spacebar case 61: // = (+) FireFox case 187: // = (+) IE this.pause(); return this.next(); case 37: // arrow left case 38: // arrow up case 8: // backspace case 109: // numpad - case 33: // page up case 189: // - this.pause(); return this.prev(); case 36: // home this.pause(); return this.first(); case 35: // end this.pause(); return this.last(); } }, addEvent: function(obj,type,fn) { if (obj.addEventListener) { obj.addEventListener(type,fn,false); return true; } else if (obj.attachEvent) { return obj.attachEvent('on'+type,fn); } return false; } } SimpleImage.onload = function() { // Note: do not use 'this', get new image document element with id 'img'. var img = document.getElementById('img'); Slideshow.SimpleImage.urls[Slideshow.index] = img.src; Slideshow.SimpleImage.controls[Slideshow.index] = img.SimpleImage; }