// Parts of this script were borrowed from: // (C) 2002 www.CodeLifter.com // http://www.codelifter.com // ============================== // Set the following variables... // ============================== // Set the slideshow speed (in milliseconds, 1 second = 1000 milliseconds) var SlideShowSpeed = 4000; // Set total number of slides var slidesCnt = 10; //Set the starting slide var slideNo = 2; //Set if you want random looping var slideShuffle=false; //Set the name of the element that will contain the slides var slideParentElement = "fadebox"; //Set fade in degree for NS6+ (number between 0 and 1. Recommended max: 0.2) //FYI, IE fade degree is the same value * 100 var Fadedegree=0.09; // ===================================== // Do not edit anything below this line! // ===================================== var slideBox; var tss; var fadeinvar; var fadeoutvar; var fadedegree; var fadeinLimit; var manualAdvance = false; var move_prev = false; var first_prev = true; var directionBack = false; var css3 = false; var moz = false; var ie = false; /* random number generation */ // The Central Randomizer 1.3 (C) 1997 by Paul Houle ([email protected]) // See: http://www.msc.cornell.edu/~houle/JavaScript/randomizer.html rnd.today=new Date(); rnd.seed=rnd.today.getTime(); function rnd() { rnd.seed = (rnd.seed*9301+49297) % 233280; return rnd.seed/(233280.0); }; function rand(number) { return Math.ceil(rnd()*number); }; function runSlideShow() { //init slideBox slideBox=document.getElementById(slideParentElement); CHECKOPACITY(); if (css3 && !ie) { fadedegree = Fadedegree; fadeinLimit = 0.999; } else if (moz) { fadedegree = Fadedegree; fadeinLimit = 0.999; } else if (ie) { fadedegree = Fadedegree*100; fadeinLimit = 100; } else { 1==1 } selectButton(1); //unload current slide tss=setInterval("unloadCurrentSlide()", SlideShowSpeed); } function unloadCurrentSlide() { //fade out current slide if (!manualAdvance) fadeoutvar=setInterval("fadeout()", 90); clearInterval(tss); } function loadNextSlide() { //get the next slide content and load it into the slideBox var slideNoTmp = slideNo; if (move_prev) { slideNoTmp = slideNo - 1; if (slideNoTmp == slidesCnt) slideNoTmp=slidesCnt-1; if (slideNoTmp == 0) slideNoTmp=slidesCnt; if (slideNoTmp == -1) slideNoTmp=slidesCnt-1; } selectButton(slideNoTmp); var slideObj = document.getElementById("slide"+slideNoTmp); var newSlide = slideObj.cloneNode(true); // this is for Konqueror and Safari who do not support clipping if (!css3 && !ie && !moz) { newSlide.removeAttribute('class'); } var slideContent = newSlide.innerHTML; slideBox.innerHTML = slideContent; //fade it in if (!manualAdvance) { fadeinvar=setInterval("fadein()", 90); } else { if (css3 && !ie) slideBox.style.opacity=fadeinLimit; else if (moz) slideBox.style.MozOpacity=fadeinLimit; else if (ie) slideBox.filters.alpha.opacity=fadeinLimit; else { 1==1}; } } function PickNextSlideAtRandom(lastSlideNo) { var nextRandomSlide; /* pick a random number between slidesCnt and 1 */ do { nextRandomSlide = rand(slidesCnt); } while ( nextRandomSlide == lastSlideNo ) return nextRandomSlide; } function finishedLoadingSlide() { if (slideShuffle) { slideNo = PickNextSlideAtRandom(slideNo); } else { if (!move_prev) slideNo = slideNo + 1; else slideNo = slideNo - 1; if (slideNo > slidesCnt) slideNo=1; if (slideNo < 1) slideNo=slidesCnt; } //set to unload the current slide in the specified time period tss = setTimeout('unloadCurrentSlide()', SlideShowSpeed); } function PauseSlide() { clearInterval(tss); clearInterval(fadeoutvar); clearInterval(fadeinvar); manualAdvance = true; //unloadCurrentSlide(); //loadNextSlide(); //finishedLoadingSlide(); //manualAdvance = false; } function loadSlideNo(theSlide) { clearInterval(tss); clearInterval(fadeoutvar); clearInterval(fadeinvar); manualAdvance = true; unloadCurrentSlide(); slideNo = theSlide; selectButton(theSlide); loadNextSlide(); finishedLoadingSlide(); directionBack = false; //manualAdvance = false; } function deselectButtons(){ for (var sl = 1; sl <= slidesCnt; sl++){ document.getElementById('selectslide'+sl).src = "/images/buttons/btn_up.gif"; } } function selectButton(theSlide){ deselectButtons(); document.getElementById('selectslide'+theSlide).src = "/images/buttons/btn_down.gif"; } function NextSlide() { clearInterval(tss); clearInterval(fadeoutvar); clearInterval(fadeinvar); manualAdvance = true; unloadCurrentSlide(); loadNextSlide(); finishedLoadingSlide(); if (directionBack) { directionBack = false; NextSlide(); } //manualAdvance = false; } function PrevSlide() { clearInterval(tss); clearInterval(fadeoutvar); clearInterval(fadeinvar); manualAdvance = true; move_prev = true; unloadCurrentSlide(); loadNextSlide(); finishedLoadingSlide(); move_prev = false; if (!directionBack) { directionBack = true; PrevSlide(); } //manualAdvance = false; } function fadein() { var current_opacity; if (css3 && !ie) { current_opacity=slideBox.style.opacity; } else if (moz) { current_opacity=slideBox.style.MozOpacity; } else if (ie) { current_opacity=slideBox.filters.alpha.opacity; } else { 1==1}; var op = Math.round( parseFloat(current_opacity)*100)/100 var opnew = Math.round( (parseFloat( current_opacity ) + fadedegree)*100)/100 if (op < fadeinLimit) { if (opnew >= fadeinLimit ) { if (css3 && !ie) slideBox.style.opacity=fadeinLimit; else if (moz) slideBox.style.MozOpacity=fadeinLimit; else if (ie) slideBox.filters.alpha.opacity=fadeinLimit; else { 1==1}; document.getElementById("fadecount").innerHTML = fadeinLimit.toString(); } else { if (css3 && !ie) slideBox.style.opacity=opnew; else if (moz) slideBox.style.MozOpacity=opnew; else if (ie) slideBox.filters.alpha.opacity=opnew; else { 1==1}; document.getElementById("fadecount").innerHTML = opnew.toString(); } } else{ clearInterval(fadeinvar) //to post slide finishedLoadingSlide(); } } function fadeout() { var current_opacity; if (css3 && !ie) current_opacity=slideBox.style.opacity; else if (moz) current_opacity=slideBox.style.MozOpacity; else if (ie) current_opacity=slideBox.filters.alpha.opacity; else { 1==1}; var op = Math.round( parseFloat( current_opacity )*100)/100; var opnew = Math.round( (parseFloat(current_opacity - fadedegree))*100)/100; if ( op > 0) { if (opnew <= 0 ) { if (css3 && !ie) slideBox.style.opacity=0; else if (moz) slideBox.style.MozOpacity=0; else if (ie) slideBox.filters.alpha.opacity=0; else { 1==1}; document.getElementById("fadecount").innerHTML = '0'; } else { if (css3 && !ie) slideBox.style.opacity=opnew; else if (moz) slideBox.style.MozOpacity=opnew; else if (ie) { slideBox.filters.alpha.opacity=opnew; } else { 1==1}; document.getElementById("fadecount").innerHTML = opnew.toString(); } } else { clearInterval(fadeoutvar); //load next slide loadNextSlide(); } } function CHECKOPACITY() { //css3 if (!(typeof(slideBox.style.opacity) == "undefined")) css3 = true; //mozilla opacity if (!(typeof(slideBox.style.MozOpacity) == "undefined")) moz = true; //IE opacity if (!(typeof(slideBox.filters) == "undefined")) if (!(typeof(slideBox.filters.alpha) == "undefined")) if (!(typeof(slideBox.filters.alpha.opacity) == "undefined")) ie = true; }