console.log('scripts loaded');
document.onreadystatechange = function(event) {
    if (document.readyState === "complete") {
        if(document.getElementById('pourcent-reveil'))
        {
            setcurrentprogress(document.getElementById('pourcent-reveil'),5);
            updateprogress(document.getElementById('pourcent-reveil'),5);
        }
    }
}

function setcurrentprogress(obj,value)
{
    obj.setAttribute("value",value);
    obj.setAttribute("aria-valuenow",value);
}

function updateprogress(obj, step=5)
{
    currentprogress = parseInt(obj.getAttribute("value")) + step;
    if(currentprogress >= 100)
    {
        console.log("finished");
        setcurrentprogress(obj,100);
        document.getElementById("finished").setAttribute("style","");    
        return;
    }
    console.log("updateprogress to "+currentprogress);
    setcurrentprogress(obj,currentprogress);
    setTimeout(updateprogress, 500, obj);
}