/* produced by Jan Hagge, 2006 www.n-try.de */ var fadeImages = Array("left_image3.gif", "left_image2.gif", "left_image4.gif", "left_image1.gif"); var delayBetweenFades = 6000; // Delay between every fade. var actualopacity = 100; // Opacity in percent before js has done anything var loaderopacity = 100; // Opacity in percent before js has done anything var minopacity = 0; // Minimal Opacity while loading/fadeanimation var maxopacity = 100; // Maximum Opacity while loading/fadeanimation (tip: take the actualopacity) var imagePath = "/images/gallery/"; // Path to the images that you would like to use in the gallery var bigimgID = "startimage"; // id="" of the big Image in the htmlsource //DONT TOUCH THIS -v- var loaded = false; var fadein = false; var interval; var ie = document.all ? true : false;; var nextImage; var newimg = new Image; var loader; var loaderWidth; var loadingbar; function initSmoothImageLoader() { if(document.getElementById(bigimgID) && fadeImages) { getNextImage(); } } function initLoadingBar() { loader.style.display = "block"; loaderWidth = 0; ie ? loader.style.filter = "alpha(opacity="+loaderopacity+")" : loader.style.opacity = loaderopacity/100; loadingbar = window.setInterval("loadingBar()", 20); } function loadingBar() { var steps = delayBetweenFades/20; var percent = 100/steps; loaderWidth = loaderWidth+percent; if(loaderWidth > 100) { window.clearInterval(loadingbar); loader.style.width = "100%"; } else { loader.style.width = loaderWidth+"%"; } } function getNextImage() { nextImage = fadeImages[ parseInt( Math.random() * fadeImages.length ) ]; if( document.getElementById(bigimgID).src.search(nextImage) == -1) { if(loader = document.getElementById("loader")) initLoadingBar(); loadImage(imagePath+nextImage); window.setTimeout("showPic()", delayBetweenFades); } else window.setTimeout("getNextImage()", 2); } function showPic() { if (document.getElementById) { //stop the running interval if( !isNaN(interval) ) window.clearInterval(interval); //start new interval interval = window.setInterval("toogleFade()", 20); return false; } else { return true; } } function loadImage(newsrc) { newimg.src = newsrc; } function toogleFade() { if(actualopacity == minopacity) { loaded = newimg.complete ? true : false; if(loaded) { if(loader) loader.style.width = "0"; document.getElementById(bigimgID).src = newimg.src; } fadein = true; } else if(actualopacity == maxopacity) { if(loaded && fadein) { window.clearInterval(interval); getNextImage(); } fadein = false; } //set new opacity actualopacity = fadein ? actualopacity+2 : actualopacity-2; loaderopacity = fadein ? loaderopacity+3 : loaderopacity-3; aim = document.getElementById(bigimgID); ie ? aim.style.filter = "alpha(opacity="+actualopacity+")" : aim.style.opacity = actualopacity/100; if(loader) ie ? loader.style.filter = "alpha(opacity="+loaderopacity+")" : loader.style.opacity = loaderopacity/100; } function addLoadFunction(addme) { var oldonload = window.onload; window.onload = typeof window.onload != 'function' ? addme : function(){ oldonload(); addme(); }; } addLoadFunction(initSmoothImageLoader); function openBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { if(window.screen)if(isCenter)if(isCenter=="true"){ var myLeft = (screen.width-myWidth)/2; var myTop = (screen.height-myHeight)/2; features+=(features!='')?',':''; features+=',left='+myLeft+',top='+myTop; } window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight); }