document.addEventListener('DOMContentLoaded', () => {

    var currentTime = new Date()
    var currDate = new Date(Date.now()); //Todays Date
    var iniPastedDate = "1/6/2023" //End Date
    
    function DateDiff(date1, date2) {
        var datediff = date1.getTime() - date2.getTime(); //store the getTime diff - or +
        return (datediff / (24 * 60 * 60 * 1000)); //Convert values to -/+ days and return value      
    }
    if (new Date(iniPastedDate) > new Date(currDate)) {
        document.getElementById('countdown').innerHTML = "S goht drgega... noch " + DateDiff(new Date(iniPastedDate), new Date(currDate)).toFixed(0) + " Tage!&nbsp;";
        document.getElementById('countdown').style.width = (100 / 365 * (365 - DateDiff(new Date(iniPastedDate), new Date(currDate)))) + "%";
    } else {
        document.getElementById('countdown').style.textAlign = 'center';
        document.getElementById('countdown').style.fontSize = '2.0em';
        document.getElementById('countdown').innerHTML = 'Endlich wieder Fasnet!';
    }

});

