WS_waitscreen = true;

window.onload = function(){
    
    document.getElementsByClassName('pageCnt')[0].style.visibility="visible"
    // Window Load
    var waitScreen = document.getElementById("waitScreen");
    document.body.removeChild(waitScreen);
    WS_waitscreen = false;
    
    document.getElementById('cancel-button').addEventListener("click", function(){
        gotoPage('login','main','');
    }); 
    
    document.getElementById('accept-button').addEventListener("click", function(){
        var scroll = document.getElementsByClassName('scroll-box')[0];
        if(scroll.scrollTop >= scroll.scrollHeight - scroll.offsetHeight - 20){
            gotoPage('register','register-data','');
        }else{
            document.getElementById('e').innerHTML = getLangById('required')[lang];
        }
    }); 
    
    document.getElementById('termdown').addEventListener("click", function(){
        gotoNewPage('register','termsandconditions')
    }); 
    
    setLang()
    
}

function termsLoad(){
    console.log("update")
    callWS("GET", "terms/load", { "lang": lang } , response);
        
    function response(status, rsp){
        switch(status){
            case 200:
                document.getElementById('text').innerHTML = JSON.parse(rsp).terms
                break;
            default:
                break;
        }
    }    
}

function setLang(){
    
    lang = lang = localStorage.getItem('lang') ? lang = localStorage.getItem('lang') : 'esp';
    
    /* inner HTML */
    setWordLanginnerHTML('register','register');
    setWordLanginnerHTML('register1','register1');
    setWordLanginnerHTML('register2','register2');
    setWordLanginnerHTML('register3','register3');
    setWordLanginnerHTML('register4','register4');
    setWordLanginnerHTML('registerTitle','register1');
    setWordLanginnerHTML('cancel-button','cancel');
    setWordLanginnerHTML('accept-button','accept');

    setWordLanginnerHTML('ts','ts');
    
    termsLoad()

    //Mostrar HTML cargado
    esconderHTML(false);   
}