/* Minification failed. Returning unminified contents.
(1,46-47): run-time error JS1195: Expected expression: )
(1,49-50): run-time error JS1195: Expected expression: >
(4,74-75): run-time error JS1195: Expected expression: )
(4,77-78): run-time error JS1195: Expected expression: >
(13,10-11): run-time error JS1195: Expected expression: )
(15,1-2): run-time error JS1002: Syntax error: }
(17,22-23): run-time error JS1004: Expected ';': {
 */
window.addEventListener('DOMContentLoaded', () => {
    if (document.getElementById('toolbar-main-container') !== null) {
        let state = false;
        document.getElementById('menuMobile').addEventListener('click', () => {
            if (state === false) {
                document.getElementById('mobileMenuContainer').classList.add('menu-mobile-container-show');
                state = !state;
            }
            else {
                document.getElementById('mobileMenuContainer').classList.remove('menu-mobile-container-show');
                state = !state;
            }
        });
    }
});

function logOutExN() {

    TLBSetLoadingPageStatus();

    $.ajax({
        type: 'GET',
        url: AuthServicesUrl,
        data: 'Field=LogoutEx',
        async: true,
        cache: false,
        crossDomain: true,
        dataType: "jsonp",
        success: function (jsonResponse) {
            setTimeout(function () {
                location.href = location.origin;
                //var host = window.location.hostname;
                //if (host.indexOf("localhost") > -1)
                //    window.location = Ax5Site;
                //else if (host.indexOf("billingtst") > -1 || host.indexOf("webtest") > -1) {
                //    if (host.indexOf(".br") > -1)
                //        window.location = "http://webtest.axeso5.com.br";
                //    else
                //        window.location = "https://webtest.axeso5.com";
                //} else {
                //    if (host.indexOf("billing") > -1 || window.location.pathname.indexOf("mi-cuenta") > -1) {
                //        if (host.indexOf(".br") > -1)
                //            window.location = "https://www.axeso5.com.br";
                //        else
                //            window.location = "https://www.axeso5.com";
                //    }
                //    else {
                //        window.location.reload();
                //    }
                //}
            }, 500);
        },
        error: function () {
            TLBRemoveLoadingPageStatus();
        }
    });
}

function TLBAxeso5Login()
{
	window.location = Ax5Site + "/login?returnUrl=" + escape(window.location);
}

/************ LOADING ************** */

var regCurrentLoadingObject;

function TLBSetLoadingStatus(obj) {
    const divLoading = document.createElement("div");
    divLoading.setAttribute("id", "divLoading-" + obj.id);

    divLoading.style.width = obj.clientWidth + "px";
    divLoading.style.height = obj.clientHeight + "px";
    divLoading.style.verticalAlign = "middle";
    divLoading.style.textAlign = "center";
    divLoading.style.position = "relative";

    const divLoader = document.createElement("div");
    divLoader.setAttribute("id", "divLoader-" + obj.id);
    divLoader.setAttribute("class", "TLBballContainer");

    const spanLoading = document.createElement("span");
    spanLoading.setAttribute("id", "spanLoading-" + obj.id);

    divLoader.appendChild(spanLoading);

    obj.style.display = "none";

    divLoading.appendChild(divLoader);
    obj.parentNode.appendChild(divLoading);

    regCurrentLoadingObject = obj;
}

function TLBRemoveLoadingStatus() {
    if (typeof regCurrentLoadingObject != 'undefined') {
        if (regCurrentLoadingObject != null) {

            document.getElementById("divLoading-" + regCurrentLoadingObject.id).remove();

            regCurrentLoadingObject.style.display = "";

            regCurrentLoadingObject = null;
        }
    }
}

function TLBSetLoadingPageStatus() {
    document.body.style.height = "100%";
    document.getElementsByTagName("html")[0].style.height = "100%";

    const divLoadingPage = document.createElement("divLoadingPage");
    divLoadingPage.setAttribute("id", "divLoadingPage");

	divLoadingPage.style.display = 'block';
    divLoadingPage.style.verticalAlign = "middle";
    divLoadingPage.style.textAlign = "center";
    divLoadingPage.style.zIndex = 1000000;
    divLoadingPage.style.position = "fixed";
    divLoadingPage.style.top = "0%";
    divLoadingPage.style.left = "0%";
    divLoadingPage.style.width = "100%";
    divLoadingPage.style.height = "100%";

	try {
		divLoadingPage.style.backgroundColor = "rgba(0,0,0,0.7)";
	}
	catch(e) {
		divLoadingPage.style.filter = "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#50000000', endColorstr='#50000000')"; /* IE 8 */
	}

    let divLoader = document.createElement("div");
    divLoader.setAttribute("class", "TLBballContainer");

    let spanLoading = document.createElement("span");

    divLoader.appendChild(spanLoading);

    divLoadingPage.appendChild(divLoader);

    document.body.appendChild(divLoadingPage);
}

function TLBRemoveLoadingPageStatus() {
    if (document.getElementById("divLoadingPage") != null) {
        let elem = document.getElementById("divLoadingPage");
        elem.parentElement.removeChild(elem);
        document.querySelector('html').setAttribute('style', '');
    }
}

/**********FIN LOADING ************** */;
