/* Minification failed. Returning unminified contents.
(1,46-47): run-time error JS1195: Expected expression: )
(1,49-50): run-time error JS1195: Expected expression: >
(6,68-69): run-time error JS1195: Expected expression: )
(6,70-71): run-time error JS1195: Expected expression: >
(16,4-5): run-time error JS1195: Expected expression: )
(18,1-2): run-time error JS1002: Syntax error: }
(21,22-23): run-time error JS1004: Expected ';': {
(65,5-18): run-time error JS1018: 'return' statement outside of function: return retval
 */
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();

    let retval = '';

    $.ajax({
        type: 'GET',
        url: AuthServicesUrl,
        data: 'Field=LogoutEx',
        async: true,
        cache: false,
        crossDomain: true,
        dataType: "jsonp",
        success: function (htmlResponse) {
            retval = htmlResponse;

            setTimeout(function () {
                var host = window.location.hostname;
                if (host.indexOf("billingtst") > -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();
                    }

            }, 2000);
        },
        error: function () {
            retval = '';
            TLBRemoveLoadingPageStatus();
        }
    })

    return retval;
}

function TLBAxeso5Login()
{
	window.location = Ax5Site + "/login?returnUrl=" + escape(window.location);
}

/************ LOADING ************** */

var regCurrentLoadingObject;

function TLBSetLoadingStatus(obj) {

    var 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";

    var divLoader = document.createElement("div");
    divLoader.setAttribute("id", "divLoader-" + obj.id);
    divLoader.setAttribute("class", "TLBballContainer");


    var 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%";

    var 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);
    }
}

/**********FIN LOADING ************** */;
