function Fader(einstellungen) { if (!einstellungen.id || !document.getElementById(einstellungen.id) || einstellungen.images.length < 2) { return new Boolean(false); } var i, original = document.getElementById(einstellungen.id); this.id = einstellungen.id; this.images = new Array(); this.counter = 0; this.element = document.createElement("span"); this.element.className = "fader"; original.parentNode.replaceChild(this.element, original); for (i = 0; i < einstellungen.images.length; i++) { this.images[i] = document.createElement("img"); this.images[i].src = einstellungen.images[i]; this.images[i].alt = "Bild"; if (i == 0) { this.element.appendChild(this.images[i]); } } this.fade = function (step) { var fader = this, imgs = this.element.getElementsByTagName("img"); step = step || 0; imgs[1].style.opacity = step/100; imgs[1].style.filter = "alpha(opacity=" + step + ")"; // IE? step = step + 2; if (step <= 100) { window.setTimeout(function () { fader.fade(step); }, 1); } else { imgs[1].className = ""; this.element.removeChild(imgs[0]); window.setTimeout(function () { fader.next(); }, 3000); // Zeitinterwall } }; this.next = function () { this.counter = (this.counter < this.images.length -1) ? this.counter +1 : 0; this.element.appendChild(this.images[this.counter]); this.images[this.counter].className = "next"; this.fade(); }; } function Preloader () { var einstellungen = { id: "slideshow", images: ["slidebilder/opticom-slide-a-001.png", "slidebilder/opticom-slide-a-002.png", "slidebilder/opticom-slide-b-001.png", "slidebilder/opticom-slide-b-002.png", "slidebilder/opticom-slide-b-003.png", "slidebilder/opticom-slide-c-001.png", "slidebilder/opticom-slide-c-002.png", "slidebilder/opticom-slide-d-001.png", "slidebilder/opticom-slide-d-002.png"] }; if (!window.meine_slideshow) { window.meine_slideshow = new Fader(einstellungen); } meine_slideshow.next(); } // window.onDomReady = initReady; // // // Initialize event dpending on browser // function initReady(fn) // { // //W3C-compliant browser // if(document.addEventListener) { // document.addEventListener("DOMContentLoaded", fn, false); // } // //IE // else { // document.onreadystatechange = function(){readyState(fn)} // } // } // // //IE execute function // function readyState(func) // { // // DOM is ready // if(document.readyState == "interactive" || document.readyState == "complete") // { // func(); // } // } // ////execute as soon as DOM is loaded //window.onDomReady(onReady); // ////do when DOM is ready //function onReady() //{ // Preloader(); //} // //// to compare which loader is shown earlier //window.onload = function() { // Preloader(); //}