WS_waitscreen = true;
numofrec = 8
currencies = {};

function start() {

    // Call Entry 
    setLang()

    if (screen.width <= 700) {
        numofrec = ''
    }


    if (screen.width > 700) {
        document.getElementById('totalPortfolioSel').addEventListener("change", function () {
            balanceDraw(accountsGlob);
            /*
            var req = {
                'sessionid': sessionStorage.getItem('sessionid'),
                'currencyid': document.getElementById('totalPortfolioSel').value,
                'filter': document.getElementById("search").value,
                'numofrec': numofrec,
            };
            currencies.records.forEach(record => {
                if(record.id == document.getElementById('totalPortfolioSel').value){
                    document.getElementById('totalPortfolioSel').setAttribute('decimal',record.decimals)
                }
            });
            balanceAccounts(req,'')*/
        })
    } else {
        document.getElementById('totalPortfolioSelR').addEventListener("change", function () {
            balanceDraw(accountsGlob);
            /*
            var req = {
                'sessionid': sessionStorage.getItem('sessionid'),
                'currencyid': document.getElementById('totalPortfolioSelR').value,
                'filter': document.getElementById("search").value,
                'numofrec': numofrec,
            };
            currencies.records.forEach(record => {
                if(record.id == document.getElementById('totalPortfolioSelR').value){
                    document.getElementById('totalPortfolioSelR').setAttribute('decimal',record.decimals)
                }
            });
            balanceAccounts(req,'')*/
        })
    }


    // Session Update


    document.getElementById("iconSearch").addEventListener("click", function () {
        var filter = document.getElementById("search").value;
        if (filter == null || filter == undefined) {
            filter = '';
        }
        //Se desmarca la pagina anterior
        var pSel = document.getElementsByClassName("pSelect");
        if (pSel.length > 0) pSel[0].classList.remove("pSelect");

        //Colocamos la pagina 1
        var page1 = document.getElementsByClassName("pages")[0];
        if (page1 != undefined) {
            page1.classList.add("pSelect");
        }

        var sessionId = sessionStorage.getItem('sessionid');
        var numofrecords = numofrec;
        var currencyid = 0;
        if (screen.width > 700) {
            currencyid = document.getElementById('totalPortfolioSel').value
        } else {
            currencyid = document.getElementById('totalPortfolioSelR').value
        }

        var req = {
            'sessionid': sessionStorage.getItem('sessionid'),
            'currencyid': currencyid,
            'filter': filter,
            'numofrec': numofrecords,
        };
        balanceAccounts(req, '')
    });

    // Event to input search
    document.getElementById("search").addEventListener("change", function () {
        var filter = document.getElementById("search").value;
        if (filter == null || filter == undefined) {
            filter = '';
        }

        //Se desmarca la pagina anterior
        var pSel = document.getElementsByClassName("pSelect");
        if (pSel.length > 0) pSel[0].classList.remove("pSelect");

        //Colocamos la pagina 1
        var page1 = document.getElementsByClassName("pages")[0];
        if (page1 != undefined) {
            page1.classList.add("pSelect");
        }

        var sessionId = sessionStorage.getItem('sessionid');
        var numofrecords = numofrec;
        var currencyid = 0;
        if (screen.width > 700) {
            currencyid = document.getElementById('totalPortfolioSel').value
        } else {
            currencyid = document.getElementById('totalPortfolioSelR').value
        }

        var req = {
            'sessionid': sessionStorage.getItem('sessionid'),
            'currencyid': currencyid,
            'filter': filter,
            'numofrec': numofrecords,
        };
        balanceAccounts(req, '')
    });

    document.getElementsByClassName('pageCnt')[0].style.display = "table";

    /*
    var req = {
        'sessionid': sessionStorage.getItem('sessionid')
    }
    balanceCurrencies(req)
    */
    var filter = document.getElementById("search").value;
    if (filter == null || filter == undefined) filter = '';
    var numofrecords = numofrec;
    var currencyid = 0;
    if (screen.width > 700) {
        currencyid = document.getElementById('totalPortfolioSel').value
    } else {
        currencyid = document.getElementById('totalPortfolioSelR').value
    }

    var req = {
        'sessionid': sessionStorage.getItem('sessionid'),
        'currencyid': currencyid,
        'filter': filter,
        'numofrec': numofrecords,
    };
    balanceAccounts(req, 'initial')



    if (screen.width <= 700) {
        responsiveBalance()
    }

    // Movimientos BTC Back
    document.getElementById('movBTCBack').addEventListener("click", function () {
        document.getElementsByClassName('movBTC')[0].style.display = "none"
    });

    // Movimientos VES Back
    document.getElementById('movVESBack').addEventListener("click", function () {
        document.getElementsByClassName('movVES')[0].style.display = "none"
        document.getElementsByTagName('body')[0].classList.remove('hidden')
    });

    // Salir de inf Movimiento Fiat
    document.getElementById('detailFiatButton').addEventListener("click", function () {
        document.getElementsByClassName('movDetailFiat')[0].style.display = "none"
        document.getElementsByClassName('movVES')[0].style.display = "table"
    });

    document.getElementById('acceptNoAccount').addEventListener("click", function () {
        document.getElementsByClassName('accountAttention')[0].style.display = "none"
    });

    document.addEventListener('click', function (evt) {
        if (evt.target.className === 'clickClose') {
            document.getElementsByClassName('movBTC')[0].style.display = "none"
        }
    })

    document.getElementById('movDetailFiatSeeComprobant').addEventListener("click", function () {
        if (document.getElementById("movDetailFiatSeeComprobant").getAttribute("comp") != 'undefined')
            window.open(document.getElementById('movDetailFiatSeeComprobant').getAttribute('comp'), '_blank');
    });

    document.getElementById("resend").addEventListener("click", function () {
        if (document.getElementById("movDetailFiatSeeComprobant").getAttribute("comp") != 'undefined')
            document.getElementById("movDetailFiatSeeComprobant").dispatchEvent(new Event("click"));
    });

    //Ajustes de balance validación de nivel, manejo de pop...
    document.getElementById('tryAgain').addEventListener("click", function () {
        document.getElementsByClassName('failure')[0].style.display = "none"
        document.getElementsByTagName('body')[0].classList.remove('hidden')
        document.getElementById('failureMsg').innerHTML = ''
        document.getElementById('failureTitle').innerHTML = ''
        document.getElementById('tryAgain').innerHTML = ''
    });

    //Mostrar HTML cargado
    esconderHTML(false);

}

function errorLevel() {
    document.getElementById('failureMsg').innerHTML = getLangById('var1')[lang]
    document.getElementById('failureTitle').innerHTML = getLangById('Attention')[lang]
    document.getElementById('tryAgain').innerHTML = getLangById('var2')[lang]
    document.getElementsByClassName('failure')[0].style.display = "table"
}


var waitScreen = document.getElementById("waitScreen");
waitScreen.style.opacity = 0;
setTimeout(function () {
    document.body.removeChild(document.getElementById("waitScreen"));
}, 600);
WS_waitscreen = false;


function logout() {
    var sessionid = sessionStorage.getItem('sessionid')
    var req = {
        'sessionid': sessionid,
    }

    callWS('GET', 'login/logout', req, response);

    function response(status, rsp) {
        switch (status) {
            case 200:
                sessionStorage.removeItem('sessionid')
                gotoPage('login', 'main', '')
                break;
            case 400:
                break;
            case 401:
                expiredSession('logout');
                break;
            case 500:
                break;
            default:
                break;
        }
    }
}
/*
function expiredSession(reason){
    
    // 'balanceCurrencies'  'balanceAccounts'
    if(reason == 'logout'){
        myLogout();
    }else{
        document.getElementsByClassName('expired')[0].style.display = "table"
        WS_waitscreen = false;
        var seconds = 30;
        var countdown = setInterval(countDown, 1000);
        
        function countDown(){
            seconds--;
            if(seconds == 0){
                if(document.getElementsByClassName('expired')[0].style.display == "table"){
                    myLogout();
                    clearInterval(countdown);
                }
            }
            if(document.getElementsByClassName('expired')[0].style.display == "none"){
                if(reason == 'balanceCurrencies'){
                    var req = {
                        'sessionid': sessionStorage.getItem('sessionid')
                    }
                    balanceCurrencies(req)
                }else if(reason == 'balanceAccounts'){
                    
                    var filter = document.getElementById("search").value;
                    if(filter == null || filter == undefined){
                        filter  = '';
                    }
                    var req = {
                        'sessionid': sessionStorage.getItem('sessionid'),
                        'currencyid': document.getElementById('totalPortfolioSel').value,
                        'filter' : filter,
                        'numofrec': numofrec,
                    };
                    if(screen.width > 700){
                        for(i = 0; i < document.getElementsByClassName('pages').length; i++){
                            if(document.getElementsByClassName('pages')[i].classList.contains('pSelect')){
                                req.offset = i*numofrec
                            }
                        }   
                    }else{
                        req.currencyid = document.getElementById('totalPortfolioSelR').value
                        req.offset = ''
                    }
                    balanceAccounts(req,'')
                }
                clearInterval(countdown)
            }
        }   
    }
}

function balanceCurrencies(req) {
    callWS('GET', 'balance/currencies', req, response);
    function response(status, rsp) {
        switch (status) {
            case 200:
                console.log(JSON.parse(rsp));
                currencies = JSON.parse(rsp)
                addOptions(currencies);
                break;
            case 400:
                break;
            case 401:
                expiredSession('balanceCurrencies');
                break;
            case 402:
                break;
            case 403:
                break;
            case 500:
                break;
            default:
                break;
        }
    }
}
*/


function addOptions(array) {

    if (screen.width > 700) {
        var selectedId = document.getElementById('totalPortfolioSel').value;
    } else {
        var selectedId = document.getElementById('totalPortfolioSelR').value;
    }
    removeOptions();
    if (screen.width > 700) {
        var selector = document.getElementById('totalPortfolioSel');
        for (var i = 0; i < array.length; i++) {
            var opcion = document.createElement("option");
            if (selectedId !== null && selectedId !== undefined && selectedId !== "") {
                if (selectedId == array[i].id) {
                    opcion.setAttribute("selected", "");
                }
            } else if (i == 0) {
                opcion.setAttribute("selected", "");
            }
            opcion.setAttribute("decimal", array[i].decimals);
            opcion.setAttribute("total", array[i].total.formatted);
            opcion.text = array[i].symbol;
            opcion.value = array[i].id;
            selector.add(opcion);
        }
        /*
        var req = {
            'sessionid': sessionStorage.getItem('sessionid'),
            'currencyid': document.getElementById('totalPortfolioSel').value,
            'numofrec': numofrec,
            'filter': document.getElementById("search").value
        };
        if(array.records){
            selector.setAttribute('decimal',array.records[0].decimals)   
        }
        balanceAccounts(req,'initial')   */
    } else {
        var selector = document.getElementById('totalPortfolioSelR');
        for (var i = 0; i < array.length; i++) {
            var opcion = document.createElement("option");
            if (selectedId !== null && selectedId !== undefined && selectedId !== "") {
                if (selectedId == array[i].id) {
                    opcion.setAttribute("selected", "");
                }
            } else if (i == 0) {
                opcion.setAttribute("selected", "");
            }
            opcion.setAttribute("decimal", array[i].decimals);
            opcion.setAttribute("total", array[i].total.formatted);
            opcion.text = array[i].symbol;
            opcion.value = array[i].id;
            selector.add(opcion);
        }/*
        var req = {
            'sessionid': sessionStorage.getItem('sessionid'),
            'currencyid': document.getElementById('totalPortfolioSelR').value,
            'numofrec': numofrec,
            'filter': document.getElementById("search").value
        };
        if(array.records){
            selector.setAttribute('decimal',array.records[0].decimals)   
        }
        balanceAccounts(req,'initial');  */
    }
}

function removeOptions() {
    if (screen.width > 700) {
        x = document.getElementById('totalPortfolioSel')
        var i, L = x.options.length - 1;
        for (i = L; i >= 0; i--) {
            x.remove(i);
        }
    } else {
        x = document.getElementById('totalPortfolioSelR')
        x.innerHTML = "";
    }
}
var accountsGlob = {};
function balanceAccounts(req, reason) {
    callWS('GET', 'balance/accounts', req, response);
    function response(status, rsp) {
        switch (status) {
            case 200:
                currencies = JSON.parse(rsp).total.currencies;
                addOptions(currencies);

                var newCurrencieArray = [];
                JSON.parse(rsp).total.currencies.forEach(record => {
                    var exist = false;
                    JSON.parse(rsp).accounts.forEach(account => {
                        if (account.currency.id == record.id && account.id > 0) exist = true;
                    });
                    if (!exist) {
                        newCurrencieArray.push(record.id);
                    }
                });

                if (newCurrencieArray.length > 0 && reason === 'initial') {
                    accountsGenerateN(newCurrencieArray.join('-'));
                    accountsGlob = JSON.parse(rsp);
                    balanceDraw(JSON.parse(rsp));
                } else {
                    accountsGlob = JSON.parse(rsp);
                    balanceDraw(JSON.parse(rsp));
                }
                break;
            case 400:
                break;
            case 401:
                expiredSession('balanceAccounts');
                break;
            case 402:
                break;
            case 403:
                break;
            case 500:
                break;
            default:
                break;
        }
    }
}

// Service accounts/generate
function accountsGenerateN(currencies) {
    var sessionid = sessionStorage.getItem('sessionid');
    var req = {
        'sessionid': sessionid,
        'currencies': currencies
    }
    callWS('GET', 'accounts/generate', req, response);
    function response(status, rsp) {
        switch (status) {
            case 200:
                var req = {
                    'sessionid': sessionStorage.getItem('sessionid'),
                    'currencyid': document.getElementById('totalPortfolioSel').value,
                    'numofrec': numofrec,
                    'filter': document.getElementById("search").value
                };
                balanceAccounts(req, '')
                break;
            case 400:
                break;
            case 401:
                expiredSession();
                break;
            case 502:
                var req = {
                    'sessionid': sessionStorage.getItem('sessionid'),
                    'currencyid': document.getElementById('totalPortfolioSel').value,
                    'numofrec': numofrec,
                    'filter': document.getElementById("search").value
                };
                balanceAccounts(req, '');

                document.getElementById('failureMsg').innerHTML = JSON.parse(rsp).msg;
                document.getElementById('failureTitle').innerHTML = getLangById('conerrtit')[lang];
                document.getElementById('tryAgain').innerHTML = getLangById('var2')[lang]
                document.getElementsByClassName('failure')[0].style.display = "table";
                break;
            case 500:
                break;
            default:
                break;
        }
    }
}

function balanceDraw(rsp) {
    var tbl;
    var node;
    var error;
    var header;
    if (screen.width > 700) {
        tbl = document.getElementById('bodyTableCurrencies')
        node = tbl.children[1].cloneNode(true);
        error = tbl.children[0].cloneNode(true);
        tbl.innerHTML = "";
        tbl.appendChild(error);
    } else {
        tbl = document.getElementById('bodyTableCurrenciesR')
        node = tbl.children[1].cloneNode(true);
        error = tbl.children[0].cloneNode(true);
        tbl.innerHTML = "";
        tbl.appendChild(error);
    }

    var tmp = null; tmp = node.cloneNode(true);
    var totconv = 0;
    if ((rsp.numofrecords == 0)) {
        var ele = null;
        ele = tmp.cloneNode(true);
        ele.style.display = "none";
        tbl.appendChild(ele);

        document.getElementById("noCurrencieDefine").style.display = "flex";
        document.getElementById('noCurrencieDefine').style.justifyContent = "center";
        document.getElementById('noCurrencieDefine').classList.add('rowImpar')
        document.getElementById("msgInTable").innerHTML = getLangById("notBalances")[lang];
        document.getElementById("paginator").style.display = "none";

        document.getElementById("noCurrencieDefineR").style.display = "flex";
        document.getElementById('noCurrencieDefineR').style.justifyContent = "center";
        document.getElementById('noCurrencieDefineR').classList.add('rowImpar')
        document.getElementById("msgInTableR").innerHTML = getLangById("notBalances")[lang];

    } else {
        for (var i = 0; i < rsp.accounts.length; i++) {
            document.getElementById('noCurrencieDefine').style.display = "none"
            document.getElementById('noCurrencieDefineR').style.display = "none"
            var actrate = "";
            var totrate = "";
            rsp.total.currencies.forEach(record => {
                if (record.id == rsp.accounts[i].currency.id) actrate = record.rate;
                if (screen.width > 700) {
                    x = document.getElementById('totalPortfolioSel');
                } else {
                    x = document.getElementById('totalPortfolioSelR');
                }
                if (record.id == x.value) totrate = record.rate;

            });
            totconv = 0;
            if (screen.width > 700) {
                document.getElementById("paginator").style.display = "table";
                var ele = null;
                ele = tmp.cloneNode(true);
                ele.style.display = "table";
                ele.children[0].children[0].children[0].innerHTML = rsp.accounts[i].currency.symbol;
                ele.children[1].children[0].children[0].innerHTML = rsp.accounts[i].balance.formatted;
                ele.children[2].children[0].children[0].innerHTML = rsp.accounts[i].last ? rsp.accounts[i].last : 'N/A';
                ele.children[3].children[0].children[0].innerHTML = rsp.accounts[i].pct ? rsp.accounts[i].pct.formatted : '0,00%';
                var totpercurr = 0;
                if (rsp.accounts[i].balance.number > 0)
                    totpercurr = ((rsp.accounts[i].balance.number) * totrate) / actrate;

                var dcim = document.getElementById('totalPortfolioSel').options[document.getElementById('totalPortfolioSel').selectedIndex].getAttribute('decimal');
                ele.children[4].children[0].children[0].innerHTML = number_format(totpercurr, dcim);
                //Ajuste realizado a nuevo campo xfer JR
                if (rsp.accounts[i].currency.xfer/*rsp.record[i].currency.interface == 4 || rsp.record[i].currency.interface == 5 || rsp.record[i].currency.interface == 6*/) {
                    ele.children[5].children[0].children[0].innerHTML = '<i class="fas fa-exchange-alt" style="cursor: pointer; font-size: 130%;"></i>'
                    ele.children[5].children[0].children[0].children[0].setAttribute('i', i)
                    ele.children[5].children[0].children[0].children[0].setAttribute('interface', rsp.accounts[i].currency.interface)
                    ele.children[5].children[0].children[0].children[0].setAttribute('cid', rsp.accounts[i].currency.id)

                    ele.children[5].children[0].children[0].children[0].addEventListener("click", function () {
                        entrydata.level.id < '0.5' ? errorLevel() : gotoPage('step', 'transferCryptoAm', { 'cid': this.getAttribute('cid') })
                    });

                } else {
                    ele.children[5].children[0].children[0].innerHTML = "";
                }
                ele.children[6].children[0].children[0].innerHTML = '<i class="fas fa-download" style="cursor: pointer; font-size: 120%;"></i>'
                ele.children[6].children[0].children[0].children[0].setAttribute('i', i)
                ele.children[6].children[0].children[0].children[0].setAttribute('interface', rsp.accounts[i].currency.interface)
                ele.children[6].children[0].children[0].children[0].setAttribute('cid', rsp.accounts[i].currency.id)
                ele.children[6].children[0].children[0].children[0].setAttribute('decimals', rsp.accounts[i].currency.decimals)
                ele.children[6].children[0].children[0].children[0].setAttribute('idr', rsp.accounts[i].id)
                ele.children[6].children[0].children[0].children[0].addEventListener("click", function () {
                    if (this.getAttribute('interface') == 4 || this.getAttribute('interface') == 5 || this.getAttribute('interface') == 6 || this.getAttribute("interface") == 7) {
                        entrydata.level.id < '0.5' ? errorLevel() : gotoPage('step', 'depositFundsWa', { 'cid': this.getAttribute('cid'), 'idr': this.getAttribute('idr'), 'd': this.getAttribute('decimals') })

                    } else {
                        entrydata.level.id < '0.5' ? errorLevel() : gotoPage('step', 'depositFundsAm', { 'cid': this.getAttribute('cid') })

                    }
                });

                ele.children[7].children[0].children[0].innerHTML = '<i class="fas fa-upload" style="cursor: pointer; font-size: 120%;"></i>'
                ele.children[7].children[0].children[0].children[0].setAttribute('i', i)
                ele.children[7].children[0].children[0].children[0].setAttribute('interface', rsp.accounts[i].currency.interface)
                ele.children[7].children[0].children[0].children[0].setAttribute('cid', rsp.accounts[i].currency.id)
                ele.children[7].children[0].children[0].children[0].addEventListener("click", function () {
                    entrydata.level.id < '0.5' ? errorLevel() : gotoPage('step', 'withdrawFundsAm', { 'cid': this.getAttribute('cid') })
                });

                if (i % 2 != 0) {
                    ele.classList.add('rowImpar')
                } else {
                    ele.classList.add('rowPar')
                }

                ele.setAttribute("id", rsp.accounts[i].id);
                ele.setAttribute("interface", rsp.accounts[i].currency.interface);
                ele.setAttribute("decimals", rsp.accounts[i].currency.decimals);
                ele.setAttribute("icSym", rsp.accounts[i].currency.symbol);

                ele.children[0].children[0].addEventListener("click", function () {
                    openMovementsModal(this.parentNode.parentNode)
                });
                ele.children[1].children[0].addEventListener("click", function () {
                    openMovementsModal(this.parentNode.parentNode)
                });
                ele.children[2].children[0].addEventListener("click", function () {
                    openMovementsModal(this.parentNode.parentNode)
                });
                ele.children[3].children[0].addEventListener("click", function () {
                    openMovementsModal(this.parentNode.parentNode)
                });
                ele.children[4].children[0].addEventListener("click", function () {
                    openMovementsModal(this.parentNode.parentNode)
                });

                tbl.appendChild(ele);
                totconv = document.getElementById('totalPortfolioSel').options[document.getElementById('totalPortfolioSel').selectedIndex].getAttribute('total');
            } else {
                document.getElementById('noCurrencieDefine').style.display = "none"
                document.getElementById("paginator").style.display = "none";
                var ele = null;
                ele = tmp.cloneNode(true);
                ele.style.display = "table";
                ele.children[0].children[4].children[1].innerHTML = document.getElementById('totalPortfolioSelR').selectedOptions[0].text;
                ele.children[1].children[0].children[0].innerHTML = rsp.accounts[i].currency.symbol
                ele.children[1].children[1].children[0].innerHTML = rsp.accounts[i].balance.formatted
                ele.children[1].children[2].children[0].innerHTML = rsp.accounts[i].last ? rsp.accounts[i].last : 'N/A'
                ele.children[1].children[3].children[0].innerHTML = rsp.accounts[i].pct ? rsp.accounts[i].pct.formatted : '0,00%'
                var dcim = document.getElementById('totalPortfolioSelR').options[document.getElementById('totalPortfolioSelR').selectedIndex].getAttribute('decimal');
                var totpercurr = 0;
                if (rsp.accounts[i].balance.number > 0)
                    totpercurr = ((rsp.accounts[i].balance.number) * totrate) / actrate;

                ele.children[1].children[4].children[0].innerHTML = number_format(totpercurr, dcim);
                //ele.children[1].children[4].children[0].innerHTML = rsp.accounts[i].total ?  rsp.accounts[i].total.formatted : number_format(0,document.getElementById('totalPortfolioSelR').getAttribute('decimal'))

                ele.children[2].children[0].children[0].innerHTML = '<i class="fas fa-ellipsis-v" style="cursor: pointer; font-size: 130%;; color: #4287CE"></i>'
                ele.children[2].children[0].children[0].children[0].setAttribute('i', i)

                ele.setAttribute("id", rsp.accounts[i].id);
                ele.setAttribute("interface", rsp.accounts[i].currency.interface);
                ele.setAttribute("decimals", rsp.accounts[i].currency.decimals);
                ele.setAttribute("icSym", rsp.accounts[i].currency.symbol);

                ele.children[1].addEventListener("click", function () {
                    openMovementsModal(this.parentNode)
                });

                if (i % 2 != 0) {
                    ele.classList.add('rowImpar')
                } else {
                    ele.classList.add('rowPar')
                }
                tbl.appendChild(ele);
                totconv = document.getElementById('totalPortfolioSelR').options[document.getElementById('totalPortfolioSelR').selectedIndex].getAttribute('total');
            }

        }
        document.getElementById('movVESBalance').innerHTML = totconv;
        drawPags(rsp.numofrecords, "numbersPaginator", rsp.accounts.length);
    }
}

function drawPags(numofrecords, tbl, recordsAct) {
    var pages;
    if (screen.width > 700) {
        pages = Math.ceil(numofrecords / numofrec);
    } else {
        pages = 1
    }
    var numbersPaginator = document.getElementById(tbl);
    var lastPag = 0;
    if (numbersPaginator.getElementsByClassName("pSelect").length > 0) {
        lastPag = numbersPaginator.getElementsByClassName("pSelect")[0].getAttribute("data-page");
    }
    numbersPaginator.innerHTML = "";
    for (let k = 0; k < pages; k++) {
        var p = document.createElement("div");
        p.classList.add("pages", "roboto-regular");
        p.innerHTML = k + 1;
        p.dataset.page = k + 1;
        if (lastPag == 0 && k == 0) p.classList.add("pSelect");//Se selecciona la p芍gina 1
        else if (lastPag !== 0 && (lastPag - 1) == k) p.classList.add("pSelect");

        p.addEventListener("click", function () {
            //Se desmarca la pagina anterior
            var pSel = document.getElementsByClassName("pSelect");
            if (pSel.length > 0) pSel[0].classList.remove("pSelect");

            //Se actualiza la pagina seleccionada
            this.classList.add("pSelect");

            //Se repinta el listado desde el offset seleccionado
            var filter = document.getElementById("search").value;

            if (filter == null || filter == undefined) {
                filter = '';
            }
            var offset = (this.innerHTML - 1) * recordsAct;
            var sessionId = sessionStorage.getItem('sessionid');
            var numofrecords = numofrec;
            var currencyid = document.getElementById('totalPortfolioSel').value

            var req = {
                'sessionid': sessionStorage.getItem('sessionid'),
                'currencyid': document.getElementById('totalPortfolioSel').value,
                'filter': filter,
                'numofrec': numofrecords,
                'offset': offset
            };
            balanceAccounts(req, '')

            //LoadOrders(filter, offset, sessionId, numofrecords, currencyid);
        });
        p.style.cursor = "pointer";
        numbersPaginator.appendChild(p);

    }
    //Asignacion de eventos validar que se lo se haga una vez
    if (numbersPaginator.getAttribute("arrowsEvent") == "false") {
        var leftArrow = numbersPaginator.previousElementSibling;
        var rightArrow = numbersPaginator.nextElementSibling;
        //Evento flecha izquierda
        leftArrow.addEventListener("click", function () {
            var pSel = document.getElementsByClassName("pSelect");
            if (pSel.length > 0) {
                //Si el elemento anterior al seleccionado es una pagina
                if (pSel[0].previousElementSibling != null && pSel[0].previousElementSibling.classList.contains("pages")) {
                    var last = pSel[0];
                    pSel[0].previousElementSibling.classList.add("pSelect");
                    last.classList.remove("pSelect");
                    //Se repinta el listado desde el offset seleccionado
                    var filter = document.getElementById("search").value;

                    if (filter == null || filter == undefined) {
                        filter = '';
                    }
                    var offset = (parseFloat(document.getElementsByClassName("pSelect")[0].innerHTML) - 1) * recordsAct;
                    var sessionId = sessionStorage.getItem('sessionid');
                    var numofrecords = numofrec;
                    var currencyid = document.getElementById('totalPortfolioSel').value

                    var req = {
                        'sessionid': sessionStorage.getItem('sessionid'),
                        'currencyid': document.getElementById('totalPortfolioSel').value,
                        'filter': filter,
                        'numofrec': numofrecords,
                        'offset': offset
                    };
                    balanceAccounts(req, '')

                    //LoadOrders(filter, offset, order, numofrecords, sessionId, daterange, type, pairid, status);
                }
            }
        });

        //Evento flecha derecha
        rightArrow.addEventListener("click", function () {
            var pSel = document.getElementsByClassName("pSelect");
            if (pSel.length > 0) {
                //Si el elemento anterior al seleccionado es una pagina
                if (pSel[0].nextElementSibling != null && pSel[0].nextElementSibling.classList.contains("pages")) {
                    pSel[0].nextElementSibling.classList.add("pSelect");
                    pSel[0].classList.remove("pSelect");

                    //Se repinta el listado desde el offset seleccionado
                    var filter = document.getElementById("search").value;

                    if (filter == null || filter == undefined) {
                        filter = '';
                    }
                    var offset = (parseFloat(document.getElementsByClassName("pSelect")[0].innerHTML) - 1) * recordsAct;
                    var sessionId = sessionStorage.getItem('sessionid');
                    var numofrecords = numofrec;
                    var currencyid = document.getElementById('totalPortfolioSel').value

                    var req = {
                        'sessionid': sessionStorage.getItem('sessionid'),
                        'currencyid': document.getElementById('totalPortfolioSel').value,
                        'filter': filter,
                        'numofrec': numofrecords,
                        'offset': offset
                    };
                    balanceAccounts(req, '')

                    //LoadOrders(filter, offset, order, numofrecords, sessionId, daterange, type, pairid, status);
                }
            }
        });

        //Evento flecha doble


        //Evento flecha doble derecha

        numbersPaginator.setAttribute("arrowsEvent", true);
    }
    var leftArrow = numbersPaginator.previousElementSibling;
    var rightArrow = numbersPaginator.nextElementSibling;
    if (pages <= 1) {
        leftArrow.style.visibility = "hidden";
        rightArrow.style.visibility = "hidden";
    }
}

function responsiveBalance() {
    document.getElementById('tableCurrencies').style.display = 'none';
    document.getElementById('tableCurrenciesR').style.display = 'block';
    document.getElementById("paginator").style.display = 'none';
    document.getElementsByClassName('subTitlePage')[0].children[0].innerHTML = 'Balance'
    document.getElementById('headerFilter').classList.add('headerFilterR')
    document.getElementById('headerFilter').classList.remove('headerFilter')
    document.getElementById('labelSearch').style.display = 'none'
    document.getElementById('subHeaderFilter').classList.add('subHeaderFilterR')
    document.getElementById('subHeaderFilter').classList.remove('subHeaderFilter')
    document.getElementById('tableContainer').style.paddingTop = '0px';
    document.getElementById('bodyTableCurrenciesR').classList.remove('bodyTableCurrencies');
    document.getElementById('bodyTableCurrenciesR').classList.add('bodyTableCurrenciesR');
}
var interfaceC = 0;
function openMovementsModal(element) {
    interfaceC = element.getAttribute('interface')
    if (entrydata.level.id >= 0.5) {
        if (element.getAttribute("id") == 0) {
            document.getElementsByClassName('accountAttention')[0].style.display = "table"
        } else {
            if (element.getAttribute("interface") == 4 || element.getAttribute("interface") == 5 || element.getAttribute("interface") == 6 || element.getAttribute("interface") == 7) {
                var criptoTit = document.getElementsByClassName("titCripto");
                if (criptoTit.length > 0) {
                    for (var i = 0; i < criptoTit.length; i++) {
                        criptoTit[i].getElementsByTagName("span")[0].innerHTML = element.getAttribute("icSym");
                    }
                }
                seeMovements(element.getAttribute("id"), element.getAttribute('decimals'), 'BTC')
            }

            else if (element.getAttribute("interface") == 3) {

            }

            else if (element.getAttribute("interface") == 1 || element.getAttribute("interface") == 2) {
                var fiatTit = document.getElementsByClassName("titFiat");
                if (fiatTit.length > 0) {
                    for (var i = 0; i < fiatTit.length; i++) {
                        fiatTit[i].getElementsByTagName("span")[0].innerHTML = element.getAttribute("icSym");
                    }
                }
                seeMovements(element.getAttribute("id"), element.getAttribute('decimals'), 'FIAT')
            }
        }
    } else {
        errorLevel();
    }
}

function seeMovements(id, dc, type) {
    var req = {
        'sessionid': sessionStorage.getItem('sessionid'),
        'accountid': id,
        'time': 0,
    }
    transactionsMovements(req, type, dc)
}

function transactionsMovements(req, type, dc) {
    callWS('GET', 'transactions/movements', req, response);
    function response(status, rsp) {
        switch (status) {
            case 200:
                if (type == 'BTC') {
                    if (JSON.parse(rsp).records.length == 0) {
                        document.getElementById('movBTCDeferred').innerHTML = number_format(0, dc);
                        document.getElementById('movBTCBalance').innerHTML = number_format(0, dc);
                        document.getElementById('movBTCCommitted').innerHTML = number_format(0, dc);
                        document.getElementById('movBTCTotal').innerHTML = number_format(0, dc);
                    } else {
                        document.getElementById('movBTCDeferred').innerHTML = JSON.parse(rsp).account.deferred.formatted
                        document.getElementById('movBTCBalance').innerHTML = JSON.parse(rsp).account.balance.formatted
                        document.getElementById('movBTCCommitted').innerHTML = JSON.parse(rsp).account.committed.formatted
                        document.getElementById('movBTCTotal').innerHTML = number_format(JSON.parse(rsp).account.deferred.number + JSON.parse(rsp).account.balance.number + JSON.parse(rsp).account.committed.number, dc);
                    }
                    transformTransactionsMovementsBTC(JSON.parse(rsp))
                } else {
                    if (JSON.parse(rsp).records.length == 0) {
                        document.getElementById('movVESDeferred').innerHTML = number_format(0, dc);
                        document.getElementById('movVESBalancee').innerHTML = number_format(0, dc);
                        document.getElementById('movVESCommitted').innerHTML = number_format(0, dc);
                        document.getElementById('movVESTotal').innerHTML = number_format(0, dc);
                    } else {
                        document.getElementById('movVESDeferred').innerHTML = JSON.parse(rsp).account.deferred.formatted
                        document.getElementById('movVESBalancee').innerHTML = JSON.parse(rsp).account.balance.formatted
                        document.getElementById('movVESCommitted').innerHTML = JSON.parse(rsp).account.committed.formatted
                        document.getElementById('movVESTotal').innerHTML = number_format(JSON.parse(rsp).account.deferred.number + JSON.parse(rsp).account.balance.number + JSON.parse(rsp).account.committed.number, dc);
                    }
                    transformTransactionsMovementsVES(JSON.parse(rsp))
                }
                break;
            case 400:
                break;
            case 401:
                expiredSession();
                break;
            case 500:
                break;
            default:
                break;
        }
    }
}

function getEntry(sessionid) {
    callWS("GET", "users/entry", { 'sessionid': sessionid }, response);

    function response(status, rsp) {
        switch (status) {
            case 200:
                if (JSON.parse(rsp).notifications > 0) {
                    document.getElementById('messageNotification').style.display = "table";
                    document.getElementById('messageNotification').children[0].innerHTML = JSON.parse(rsp).notifications;
                } else {
                    document.getElementById('messageNotification').style.display = "none";
                    document.getElementById('messageNotification').children[0].innerHTML = "";
                }
                view = JSON.parse(rsp).entry.view;
                entrydata = (JSON.parse(rsp).entry);
                if (entrydata.level.id == 4) entrydata.level.id = 0.5;
                putName(entrydata);
                break;
            case 204:
                break;
            case 400:
                break;
            case 401:
                expiredSession();
                break;
            case 500:
                // Error
                break;
            default:
                break;
        }
    }
}

function putName(entrydata) {
    var name;
    if (entrydata.company) {
        if (entrydata.company.name.value == "" || entrydata.company.name.value == null) {
            name = entrydata.usr
        } else {
            name = entrydata.company.name.value
        }
    }
    else if (entrydata.person) {
        if (entrydata.person.firstname.value == "" || entrydata.person.firstname.value == null) {
            name = entrydata.usr
        } else {
            name = entrydata.person.firstname.value + ' ' + entrydata.person.firstlastname.value
        }
    }
    document.getElementById('headname').innerHTML = name
    document.getElementById('name2').innerHTML = name
}

function transformTransactionsMovementsBTC(data) {
    dataArray = []
    for (var i = 0; i < data.numofrecords; i++) {
        if (data.records[i].status == 0) {
            data.records[i].status = 'yellow'
            ////0 Pendiente, -1 Rechazado, 1 Aprobado
        }
        if (data.records[i].status == -1) {
            data.records[i].status = 'red'
        }
        if (data.records[i].status == 1) {
            data.records[i].status = 'green'
        }
        dataArray.push({
            'status': data.records[i].status,
            'date': data.records[i].date.formatted,
            'description': data.records[i].dsc,
            'total': data.records[i].amount.formatted,
            'id': data.records[i].id,
            'type': data.records[i].type,
            'txid': data.records[i].txid,
            'optype': data.records[i].optype
        })
    }
    //listDraw(dataArray, 'dataFiat')
    listDrawDataArray(dataArray, data.account.currency.id)
    document.getElementsByClassName('movBTC')[0].style.display = "table"
    document.getElementsByTagName('body')[0].classList.add('hidden')
}

function listDrawDataArray(rsp, idCur) {
    var tbl;
    var node;
    if (screen.width > 700) {
        tbl = document.getElementById("imovBTC").children[0];
        var node = tbl.children[0].cloneNode(true);
        tbl.children[0].innerHTML = "";
    } else {
        document.getElementById("imovBTC").style.display = 'none'
        document.getElementById("imovBTCR").style.display = 'block'
        tbl = document.getElementById("imovBTCR").children[0];
        var node = tbl.children[0].cloneNode(true);
        tbl.children[0].innerHTML = "";
    }
    var tmp = null; tmp = node.cloneNode(true);
    tbl.innerHTML = ''
    if (!(rsp.length > 0)) {
        var ele = null;
        ele = tmp.cloneNode(true);
        ele.style.display = "none";
        tbl.appendChild(ele);
    } else {
        for (var i = 0; i < rsp.length; i++) {
            var ele = null;
            ele = tmp.cloneNode(true);
            ele.style.display = "table";
            if (rsp[i].name !== "") {
                if (rsp[i].status == 'green') {
                    ele.children[0].children[0].innerHTML = '<i class="fas fa-check-circle" style="font-size: 55%; top: -4px; position: relative; color: #85BB4F"></i>'
                }
                else if (rsp[i].status == 'red') {
                    ele.children[0].children[0].innerHTML = '<i class="fas fa-times-circle" style="font-size: 55%; top: -4px; position: relative; color: #C04F5D"></i>'
                }
                else if (rsp[i].status == 'yellow') {
                    ele.children[0].children[0].innerHTML = '<i class="fas fa-pause-circle" style="font-size: 55%; top: -4px; position: relative; color: #f2c542"></i>'
                }

                if (screen.width > 700) {
                    ele.children[0].children[1].children[0].innerHTML = rsp[i].date
                    ele.children[0].children[2].children[0].innerHTML = rsp[i].id
                    ele.children[0].children[3].children[0].innerHTML = rsp[i].description
                    ele.children[0].children[4].children[0].innerHTML = (rsp[i].total)

                    // rsp[i].type == 3 -> Transferencia
                    if (rsp[i].type != 3 && rsp[i].optype != 'FEE' && rsp[i].txid != null) {
                        ele.children[0].children[5].innerHTML = '<i class="fas fa-external-link-alt" style="font-size: 50%; top: -4px; position: relative; color: #4287CE; cursor: pointer"></i>'
                        ele.children[0].children[5].children[0].setAttribute("id", rsp[i].id);
                        ele.children[0].children[5].children[0].setAttribute("txid", rsp[i].txid);
                        ele.children[0].children[5].children[0].setAttribute("interface", idCur);
                        ele.children[0].children[5].children[0].addEventListener("click", function (e) {
                            openBlockChainPag(e.srcElement.getAttribute('txid'), interfaceC);
                        });
                    } else {
                        ele.children[0].children[5].innerHTML = ''
                    }

                    if (i % 2 != 0) {
                        ele.children[0].style.backgroundColor = 'rgba(245, 246, 248, 0.800000011920929)'
                    }
                    tbl.appendChild(ele);
                    if (getBrowserInfo().startsWith('Firefox')) {
                        if (rsp.length >= 10) {
                            document.getElementById('canBTC').style.marginRight = '18px'
                            document.getElementById('imovBTC').style.paddingRight = '10px'
                        }
                    }
                } else {
                    ele.children[0].children[1].children[0].innerHTML = rsp[i].date + '<br>' + rsp[i].description
                    ele.children[0].children[2].children[0].innerHTML = 'TXID ' + rsp[i].id + '<br>' + (rsp[i].total)


                    if (rsp[i].type != 3 && rsp[i].optype != 'FEE' && rsp[i].txid != null) {
                        ele.children[0].children[3].innerHTML = '<i class="fas fa-external-link-alt" style="font-size: 50%; top: -4px; position: relative; color: #4287CE; cursor: pointer"></i>'
                        ele.children[0].children[3].children[0].setAttribute("id", rsp[i].id);
                        ele.children[0].children[3].children[0].setAttribute("txid", rsp[i].txid);
                        ele.children[0].children[3].children[0].addEventListener("click", function (e) {
                            openBlockChainPag(e.srcElement.getAttribute('txid'), interfaceC)
                        });
                    } else {
                        ele.children[0].children[3].innerHTML = ''
                    }

                    if (i % 2 != 0) {
                        ele.children[0].style.backgroundColor = 'rgba(245, 246, 248, 0.800000011920929)'
                    }
                    tbl.appendChild(ele);
                }
            }

        }

    }
}

var getBrowserInfo = function () {
    var ua = navigator.userAgent, tem,
        M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
    if (/trident/i.test(M[1])) {
        tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
        return 'IE ' + (tem[1] || '');
    }
    if (M[1] === 'Chrome') {
        tem = ua.match(/\b(OPR|Edge)\/(\d+)/);
        if (tem != null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
    }
    M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
    if ((tem = ua.match(/version\/(\d+)/i)) != null) M.splice(1, 1, tem[1]);
    return M.join(' ');
};

function openBlockChainPag(id, type) {
    if (type == 4) {
        window.open('https://www.blockchain.com/search?search=' + id, '_blank');
    } else if (type == 5) {
        window.open('https://explorador.petro.gob.ve/insight/transaction/' + id, '_blank');
    } else if (type == 6) {
        window.open('https://tronscan.org/#/transaction/' + id, '_blank');
    } else if (type == 7) {
        //window.open('https://blockexplorer.one/dash/testnet/tx/' + id, '_blank');
        window.open('https://blockexplorer.one/dash/tx/' + id, '_blank'); //<-- Real blockchain
    }
}

function transformTransactionsMovementsVES(data) {
    dataArray = []
    for (var i = 0; i < data.numofrecords; i++) {
        if (data.records[i].status == 0) {
            data.records[i].status = 'yellow'
            ////0 Pendiente, -1 Rechazado, 1 Aprobado
        }
        if (data.records[i].status == -1) {
            data.records[i].status = 'red'
        }
        if (data.records[i].status == 1) {
            data.records[i].status = 'green'
        }
        dataArray.push({
            'status': data.records[i].status,
            'date': data.records[i].date.formatted,
            'description': data.records[i].dsc,
            'total': data.records[i].amount.formatted,
            'id': data.records[i].id,
            'type': data.records[i].type,
            'optype': data.records[i].optype,
            'imageview': data.records[i].imageview
        })
    }
    listDrawDataFiat(dataArray)
    document.getElementsByClassName('movVES')[0].style.display = "table"
    document.getElementsByTagName('body')[0].classList.add('hidden')
}

function listDrawDataFiat(rsp) {
    var tbl;
    var node;
    if (screen.width > 700) {
        tbl = document.getElementById("imovVES").children[0];
        var node = tbl.children[0].cloneNode(true);
        tbl.children[0].innerHTML = "";
    } else {
        document.getElementById("imovVES").style.display = 'none'
        document.getElementById("imovVESR").style.display = 'block'
        tbl = document.getElementById("imovVESR").children[0];
        var node = tbl.children[0].cloneNode(true);
        tbl.children[0].innerHTML = "";
    }
    var tmp = null; tmp = node.cloneNode(true);
    tbl.innerHTML = ''
    if (!(rsp.length > 0)) {
        var ele = null;
        ele = tmp.cloneNode(true);
        ele.style.display = "none";
        tbl.appendChild(ele);
    } else {
        for (var i = 0; i < rsp.length; i++) {
            var ele = null;
            ele = tmp.cloneNode(true);
            ele.style.display = "table";
            if (rsp[i].name !== "") {
                if (rsp[i].status == 'green') {
                    ele.children[0].children[0].innerHTML = '<i class="fas fa-check-circle" style="font-size: 55%; top: -4px; position: relative; color: #85BB4F"></i>'
                }
                else if (rsp[i].status == 'red') {
                    ele.children[0].children[0].innerHTML = '<i class="fas fa-times-circle" style="font-size: 55%; top: -4px; position: relative; color: #C04F5D"></i>'
                }
                else if (rsp[i].status == 'yellow') {
                    ele.children[0].children[0].innerHTML = '<i class="fas fa-pause-circle" style="font-size: 55%; top: -4px; position: relative; color: #f2c542"></i>'
                }
                if (screen.width > 700) {
                    ele.children[0].children[1].children[0].innerHTML = rsp[i].date
                    ele.children[0].children[1].children[0].setAttribute("date", rsp[i].date);
                    ele.children[0].children[2].children[0].innerHTML = rsp[i].description
                    ele.children[0].children[3].children[0].innerHTML = (rsp[i].total)
                    ele.children[0].children[3].children[0].setAttribute("total", rsp[i].date);
                    /*if ((rsp[i].description == "Retiro" ||
                            rsp[i].description == "Comisión de Retiro" ||
                            rsp[i].description == "Depósito inicial de pruebas" ||
                            rsp[i].description == "Comisión de Depósito inicial de pruebas" ||
                            rsp[i].description == "Depósito" ||
                            rsp[i].description == "Comisión de Depósito") && !((rsp[i].description).indexOf("Comisión") >= 0)) {*/
                    if ((rsp[i].optype == 'DEP' || rsp[i].optype == "WITH") && rsp[i].imageview) {
                        ele.children[0].children[4].innerHTML = '<i class="fas fa-eye tableMovEye"></i>'
                        ele.children[0].children[4].children[0].setAttribute("id", rsp[i].id);
                        ele.children[0].children[4].children[0].addEventListener("click", function (e) {
                            openMovDetailFiat(e.srcElement.id)
                        });
                    } else {
                        ele.children[0].children[4].innerHTML = '';
                    }

                    if (i % 2 != 0) {
                        ele.children[0].style.backgroundColor = 'rgba(245, 246, 248, 0.800000011920929)'
                    }

                    tbl.appendChild(ele);
                    if (getBrowserInfo().startsWith('Firefox')) {
                        if (rsp.length >= 10) {
                            document.getElementById('amountVES').style.marginRight = '18px'
                            document.getElementById('imovVES').style.paddingRight = '15px'
                            document.getElementById('datVES').parentNode.style.width = '29%'
                        }
                    }

                    if (getBrowserInfo().startsWith('Chrome')) {
                        document.getElementById('datVES').parentNode.style.width = "29%"
                        if (rsp.length >= 10) {
                            document.getElementById('amountVES').style.marginRight = '22px'
                            document.getElementById('imovVES').style.paddingRight = '10px'
                        }
                    }
                } else {
                    ele.children[0].children[1].children[0].innerHTML = rsp[i].date + '<br>' + rsp[i].description
                    ele.children[0].children[2].children[0].innerHTML = (rsp[i].total)

                    /*if ((rsp[i].description == "Retiro" ||
                            rsp[i].description == "Comisión de Retiro" ||
                            rsp[i].description == "Depósito inicial de pruebas" ||
                            rsp[i].description == "Comisión de Depósito inicial de pruebas" ||
                            rsp[i].description == "Depósito" ||
                            rsp[i].description == "Comisión de Depósito") && !((rsp[i].description).indexOf("Comisión") >= 0)) {*/
                    if ((rsp[i].optype == 'DEP' || rsp[i].optype == "WITH") && rsp[i].imageview) {
                        ele.children[0].children[3].innerHTML = '<i class="fas fa-eye tableMovEye"></i>'
                        ele.children[0].children[3].children[0].setAttribute("id", rsp[i].id);
                        ele.children[0].children[3].children[0].addEventListener("click", function (e) {
                            openMovDetailFiat(e.srcElement.id)
                        });
                    } else {
                        ele.children[0].children[3].innerHTML = ''
                    }

                    if (i % 2 != 0) {
                        ele.children[0].style.backgroundColor = 'rgba(245, 246, 248, 0.800000011920929)'
                    }
                    tbl.appendChild(ele);
                }

            }

        }

    }
}

function openMovDetailFiat(id) {
    var req = {
        'sessionid': sessionStorage.getItem('sessionid'),
        'id': id,
        'time': 0,
    }

    transactionsEntry(req)
}

// transacionts/entry

function transactionsEntry(req) {
    callWS('GET', 'transactions/entry', req, response);
    function response(status, rsp) {
        switch (status) {
            case 200:
                /*MODIFICADO*/
                var trans = JSON.parse(rsp).entry;
                var amount = trans.amount.formatted;
                var total = trans.total.formatted;
                var fee = trans.fee.formatted;
                if (trans.origin) {
                    document.getElementById('movDetailFiatAddress').style.display = 'table';
                    document.getElementById('movDetailFiatAddressHr').style.display = 'block';
                    document.getElementById('movDetailFiatAddress').style.display = 'table';
                    document.getElementById('movDetailFiatAddressHr').style.display = 'block';
                    document.getElementById('movDetailFiatAddress').style.display = 'table';
                    document.getElementById('movDetailFiatAddressHr').style.display = 'block';
                    document.getElementById('movDetailFiatAccount').innerHTML = this.transformAccountString(JSON.parse(rsp).entry.destination.account.paymentmethod.dsc, JSON.parse(rsp).entry.destination.account.details1)
                    document.getElementById("movDetailTit").innerHTML = getLangById("withdrawLine")[lang] + trans.origin.account.currency.symbol;
                    /*
                    if(valid !== null)document.getElementById("resend").style.display = "";
                    else document.getElementById("resend").style.display = "none";*/
                    document.getElementById("resend").parentElement.parentElement.style.display = "none";

                    /*if(JSON.parse(rsp).entry.destination.account.details1){
                        
                    }else{
                        console.log(JSON.parse(rsp).entry.destination.account.details1)
                        document.getElementById('movDetailFiatAddress').style.display = 'none';
                        document.getElementById('movDetailFiatAddressHr').style.display = 'none';
                        document.getElementById('movDetailFiatAccount').innerHTML = '';
                        document.getElementById("movDetailTit").innerHTML = "Retiro "+ trans.destination.account.currency.symbol; 
                        document.getElementById("resend").parentElement.parentElement.style.display = "none";

                    }     */
                    document.getElementById('movDetailFiatAmount').innerHTML = total;
                    document.getElementById('movDetailFiatAmountRet').innerHTML = amount;
                    document.getElementById('comisionFiatDetails').innerHTML = fee;
                    document.getElementById('movDetailFiatDate').innerHTML = JSON.parse(rsp).entry.datecreated.formatted;
                    document.getElementById('movDetailFiatSeeComprobant').setAttribute("comp", JSON.parse(rsp).entry.payment.url);
                    document.getElementsByClassName('movDetailFiat')[0].style.display = "table";
                    document.getElementsByClassName('movVES')[0].style.display = "none";
                    document.getElementById('movDetailLblAmount').innerHTML = getLangById("amountWithdrawn")[lang];

                } else if (trans.destination) {
                    document.getElementById("movDetailTit").innerHTML = getLangById("depositLine")[lang] + trans.destination.account.currency.symbol;

                    document.getElementById('movDetailFiatAddress').style.display = 'table';
                    document.getElementById('movDetailFiatAddressHr').style.display = 'block';
                    document.getElementById('movDetailFiatAccount').innerHTML = this.transformAccountString(JSON.parse(rsp).entry.destination.account.paymentmethod.dsc, JSON.parse(rsp).entry.destination.account.details1)
                    document.getElementById("resend").parentElement.parentElement.style.display = "table";
                    /*}else{
                        console.log(JSON.parse(rsp).entry.destination.account.details1)
                        document.getElementById('movDetailFiatAddress').style.display = 'none';
                        document.getElementById('movDetailFiatAddressHr').style.display = 'none';
                        document.getElementById('movDetailFiatAccount').innerHTML = '';
                        document.getElementById("movDetailTit").innerHTML = "COMISIÓN DE DEPOSIO";
                        document.getElementById("resend").parentElement.parentElement.style.display = "none";
                    }*/
                    document.getElementById('movDetailLblAmount').innerHTML = getLangById("amountDeposit")[lang];
                    document.getElementById('movDetailFiatDate').innerHTML = JSON.parse(rsp).entry.datecreated.formatted;
                    document.getElementById('movDetailFiatAmount').innerHTML = total;
                    document.getElementById('movDetailFiatAmountRet').innerHTML = amount;
                    document.getElementById('comisionFiatDetails').innerHTML = fee;
                    document.getElementById('movDetailFiatSeeComprobant').setAttribute("comp", JSON.parse(rsp).entry.payment.url);
                    document.getElementsByClassName('movDetailFiat')[0].style.display = "table";
                    document.getElementsByClassName('movVES')[0].style.display = "none";

                }
                break;
            case 400:
                break;
            case 401:
                expiredSession();
                break;
            case 500:
                break;
            default:
                break;
        }
    }
}

function transformAccountString(paymentmethod, details1) {
    return (paymentmethod + '(****' + details1.substr(-4) + ')')
}

function setLang() {

    addFooter()

    lang = sessionStorage.getItem('lang');

    /* inner HTML */
    setWordLanginnerHTML('home', 'home');
    setWordLanginnerHTML('balance', 'balance');
    setWordLanginnerHTML('preferences', 'preferences');
    setWordLanginnerHTML('homeR', 'home');
    setWordLanginnerHTML('balanceR', 'balance');
    setWordLanginnerHTML('preferencesR', 'preferences');
    setWordLanginnerHTML('langIcon', 'langIcon');
    setWordLanginnerHTML('titleBalance', 'balanceSheet');
    setWordLanginnerHTML('labelSearch', 'search');
    setWordLanginnerHTML('currencyLabelMov', 'currency');
    setWordLanginnerHTML('balanceLabelMov', 'balance');
    setWordLanginnerHTML('lastOperationLabelMov', 'lastOperation');
    setWordLanginnerHTML('percentagesLabelMov', 'percentages');
    setWordLanginnerHTML('expressedInLabelMov', 'expressedIn');
    setWordLanginnerHTML('trasnferLabelMov', 'transfer');
    setWordLanginnerHTML('depositLabelMov', 'deposit');
    setWordLanginnerHTML('withdrawLabelMov', 'withdraw');
    setWordLanginnerHTML('currencyLabelMovR', 'currency');
    setWordLanginnerHTML('balanceLabelMovR', 'balance');
    setWordLanginnerHTML('lastOperationMovR', 'lastOperation');
    setWordLanginnerHTML('percentageMovR', 'percentages');
    setWordLanginnerHTML('expressedInLabelMovR', 'expressedInR');
    setWordLanginnerHTML('expressInRMov', 'expressedInRTable');
    setWordLanginnerHTML('ts', 'ts');
    setWordLanginnerHTML('completeLater', 'completeLater');
    setWordLanginnerHTML('completeLaterAccept', 'completeThen');
    setWordLanginnerHTML('completeLaterCancel', 'cancel');
    setWordLanginnerHTML('expired1', 'expired1');
    setWordLanginnerHTML('expired2', 'expired2');
    setWordLanginnerHTML('expSessionButton', 'continue')
    setWordLanginnerHTML('MovLabelBTC', 'movementsSpan');
    setWordLanginnerHTML('statBTC', 'status');
    setWordLanginnerHTML('datBTC', 'date');
    setWordLanginnerHTML('desBTC', 'description');
    setWordLanginnerHTML('canBTC', 'quantity');
    setWordLanginnerHTML('AvaMovLabel', 'AVAILABLE');
    setWordLanginnerHTML('defMovLabel', 'DEFERRED');
    setWordLanginnerHTML('comMovLabel', 'COMMITTED');
    setWordLanginnerHTML('movBTCBack', 'BACK');
    setWordLanginnerHTML('LabelFiatMov', 'movementsSpan');
    setWordLanginnerHTML('fiatLabelMov', 'status');
    setWordLanginnerHTML('datVES', 'date');
    setWordLanginnerHTML('fiatLabelDes', 'description');
    setWordLanginnerHTML('amountVES', 'quantity');
    setWordLanginnerHTML('AvaMovLabelF', 'AVAILABLE');
    setWordLanginnerHTML('defMovLabelF', 'DEFERRED');
    setWordLanginnerHTML('comMovLabelF', 'COMMITTED');
    setWordLanginnerHTML('movVESBack', 'BACK');
    setWordLanginnerHTML('comisionFiatDetailsLabel', 'fees');
    setWordLanginnerHTML('movDetailFiatAmountLabel', 'netTotal');
    setWordLanginnerHTML('movDetailFiatAccountLabel', 'destinationAccount');
    setWordLanginnerHTML('movDetailFiatDateLabel', 'date');
    setWordLanginnerHTML('resend', 'seeVoucher');
    setWordLanginnerHTML('detailFiatButton', 'TOACCEPT');
    setWordLanginnerHTML('accountAttentionTitle', 'attention');
    setWordLanginnerHTML('amountValidationText', 'notHaveAcc');
    setWordLanginnerHTML('acceptNoAccount', 'TOACCEPT');

    getEntry(sessionStorage.getItem('sessionid'));

}






