/* ########## eSnowFlake (copyright e2see.de) ##########
<!DOCTYPE html>
<html>
<head>
    <!-- Das originale CSS muss vorhanden sein! -->
    <link rel="stylesheet" href="https://cdn.e2see.com/css/plugins/esnowflake">
</head>
<body>
    <!-- Deine Webseite -->
    
    <!-- eSnowFlake Library -->
    <script src="https://cdn.e2see.com/js/plugins/esnowflake"></script>
    
    <!-- Dein Code -->
    <script>
        // Start mit Standard-Parametern
        eSnowFlake.start();
        
        // Oder mit eigenen Parametern
        eSnowFlake.start({
            count: 30,
            zIndex: 9999
        });
        
        // Stoppen (optional)
        // eSnowFlake.stop();
    </script>
</body>
</html>
*/

/* eSnowFlake - Vanilla JS (copyright e2see.de) */
(function(global) {
    'use strict';

    // Private Variablen
    let container = null;
    let activeSettings = {
        count: 25,
        zIndex: 400
    };
    let timeouts = [];

    // Private Methode: Fügt eine einzelne Schneeflocke hinzu
    function addFlake(initElem) {
        const size = Math.floor(Math.random() * 10);
        const from = 1;
        const to = 99;
        const speed = 5.5;
        const dh = window.innerHeight;

        let flake;
        
        if (initElem) {
            flake = initElem;
            flake.setAttribute('data-size', size);
        } else {
            flake = document.createElement('div');
            flake.className = 'e-snow-flake';
            flake.setAttribute('data-size', size);
            flake.setAttribute('data-status', 'init');
            container.appendChild(flake);

            flake.addEventListener('init', function() {
                addFlake(this);
            });
        }

        const fHeight = parseInt(window.getComputedStyle(flake).height) || 20;
        const additionalH = fHeight;
        const duration = ((dh + additionalH) * speed) * ((size + 2) / 2);
        const leftPosRandom = Math.floor(Math.random() * to) + from;

        flake.style.top = '-' + fHeight + 'px';
        flake.style.marginLeft = '-' + fHeight + 'px';

        setTimeout(function() {
            flake.style.top = '';
            flake.style.left = leftPosRandom + '%';
            flake.style.transition = 'top ' + duration + 'ms linear';
            flake.setAttribute('data-status', 'run');

            setTimeout(function() {
                flake.setAttribute('data-status', 'init');
                flake.dispatchEvent(new Event('init'));
            }, duration);
        }, 150);
    }

    // Private Methode: Startet die Schneeflocken-Animation
    function startSnow(userOptions) {
        // Vorhandene Timeouts löschen
        timeouts.forEach(clearTimeout);
        timeouts = [];
        
        // Container erstellen falls nötig
        if (!container) {
            container = document.createElement('div');
            container.id = 'e-snow-flakes';
            document.body.appendChild(container);
        }

        // Einstellungen mergen
        const settings = { ...activeSettings, ...userOptions };
        activeSettings = settings;
        
        container.style.zIndex = settings.zIndex;
        container.innerHTML = '';
        container.style.display = 'block';

        // Flocken mit gestaffelten Timeouts erstellen
        let i = 0;
        do {
            const wh = ((document.documentElement.scrollHeight / settings.count) / 4) + 6;
            const mxSec = wh;
            const duration = Math.floor(Math.random() * (mxSec + 1));
            
            const timeoutId = setTimeout(function() {
                addFlake();
            }, duration * 1000);
            
            timeouts.push(timeoutId);

            i++;
        } while (i < settings.count);
    }

    // Private Methode: Stoppt die Animation
    function stopSnow() {
        if (container) {
            // Alle geplanten Timeouts löschen
            timeouts.forEach(clearTimeout);
            timeouts = [];
            
            // Flocken entfernen und Container ausblenden
            container.innerHTML = '';
            container.style.display = 'none';
        }
    }

    // Öffentliche API - NUR DAS ist global sichtbar
    global.eSnowFlake = {
        start: startSnow,
        stop: stopSnow
    };

})(window);





/* cdn 2ms */