var slideNames = new Array("../pictures/slideshow/01.First_Parish_Church.jpg", "../pictures/slideshow/02.Christmas_Eve_Nativity_in_a_box.jpg", "../pictures/slideshow/03.Flower_communion_service.jpg", "../pictures/slideshow/04.Congregational_musicians.jpg", "../pictures/slideshow/05.Christmas_candlelight_service.jpg", "../pictures/slideshow/06.FPC_in_Spring.jpg", "../pictures/slideshow/07.Christmas_Eve_"Angel"_choir.jpg", "../pictures/slideshow/08.Congregational_musician.jpg", "../pictures/slideshow/09.Flower_communion.jpg", "../pictures/slideshow/10.Outside_service.jpg", "../pictures/slideshow/11.Mummers_Play.jpg", "../pictures/slideshow/12.Flower_communion.jpg", "../pictures/slideshow/13.Joyous_choir.jpg", "../pictures/slideshow/14.Child_dedication.jpg", "../pictures/slideshow/15.Christmas_Eve.jpg", "../pictures/slideshow/16.Remembrance.jpg"); /* ---------------------------------------------- Cross fade slide slow Author: Keith Lundberg For First Parish Church of Acton & Stow Preloads slide one-at-a-time Delays fades until images have loaded ----------------------------------------------*/ // ---------------------------------------------- // Set these variables to control the slideshow var slideHoldMilliseconds = 1900.0; var slideFadeMilliseconds = 1500.0; var slideFadeSteps = 30.0; var slideInitialDelay = 20.0; // var slideNames = new Array( // "pictures/slideshow/web01.jpg", // "pictures/slideshow/web02.jpg", // ... // ); // ---------------------------------------------- // ---------------------------------------------- // These variables take care of themselves var fadeOpVal = 0.99; // start with the top slide var fadeOpInc = 0; var fadeDelay = slideHoldMilliseconds; var slideNumber = 0; // displayed slide Number var loadNumber = 0; // loading slide number var slideImg = new Array(); var slideIsLoading = false; var slideIsHolding = false; var frozen = false; var slideCaption = "First Parish Church"; // ---------------------------------------------- // --------------------------------------------------------------------------- // ------------------ Displaying Slides -------------------------------------- function setOpacity(obj, val) { // CSS3/mozilla/safari: style.opacity // Gecko before CSS3: style.MozOpacity // Konquerer and Safari: KhtmlOpacity // IE5.5+ : style.filter alpha(opacity=x) obj.style.opacity = val; obj.style.MozOpacity = val; obj.style.KhtmlOpacity = val; obj.style.filter = "alpha(opacity=" + (val*100) + ")"; } function displayNewSlide(obj) { slideNumber = (slideNumber + 1) % slideNames.length; obj.src = slideImg[slideNumber].src; //alert ("loading " + obj.id + " with " + obj.src); } function switchSlides(fromObj, toObj, topDirection) { if (fromObj && toObj) { if (false == slideIsLoading) { // begin transition by changing the display of the hidden slide displayNewSlide(toObj); slideIsLoading = true; } else if (true == toObj.complete) { if (false == slideIsHolding) { fadeDelay = slideHoldMilliseconds; slideIsHolding = true; } else if (false == frozen) { // the hidden slide is ready, continue transition with the fade //alert("Begining fade from " + fromObj.id + " to " + toObj.id + " (" + topDirection + ")" ); fadeOpInc = topDirection / slideFadeSteps; slideIsLoading = false; slideIsHolding = false; var name1 = toObj.src.replace(/_/g, ' '); var name2 = name1.match(/[0-9]\..*\.jpg/); var name3 = name2[0].slice(2,-4); slideCaption = name3; } else { fadeDelay = 100; // continue checking for non frozen } } else { // continue checking for completed loading of hidden slide (10 times a second) fadeDelay = 100; } } } function onSlideOver() { frozen = true; } function onSlideOut() { frozen = false; } // --------------------------------------------------------------------------- // ------------------ Setup / preloading slide images ----------------------- function onSlideLoad(num) { // Load the next slide loadNumber = loadNumber + 1; if (loadNumber < slideNames.length) { preloadSlide(); } } function preloadSlide() { slideImg[loadNumber] = new Image(); slideImg[loadNumber].src = slideNames[loadNumber]; slideImg[loadNumber].onLoad = onSlideLoad(loadNumber); } function setupSlides() { setOpacity(document.images["slidetop"], fadeOpVal); //setTimeout(doSlides, slideInitialDelay); slideInitialDelay = 0; preloadSlide(); } // --------------------------------------------------------------------------- // ---------------------- Top level contoller -------------------------------- function doSlides() { if (0 != slideInitialDelay) { setupSlides(); //return; } var topImage = document.images["slidetop"]; var bottomImage = document.images["slidebottom"]; if (topImage && bottomImage) { fadeOpVal = fadeOpVal + fadeOpInc; if (fadeOpVal >= 0.99) { fadeOpVal = 0.99; switchSlides(topImage, bottomImage, -1.0); } else if (fadeOpVal <= 0) { fadeOpVal = 0; switchSlides(bottomImage, topImage, 1.0); } else { fadeDelay = slideFadeMilliseconds / slideFadeSteps; } setOpacity(topImage, fadeOpVal); setTimeout(doSlides, fadeDelay); } }