var firstPass = 1; // initial state variable var random = 0; // random slide selection? var pointer = 0; // foreground image pointer var FadeDuration = 1500; // fade duration in millisecond var image_count = imagefiles.length; var imageArray = []; for (var i=0; i < image_count; i++ ) { imageArray[i] = new imageItem(image_path+imagefiles[i]); } function imageItem(image_location) { this.image_item = new Image(); this.image_item.src = image_location; } function get_ImageItemLocation(imageObj) { return(imageObj.image_item.src); } function random_index(nmax) { return Math.floor(Math.min(Math.random()*(nmax + 1),nmax)); } function getNextImage() { var current = pointer; var next = current; if (random) { while (next == current) { next = random_index(image_count-1); } } else { next = (current+1) % image_count; } var next_image = get_ImageItemLocation(imageArray[next]); pointer = next; return(next_image); } function SetOpacity(object,opacityPct) { object.style.opacity = opacityPct/100; // Safari 1.2, newer Firefox and Mozilla, CSS3 object.style.MozOpacity = opacityPct/100; // Older Mozilla and Firefox object.style.KhtmlOpacity = opacityPct/100; // Safari<1.2, Konqueror object.style.filter = "alpha(opacity=" + opacityPct + ");"; // IE/Win } function ChangeOpacity(id,interval,tstart,ostart,ostop) { var element = document.getElementById(id); var tnow = (new Date()).getTime(); var opacity = ostart + (ostop - ostart) * (tnow - tstart) / interval; if (opacity >= 100) { SetOpacity(element,100); element.timer = undefined; } else if (opacity <= 0) { SetOpacity(element,0); element.timer = undefined; } else { SetOpacity(element,opacity); element.timer = window.setTimeout("ChangeOpacity('"+id+"',"+interval+","+tstart+","+ostart+","+ostop+")",10); } } function FadeInImage(foregroundID,backgroundID) { var newImage = getNextImage(); var foreground = document.getElementById(foregroundID); if (foreground.timer) { window.clearTimeout(foreground.timer); } if (backgroundID) { var background = document.getElementById(backgroundID); if (background) { if (background.src) { foreground.src = background.src; SetOpacity(foreground,100); } background.src = newImage; background.style.backgroundImage = 'url(' + newImage + ')'; background.style.backgroundRepeat = 'no-repeat'; var startMS = (new Date()).getTime(); foreground.timer = window.setTimeout("ChangeOpacity('"+foregroundID+"',"+FadeDuration+","+startMS+",100,0)",10); } } else { foreground.src = newImage; } } function SlideShow(foregroundID,backgroundID,displaySecs) { if (firstPass) { firstPass = 0; setTimeout("SlideShow('"+foregroundID+"','"+backgroundID+"',"+displaySecs+")",3500); } else { FadeInImage(foregroundID,backgroundID); setTimeout("SlideShow('"+foregroundID+"','"+backgroundID+"',"+displaySecs+")",displaySecs*1000); } }