function switchImage(imgName, imgSrc, imgCaption) { if (document.images) { if (imgSrc != "none") { document.getElementById('picCaption').innerHTML = imgCaption; document.getElementById('slideImage').src = imgSrc; } } } var mySlideList1 = ['/images/frontPageSlides/1.jpg', '/images/frontPageSlides/4.jpg', '/images/frontPageSlides/5.jpg', '/images/frontPageSlides/8.jpg']; var mySlideCaption1 = ['', '', '', '']; var mySlideShow1 = new SlideShow(mySlideList1, mySlideCaption1, 'slideImage', 5000, "mySlideShow1"); function SlideShow(slideList, captionList, image, speed, name) { this.slideList = slideList; this.captionList = captionList; this.image = image; this.speed = speed; this.name = name; this.current = 0; this.timer = 0; } SlideShow.prototype.play = SlideShow_play; function SlideShow_play() { with(this) { if(current++ == slideList.length-1) current = 0; switchImage(image, slideList[current], captionList[current]); clearTimeout(timer); timer = setTimeout(name+'.play()', speed); } }