/* Minification failed. Returning unminified contents.
(1,16): run-time error CSS1031: Expected selector, found '='
(1,16): run-time error CSS1025: Expected comma or open brace, found '='
(2,21): run-time error CSS1031: Expected selector, found '='
(2,21): run-time error CSS1025: Expected comma or open brace, found '='
(3,23): run-time error CSS1031: Expected selector, found '='
(3,23): run-time error CSS1025: Expected comma or open brace, found '='
(4,20): run-time error CSS1031: Expected selector, found '='
(4,20): run-time error CSS1025: Expected comma or open brace, found '='
(5,19): run-time error CSS1031: Expected selector, found '='
(5,19): run-time error CSS1025: Expected comma or open brace, found '='
(6,20): run-time error CSS1031: Expected selector, found '='
(6,20): run-time error CSS1025: Expected comma or open brace, found '='
(7,19): run-time error CSS1031: Expected selector, found '='
(7,19): run-time error CSS1025: Expected comma or open brace, found '='
(8,21): run-time error CSS1031: Expected selector, found '='
(8,21): run-time error CSS1025: Expected comma or open brace, found '='
(10,16): run-time error CSS1031: Expected selector, found 'LiberarPlaza('
(10,16): run-time error CSS1025: Expected comma or open brace, found 'LiberarPlaza('
(152,10): run-time error CSS1031: Expected selector, found 'CambiarTitle('
(152,10): run-time error CSS1025: Expected comma or open brace, found 'CambiarTitle('
(162,10): run-time error CSS1031: Expected selector, found 'UpdateDate('
(162,10): run-time error CSS1025: Expected comma or open brace, found 'UpdateDate('
(168,16): run-time error CSS1031: Expected selector, found 'CambiarEstadoPlaza('
(168,16): run-time error CSS1025: Expected comma or open brace, found 'CambiarEstadoPlaza('
(291,16): run-time error CSS1031: Expected selector, found 'EstadoPlazaDiaSeleccionado('
(291,16): run-time error CSS1025: Expected comma or open brace, found 'EstadoPlazaDiaSeleccionado('
(300,10): run-time error CSS1031: Expected selector, found 'PlazaOcupada('
(300,10): run-time error CSS1025: Expected comma or open brace, found 'PlazaOcupada('
(304,10): run-time error CSS1031: Expected selector, found 'updateDiv('
(304,10): run-time error CSS1025: Expected comma or open brace, found 'updateDiv('
(324,10): run-time error CSS1031: Expected selector, found 'setDateTime('
(324,10): run-time error CSS1025: Expected comma or open brace, found 'setDateTime('
(328,10): run-time error CSS1031: Expected selector, found 'setVisibility('
(328,10): run-time error CSS1025: Expected comma or open brace, found 'setVisibility('
(338,10): run-time error CSS1031: Expected selector, found 'EstaModificando('
(338,10): run-time error CSS1025: Expected comma or open brace, found 'EstaModificando('
(342,10): run-time error CSS1031: Expected selector, found 'CambiarFecha('
(342,10): run-time error CSS1025: Expected comma or open brace, found 'CambiarFecha('
(357,10): run-time error CSS1031: Expected selector, found 'FalloGuardarPeriodo('
(357,10): run-time error CSS1025: Expected comma or open brace, found 'FalloGuardarPeriodo('
(387,10): run-time error CSS1031: Expected selector, found 'OnBegin('
(387,10): run-time error CSS1025: Expected comma or open brace, found 'OnBegin('
(392,10): run-time error CSS1031: Expected selector, found 'ShowModal('
(392,10): run-time error CSS1025: Expected comma or open brace, found 'ShowModal('
(421,10): run-time error CSS1031: Expected selector, found 'ShowModalUrl('
(421,10): run-time error CSS1025: Expected comma or open brace, found 'ShowModalUrl('
(450,10): run-time error CSS1031: Expected selector, found 'ShowModalPlano('
(450,10): run-time error CSS1025: Expected comma or open brace, found 'ShowModalPlano('
(479,10): run-time error CSS1031: Expected selector, found 'ShowModalCorreo('
(479,10): run-time error CSS1025: Expected comma or open brace, found 'ShowModalCorreo('
(515,10): run-time error CSS1031: Expected selector, found 'ShowModalEditar('
(515,10): run-time error CSS1025: Expected comma or open brace, found 'ShowModalEditar('
(551,10): run-time error CSS1031: Expected selector, found 'ShowModalPeriodo('
(551,10): run-time error CSS1025: Expected comma or open brace, found 'ShowModalPeriodo('
(582,10): run-time error CSS1031: Expected selector, found 'HideModal('
(582,10): run-time error CSS1025: Expected comma or open brace, found 'HideModal('
(586,10): run-time error CSS1031: Expected selector, found 'ShowLoader('
(586,10): run-time error CSS1025: Expected comma or open brace, found 'ShowLoader('
(593,10): run-time error CSS1031: Expected selector, found 'HideLoader('
(593,10): run-time error CSS1025: Expected comma or open brace, found 'HideLoader('
(598,10): run-time error CSS1031: Expected selector, found 'openTab('
(598,10): run-time error CSS1025: Expected comma or open brace, found 'openTab('
(619,10): run-time error CSS1031: Expected selector, found 'PopupCorrecto('
(619,10): run-time error CSS1025: Expected comma or open brace, found 'PopupCorrecto('
(623,10): run-time error CSS1031: Expected selector, found 'PopupError('
(623,10): run-time error CSS1025: Expected comma or open brace, found 'PopupError('
(627,10): run-time error CSS1031: Expected selector, found 'PopupAdvertencia('
(627,10): run-time error CSS1025: Expected comma or open brace, found 'PopupAdvertencia('
(630,10): run-time error CSS1031: Expected selector, found 'ObtenerValorFilaTelerik('
(630,10): run-time error CSS1025: Expected comma or open brace, found 'ObtenerValorFilaTelerik('
(638,10): run-time error CSS1031: Expected selector, found 'SendGridValue('
(638,10): run-time error CSS1025: Expected comma or open brace, found 'SendGridValue('
(660,10): run-time error CSS1031: Expected selector, found 'CrearDelegado('
(660,10): run-time error CSS1025: Expected comma or open brace, found 'CrearDelegado('
(702,10): run-time error CSS1031: Expected selector, found 'EliminarDelegado('
(702,10): run-time error CSS1025: Expected comma or open brace, found 'EliminarDelegado('
(727,1): run-time error CSS1019: Unexpected token, found 'jQuery('
(727,17): run-time error CSS1031: Expected selector, found '('
(727,17): run-time error CSS1025: Expected comma or open brace, found '('
(770,2): run-time error CSS1019: Unexpected token, found ')'
 */
const ID_BOTON = "#status-holder";
const ID_TEXT_LIBRE = "#status-text-libre";
const ID_TEXT_OCUPADO = "#status-text-ocup";
const ID_IMG_COCHE = "#CocheOcupado";
const CLASS_COCHE = "imgCoche";
const TITULO_BOTON = "TITULO_BOTON";
const CLICK_EVENT = "CambiarEstadoPlaza()";
const ID_DIV_CAMBIO = "#divCambioDia";

async function LiberarPlaza(e, url, urlAct) {
    let month = '' + (e.getMonth() + 1);
    let day = '' + e.getDate();
    const year = e.getFullYear();

    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;


    let value;
    if (recursos.idioma == "en-EU") {
        value = month + "/" + day + "/" + year;
    }
    else {
        value = day + "/" + month + "/" + year;
    }

    const valueSend = day + "/" + month + "/" + year;

    const date = new Date();
    let diaMaxCorte = date.getDate() + 1;
    let diaMinNoAviso = date.getDate() + 2;
    const fechaMaxAviso = new Date(year, month - 1, diaMaxCorte, recursos.HoraCorte);
    const fechaMinNoAviso = new Date(year, month - 1, diaMinNoAviso);
    let diaHoy = new Date();
    diaHoy.setHours(0, 0, 0, 0);

    const estadoPlaza = await EstadoPlazaDiaSeleccionado(value);

    let gestorDirectorTresCantos = false;
    const empleadoTresCantos = recursos.CodCentro;
    if (empleadoTresCantos == "28XC") {
        gestorDirectorTresCantos = true;
    } else if (recursos.EsGestor == "True") {
        gestorDirectorTresCantos = true;
    }
    else if (recursos.EsDirector == "True" && recursos.PerteneceCentroVisitas == "True") {
        gestorDirectorTresCantos = false;
    }

    //Comentamos las deliberaciones debido a no funcionamiento correcto. 04/06/2024
    /*if (gestorDirectorTresCantos && estadoPlaza == "2") {
        swal({
            title: "Recuperar plaza",
            text: `Recuperar plaza para el día ${value}`,
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: recursos.confirmar,
            cancelButtonText: recursos.cancelar,
        }).then(function () {
            ShowLoader();
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    data: valueSend
                },
            }).done(function (data) {
                HideLoader();
                $("#calendar").data("kendoCalendar").destroy();
                $("#calendar > table").remove();
                $("#calendar > div").remove();
                $("#PartialLiberaciones").html(data);
            }).fail(function () {
                HideLoader();
            });

        }, function (dismiss) {
            // dismiss can be 'cancel', 'overlay', 'close', 'timer'
            if (dismiss === 'cancel') {
                // prevent error on press cancel button
            }
        });
    } else*/ if (estadoPlaza == "2") {
        swal({
            title: 'Plaza liberada',
            text: `La plaza ya se encuentra liberada para el día ${valueSend}`,
            type: 'warning',
            showCancelButton: false,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: "Aceptar"
        });
    } else {
        let titulo = "";
        if (recursos.EstadoParking == "False" && diaHoy.getTime() == e.getTime()) {
            titulo = recursos.tituloMensajeAviso;
        }
        else {
            e.setHours(date.getHours(), date.getMinutes(), date.getSeconds());
            if (recursos.EstadoParking == "False" && (e > fechaMaxAviso) && (e < fechaMinNoAviso)) {
                titulo = recursos.tituloMensajeAviso;
            }
            else {
                titulo = recursos.tituloMensajeLiberacionPlaza
            }
        }
        swal({
            title: titulo,
            text: recursos.textoMensajeLiberar + " <font color='red' style='font-weight: bold'>" + value + "<br>Recuerda que las plazas liberadas no se pueden volver a recuperar.</font>",
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: recursos.confirmar,
            cancelButtonText: recursos.cancelar,

        }).then(function () {
            ShowLoader();
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    data: valueSend
                },
            }).done(function (data) {
                HideLoader();

                $("#calendar").data("kendoCalendar").destroy();
                $("#calendar > table").remove();
                $("#calendar > div").remove();

                $("#PartialLiberaciones").html(data);

                //HideLoader();  
            }).fail(function () {
                HideLoader();
            });

            //updateDiv(urlAct, new Date(fecha), jsonValue);
        }, function (dismiss) {
            // dismiss can be 'cancel', 'overlay', 'close', 'timer'
            if (dismiss === 'cancel') {
                // prevent error on press cancel button
            }
        });
    }
    return false;
}

function CambiarTitle(id, ocupado, libre) {

    if (document.getElementById(id).title == ocupado) {
        document.getElementById(id).title = libre;
    }
    else {
        document.getElementById(id).title = ocupado;
    }
}

function UpdateDate() {
    HideLoader();
    HideModal();
    PopupCorrecto(recursos.tituloGuardado, recursos.mensajeGuardar);
}

async function CambiarEstadoPlaza() {

    let url = $('#divCambioDia').attr('url');
    let urlUpdate = $('#divCambioDia').attr('url-update');

    let valor = new Date();
    if (valor.getUTCDay() === 5) {
        valor.setDate(valor.getDate() + 3);
    } else if (valor.getUTCDay() === 6) {
        valor.setDate(valor.getDate() + 2);
    } else {
        valor.setDate(valor.getDate() + 1);
    }

    const month = '' + (valor.getMonth() + 1);
    const day = '' + valor.getDate();
    const year = valor.getFullYear();
    let diaLiberar;
    if (recursos.idioma == "en-EU") {
        diaLiberar = month + "/" + day + "/" + year;
    }
    else {
        diaLiberar = day + "/" + month + "/" + year;
    }

    let arrayFestivos = recursos.festivos;

    for (var i = 0; i < arrayFestivos.length; i++) {
        const [day, month, year] = arrayFestivos[i].split('/');

        const fecha = new Date(year, month - 1, day);
        if (fecha.toLocaleDateString('es-ES') == diaLiberar) {
            const daySiguiente = '' + (valor.getDate() + 1);
            diaLiberar = daySiguiente + "/" + month + "/" + year
        }
    }

    const estadoPlaza = await EstadoPlazaDiaSeleccionado(diaLiberar);

    const date = new Date();
    let diaMaxCorte = date.getDate() + 1;
    const fechaMaxAviso = new Date(year, month - 1, diaMaxCorte, 10);

    let titulo = "";
    if (recursos.EstadoParking == "False" && valor > fechaMaxAviso) {
        titulo = recursos.tituloMensajeAviso
    }
    else {
        titulo = recursos.tituloMensajeLiberacionPlaza
    }

    if (estadoPlaza == "2") {
        swal({
            title: 'Plaza liberada',
            text: `La plaza ya se encuentra liberada para el día ${diaLiberar}`,
            type: 'warning',
            showCancelButton: false,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: "Aceptar"
        });
    } else {
        swal({
            title: titulo, //recursos.tituloMensajeLiberar,
            text: recursos.textoMensajeLiberarDiaSiguiente,
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: recursos.confirmar,
            cancelButtonText: recursos.cancelar,

        }).then(function () {
            ShowLoader();
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    //TipoPlaza: $(e).val()
                }
            }).done(function (data) {
                $(ID_DIV_CAMBIO).attr("onclick", CLICK_EVENT);
                $.each(data.Valores, function (_i, item) {
                    if (item.Id == ID_BOTON) {
                        $(ID_BOTON).prop('class', '');
                        $(ID_BOTON).addClass(item.Valor);
                        $(ID_BOTON).prop('title', '');
                    } else if (item.Id == ID_TEXT_LIBRE) {
                        $(ID_TEXT_LIBRE).addClass(item.Valor);
                        $(ID_TEXT_OCUPADO).removeClass(item.Valor);
                    } else if (item.Id == ID_TEXT_OCUPADO) {
                        $(ID_TEXT_OCUPADO).addClass(item.Valor);
                        $(ID_TEXT_LIBRE).removeClass(item.Valor);
                    } else if (item.Id == ID_IMG_COCHE) {
                        $(ID_IMG_COCHE).prop('class', '');
                        $(ID_IMG_COCHE).addClass(CLASS_COCHE + " " + item.Valor);
                    } else if (item.Id == TITULO_BOTON) {
                        $(ID_BOTON).prop('title', item.Valor);
                        $(ID_DIV_CAMBIO).attr("onclick", "");
                    }

                });
                HideLoader();

                $("#calendar").data("kendoCalendar").destroy();
                $("#calendar > table").remove();
                $("#calendar > div").remove();

                $("#PartialLiberaciones").load(urlUpdate);

            }).fail(function () {
                HideLoader();
                swal(recursos.tituloErrorLiberacion, recursos.mensajeErrorLiberacion, "error");
            });
        }, function (dismiss) {
            // dismiss can be 'cancel', 'overlay', 'close', 'timer'
            if (dismiss === 'cancel') {
                // prevent error on press cancel button
            }
        });
    }
};

async function EstadoPlazaDiaSeleccionado(fecha) {
    const result = await $.ajax({
        type: "GET",
        url: "Liberaciones/ObtenerEstadoPlazaDia",
        data: { fecha: fecha }
    });
    return result
}

function PlazaOcupada() {
    swal(recursos.tituloPlazaOcupada, recursos.mensajePlazaOcupada, "warning");
}

function updateDiv(url, fecha, data) {
    $("#PartialLiberaciones").load(url, function () {
        $("#calendar").data("kendoCalendar").value(fecha);

        var valorHtml;
        if (data == recursos.libre) {
            valorHtml = $("#calendar_cell_selected > .k-link").html();
            $("#calendar_cell_selected > .k-link").addClass("date-liberation-style k-state-hover");
            $("#calendar_cell_selected > .k-link").html('<div class="date-liberation">' + valorHtml + '</div>');
            $("#calendar_cell_selected").removeClass("k-state-selected");

        } else {
            valorHtml = $("#calendar_cell_selected > .k-link > .date-liberation").html();
            $("#calendar_cell_selected > .k-link").removeClass("date-liberation-style").removeClass("k-state-hover");
            $("#calendar_cell_selected > .k-link").html(valorHtml);
        }

    });
}

function setDateTime(id) {
    document.getElementById(id).reset();
}

function setVisibility(e, id, visibility) {
    if (visibility == 'none') {
        document.getElementById(e).style.display = 'inline';
    }
    else {
        document.getElementById(e).style.display = 'none';
    }
    document.getElementById(id).style.display = visibility;
}

function EstaModificando(idGrid, idPeriodoModi) {
    return (idGrid == idPeriodoModi);
}

function CambiarFecha() {
    var dtpFechaHasta = new Date($("#dtpFechaHasta").data("kendoDatePicker").value());
    var dtpFechaDesde = new Date($("#dtpFechaDesde").data("kendoDatePicker").value());
    var fechahoy = new Date();

    if (dtpFechaDesde >= dtpFechaHasta) {
        dtpFechaDesde.setDate(dtpFechaDesde.getDate() + 1);
        $("#dtpFechaHasta").data("kendoDatePicker").value(dtpFechaDesde);
    }

    if (dtpFechaDesde <= fechahoy && $("#id_Periodo").val() == "") {
        $("#dtpFechaDesde").data("kendoDatePicker").value(fechahoy);
    }
}

function FalloGuardarPeriodo(data) {
    HideLoader();
    var options = { "backdrop": "static", keyboard: true };
    $('#myModal').modal(options);
    $('#myModal').modal('show');

    $(recursos.eFechaDesde).removeClass(recursos.noVisible);
    $(recursos.eFechaHasta).removeClass(recursos.noVisible);
    $(recursos.eDiasPeriodo).removeClass(recursos.noVisible);

    $(recursos.eFechaDesde).addClass(recursos.noVisible);
    $(recursos.eFechaHasta).addClass(recursos.noVisible);
    $(recursos.eDiasPeriodo).addClass(recursos.noVisible);

    respuesta = data.responseJSON;

    if (respuesta.Code == recursos.CodigoError) {
        if (respuesta.Valores != null && respuesta.Valores.length > 0) {
            jQuery.each(respuesta.Valores, function () {
                $(this.Id).removeClass(this.Valor);
            })
        } else {
            PopupError(recursos.tituloErrorGuardarPeriodo, recursos.mensajeErrorGuardarPeriodo);
        }
    } else {
        PopupError(recursos.tituloErrorGuardarPeriodo, recursos.mensajeErrorGuardarPeriodo);
    }
}


function OnBegin() {
    HideModal();
    ShowLoader();
}

function ShowModal(e) {
    var TeamDetailPostBackURL = $(e).attr('arial-url');

    var options = { "backdrop": "static", keyboard: true };
    ShowLoader();
    $.ajax({
        type: "POST",
        url: TeamDetailPostBackURL,
        //contentType: "application/json; charset=utf-8",
        data: {  },
        //datatype: "json",
        success: function (data) {
            HideLoader();
            $('#myModalContent').html(data);
            $('#myModal').modal(options);
            $('#myModal').modal('show');

        },
        error: function () {
            HideLoader();
            alert("No disponoe de los permisos suficientes para realizar esta acción.");
        }
    });

    $("#closbtn").click(function () {
        HideModal();
    });
}

function ShowModalUrl(Url) {
    var TeamDetailPostBackURL = Url;

    var options = { "backdrop": "static", keyboard: true };
    ShowLoader();
    $.ajax({
        type: "POST",
        url: TeamDetailPostBackURL,
        //contentType: "application/json; charset=utf-8",
        data: {},
        //datatype: "json",
        success: function (data) {
            HideLoader();
            $('#modalCenterContent').html(data);
            $('#modalCenter').modal(options);
            $('#modalCenter').modal('show');

        },
        error: function () {
            HideLoader();
            alert("Dynamic content load failed.");
        }
    });

    $("#closbtn").click(function () {
        HideModal();
    });
}

function ShowModalPlano(Url) {
    var TeamDetailPostBackURL = Url;
    
    var options = { "backdrop": "static", keyboard: true };
    ShowLoader();

    $.ajax({
        type: "POST",
        url: TeamDetailPostBackURL,
        //contentType: "application/json; charset=utf-8",
        data: {},
        //datatype: "json",
        success: function (data) {
            HideLoader();
            $('#modalPlanoContent').html(data);
            $('#modalPlano').modal(options);
            $('#modalPlano').modal('show');
        },
        error: function () {
            HideLoader();
            alert("Dynamic content load failed.");
        }
    });

    $("#closbtn").click(function () {
        HideModal();
    });
}

function ShowModalCorreo(url, idSolicitud, correo, codigoUsuario) {
    if (codigoUsuario === undefined || codigoUsuario === null) {
        var datosEmpleado = $('#tblEmpleados').data("kendoGrid").dataSource.data();
        var codigoUsuario = datosEmpleado[0].CodUsuario;
    }

    var TeamDetailPostBackURL = url;

    var options = { "backdrop": "static", keyboard: true };
    ShowLoader();
    $.ajax({
        type: "POST",
        url: TeamDetailPostBackURL,
        data: {
            idSolicitud: idSolicitud,
            email: correo,
            codUsuario: codigoUsuario
        },
        success: function (data) {
            HideLoader();
            $('#myModalContent').html(data);
            $('#myModal').modal(options);
            $('#myModal').modal('show');

        },
        error: function () {
            HideLoader();
            alert("Dynamic content load failed.");
        }
    });

    $("#closbtn").click(function () {
        HideModal();
    });
}

function ShowModalEditar(e, id, codUsuario) {
    var TeamDetailPostBackURL = $(e).attr('arial-url');

    var options = { "backdrop": "static", keyboard: true };
    ShowLoader();
    $.ajax({
        type: "POST",
        url: TeamDetailPostBackURL,
        //contentType: "application/json; charset=utf-8",
        data: { id: id, codUsuario: codUsuario },
        //datatype: "json",
        success: function (data) {
            HideLoader();
            $('#myModalContent').html(data);
            $('#myModal').modal(options);
            $('#myModal').modal('show');

        },
        error: function (data) {
            HideLoader();
            value = data.responseJSON;
            if (value != null) {
                if (value.Titulo != "" && value.Titulo != null) {
                    PopupError(value.Titulo, value.Mensaje);
                }
            } else {
                alert("Dynamic content load failed.");
            }
        }
    });

    $("#closbtn").click(function () {
        HideModal();
    });
}

function ShowModalPeriodo(e, id_rango) {
    var url = $(e).attr('arial-url');
    var options = { "backdrop": "static", keyboard: true };
    ShowLoader();
    $.ajax({
        type: "POST",
        url: url,
        //contentType: "application/json; charset=utf-8",
        data: {
            idRango: id_rango
        },
        //datatype: "json",
        success: function (data) {
            HideLoader();
            $('#myModalContent').html(data);
            $('#myModal').modal(options);
            $('#myModal').modal('show');
        },
        error: function () {
            HideLoader();
            alert("Dynamic content load failed.");
        }
    });


    $("#closbtn").click(function () {
        HideModal();
    });

}

function HideModal(){
    $('#myModal').modal('hide');
}

function ShowLoader() {

    var options = { "backdrop": "static", keyboard: true };
    $('#ModalLoader').modal(options);
    $('#ModalLoader').modal('show');
}

function HideLoader() {
    $('#ModalLoader').modal('hide');
}


function openTab(evt, tabItem) {
    // Declare all variables
    var i, tabcontent, tablinks;

    // Get all elements with class="tabcontent" and hide them
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
        tabcontent[i].style.display = "none";
    }

    // Get all elements with class="tablinks" and remove the class "active"
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
        tablinks[i].className = tablinks[i].className.replace(" active", "");
    }

    // Show the current tab, and add an "active" class to the button that opened the tab
    document.getElementById(tabItem).style.display = "block";
    evt.currentTarget.className += " active";
} 

function PopupCorrecto(titulo, mensaje) {
    swal(titulo, mensaje, "success");
}

function PopupError(titulo, mensaje) {
    swal(titulo, mensaje, "error");
}

function PopupAdvertencia(titulo, mensaje) {
    swal(titulo, mensaje, "warning");
}
function ObtenerValorFilaTelerik(e)
{
    var grid = e.sender;
    var selectedRow = grid.select();
    var selectedItem = grid.dataItem(selectedRow);

    return selectedItem;
}
function SendGridValue(e) {
    var valores = ObtenerValorFilaTelerik(e);

    var url = $(e.sender.element).attr('url');

    swal({
        title: recursosDelegaciones.TituloConfirmar,
        text: "¿" + recursosDelegaciones.TextoConfirmar+ " " + valores.Nombre + "?",
        type: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        confirmButtonText: recursosDelegaciones.Confirmar,
        cancelButtonText: recursosDelegaciones.Cancelar,

    }).then(function () {
        
        $.form(url, { codUsuario: valores.CodDelegado }, 'POST').submit();
        //$.post(url, { codUsuario: valores.CodDelegado });
    });
}

function CrearDelegado(e) {
    var valores = $("#email").val();
    $('#myModal').modal('hide');
    var url = $(e).attr('url');

    swal({
        title: recursosDelegaciones.TituloConfirmarCrear,
        text: "¿" + recursosDelegaciones.TextoConfirmarCrear + " " + valores + "?",
        type: 'warning',
        showCancelButton: true,
        confirmButtonColor: '#3085d6',
        cancelButtonColor: '#d33',
        confirmButtonText: recursosDelegaciones.Confirmar,
        cancelButtonText: recursosDelegaciones.Cancelar,

    }).then((eliminar) => {
        if (eliminar) {
            ShowLoader();
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    email: valores
                },
            }).done(function (data) {
                HideLoader();
                $('#myModal').modal('show');
                $('#gridDelegar').data('kendoGrid').dataSource.read();
                $('#gridDelegar').data('kendoGrid').dataSource.page(1);
                swal(recursosDelegaciones.TextoGuardado, "", "success");

            }).fail(function () {
                HideLoader();
                $('#myModal').modal('show');
                swal(recursosDelegaciones.TextoErrorGuardar, "", "error");
            });
        } else {
            $('#myModal').modal('show');
        }
    });
}

function EliminarDelegado(e, id)
{
    var TeamDetailPostBackURL = $(e).attr('arial-url')
    $('#myModal').modal('hide');
    $.ajax({
        type: "POST",
        url: TeamDetailPostBackURL,
        data: {
            idDelegado: id
        },
    }).done(function (data) {
        HideLoader();
        $('#myModal').modal('show');
        $('#gridDelegar').data('kendoGrid').dataSource.read();
        $('#gridDelegar').data('kendoGrid').dataSource.page(1);
        swal(recursosDelegaciones.TextoEliminado, "", "success");

    }).fail(function () {
        HideLoader();
        $('#myModal').modal('show');
        swal(recursosDelegaciones.TextoErrorEliminado, "", "error");
    });
}


jQuery(function ($) {
    $.extend({
        form: function (url, data, method) {
            if (method == null) method = 'POST';
            if (data == null) data = {};

            var form = $('<form>').attr({
                method: method,
                action: url
            }).css({
                display: 'none'
            });

            var addData = function (name, data) {
                if ($.isArray(data)) {
                    for (var i = 0; i < data.length; i++) {
                        var value = data[i];
                        addData(name + '[]', value);
                    }
                } else if (typeof data === 'object') {
                    for (var key in data) {
                        if (data.hasOwnProperty(key)) {
                            addData(name + '[' + key + ']', data[key]);
                        }
                    }
                } else if (data != null) {
                    form.append($('<input>').attr({
                        type: 'hidden',
                        name: String(name),
                        value: String(data)
                    }));
                }
            };

            for (var key in data) {
                if (data.hasOwnProperty(key)) {
                    addData(key, data[key]);
                }
            }

            return form.appendTo('body');
        }
    });
});
