/* Minification failed. Returning unminified contents.
(1,10): run-time error CSS1031: Expected selector, found 'controllerGenericAction('
(1,10): run-time error CSS1025: Expected comma or open brace, found 'controllerGenericAction('
(38,10): run-time error CSS1031: Expected selector, found 'IsIEBrowser('
(38,10): run-time error CSS1025: Expected comma or open brace, found 'IsIEBrowser('
(66,1): run-time error CSS1019: Unexpected token, found '$'
(66,17): run-time error CSS1031: Expected selector, found '='
(66,17): run-time error CSS1025: Expected comma or open brace, found '='
(165,10): run-time error CSS1031: Expected selector, found 'GenerateTimeLine('
(165,10): run-time error CSS1025: Expected comma or open brace, found 'GenerateTimeLine('
(219,10): run-time error CSS1031: Expected selector, found 'hideSidenavPanel('
(219,10): run-time error CSS1025: Expected comma or open brace, found 'hideSidenavPanel('
(226,10): run-time error CSS1031: Expected selector, found 'BloquearComboBoxSelect2('
(226,10): run-time error CSS1025: Expected comma or open brace, found 'BloquearComboBoxSelect2('
(234,10): run-time error CSS1031: Expected selector, found 'DesbloquearComboBoxSelect2('
(234,10): run-time error CSS1025: Expected comma or open brace, found 'DesbloquearComboBoxSelect2('
(241,10): run-time error CSS1031: Expected selector, found 'SetDataComboBox('
(241,10): run-time error CSS1025: Expected comma or open brace, found 'SetDataComboBox('
(264,10): run-time error CSS1031: Expected selector, found 'MsgAlert('
(264,10): run-time error CSS1025: Expected comma or open brace, found 'MsgAlert('
(290,10): run-time error CSS1031: Expected selector, found 'stringLeft('
(290,10): run-time error CSS1025: Expected comma or open brace, found 'stringLeft('
(299,10): run-time error CSS1031: Expected selector, found 'stringRight('
(299,10): run-time error CSS1025: Expected comma or open brace, found 'stringRight('
(310,10): run-time error CSS1031: Expected selector, found 'getIndexThumb('
(310,10): run-time error CSS1025: Expected comma or open brace, found 'getIndexThumb('
(322,20): run-time error CSS1031: Expected selector, found '='
(322,20): run-time error CSS1025: Expected comma or open brace, found '='
 */
function controllerGenericAction(type, url, data, dataType, controlContent, showLoading, hideLoading, functionOnSucess) {

    $.ajax({
        beforeSend: function () {
            if (showLoading == true)
                $("#ajaxLoadingPanel").show();
        },
        complete: function () {
            if (hideLoading == true)
                setTimeout(function () {
                    $("#ajaxLoadingPanel").hide();
                }, 200);
        },
        type: type,
        contentType: "application/json; charset=utf-8",
        url: url,
        data: data,
        dataType: dataType,
        success: function (response, textStatus, jqXHR) {
            if (controlContent != "")
                $("#" + controlContent).html(response);

            if (controlContent == "workspace")
                updateScrollBarWorkSpace();

            if (typeof functionOnSucess == 'function')
                functionOnSucess(response);
        },
        error: function (xhr, status, error) {
            if (error.toString() == "")
                error = xhr.statusText;
            console.error(error);
        }
    });
};


function IsIEBrowser() {
    var ua = window.navigator.userAgent;

    var msie = ua.indexOf('MSIE ');
    if (msie > 0) {
        // IE 10 or older => return version number
        return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
    }

    var trident = ua.indexOf('Trident/');
    if (trident > 0) {
        // IE 11 => return version number
        var rv = ua.indexOf('rv:');
        return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
    }

    var edge = ua.indexOf('Edge/');
    if (edge > 0) {
        // Edge (IE 12+) => return version number
        return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
    }

    // other browser
    return false;
};



$.fn.mrTimeLine = function (options) {
    var control = this;
    var defaults = {
        data: [],
        animation: 'pulse',
        isAdd: false,
        onClickItem: null,
        onDownload: null
    };


    this.options = $.extend({}, defaults, options);
    var htmlData = '';
    control.empty();
    var headHtml = '<div class="frst-timeline-block frst-odd-item" data-animation="' + this.options.animation + '"><div class="frst-timeline-img">';
    var headHtmlPar = '<div class="frst-timeline-block frst-even-item" data-animation="' + this.options.animation + '"><div class="frst-timeline-img">';
    var headHtml02 = '</div><div class="frst-timeline-content"><div class="frst-timeline-content-inner">';

    var footerHTML = '</div></div></div>';
    var i = 1;
    var animation = this.options.animation;
    var onDownload = this.options.onDownload;

    this.options.data.forEach(function (item) {
        htmlData = '';
        switch (item.type) {
            case 0:
                htmlData = htmlData.concat('<div class="frst-timeline-block frst-timeline-label-block" data-animation="' + animation + '">',
                    '<div class="frst-labels frst-start-label"><span>', item.titulo, '</span></div></div>')
                break;
            case 1:
                htmlData = htmlData.concat(i % 2 ? headHtmlPar : headHtml, '<span class="ev-state-', item.idCondicion, '">', item.condiLetra,'</span>', headHtml02,
                     onDownload == null ? '' : '<div class="btnDownloadTL" id="' + item.idFoto + '">DESCARGAR</div>',
                    '<div class="media-section">',
                    '<img src="', item.url, '" alt="Frst Responsive Timeline">', 
                    '</div>',
                    '<h2>', item.titulo, '</h2>',
                    '<span class="frst-date">', item.fecha, '</span>',
                    '<p>', item.contenido, '</p>',
                    footerHTML);
                break;
            case 2:
                htmlData = htmlData.concat(i % 2 ? headHtmlPar : headHtml, '<span class="ev-state-', item.idCondicion, '">', item.condiLetra,'</span>', headHtml02,
                    '<div class="media-section">',
                    '<iframe width="560" height="315" src="', item.url, '" frameborder="0" allowfullscreen></iframe>',
                    '</div>',
                    '<h2>', item.titulo, '</h2>',
                    '<span class="frst-date">', item.fecha, '</span>',
                    '<p>', item.contenido, '</p>',
                    footerHTML);
                break;
            case 3:
                htmlData = htmlData.concat(i % 2 ? headHtmlPar : headHtml, '<span class="ev-state-', item.idCondicion, '">', item.condiLetra,'</span>', headHtml02,
                    '<span class="frst-date">', item.fecha, '</span>',
                    '<p style="color:#000;">', item.contenido, '</p>');
                if (typeof item.fotos != "undefined") {
                    item.fotos.forEach(function (foto) {
                        
                        htmlData = htmlData.concat(onDownload == null ? '' : '<div class="btnDownloadTL" id="' + foto.idFoto + '">DESCARGAR</div>','<div class="media-section">',
                            '<img src="', foto.url, '" alt="Frst Responsive Timeline">', 
                            '<p style="color:#000;text-aling:ceter;">', foto.contenido, '</p>', '</div>');
                    });
                }
                htmlData = htmlData.concat(footerHTML);
                break;
            case 4:
                htmlData = htmlData.concat(i % 2 ? headHtmlPar : headHtml, '<span class="ev-state-', item.idCondicion, '">', item.condiLetra, '</span>', headHtml02,
                    '<span class="frst-date">', item.fecha, '</span>',
                    '<p style="color:#000;">', item.contenido, '</p>');
                if (typeof item.fotos != "undefined") {
                    item.fotos.forEach(function (foto) {
                        
                        htmlData = htmlData.concat(onDownload == null ? '' : '<div class="btnDownloadTL" id="' + foto.idFoto + '">DESCARGAR</div>', '<div class="media-section">',
                            '<img src="', foto.url, '" alt="Frst Responsive Timeline">',
                            '<p style="color:#000;text-aling:ceter;">', foto.contenido, '</p>', '</div>');
                    });
                }
                htmlData = htmlData.concat(footerHTML);
                break;
        }
        i++;
        control.append(htmlData);

    });
    control.find('.btnDownloadTL').one('click', onclickTL);

    if (this.options.data.length === 0) {
        control.append('<div> No se encontraron datos.</div>');
    }


    function onclickTL() {
        onDownload(this.getAttribute('id'));
    }


    return this;
};

function GenerateTimeLine(content) {
    var t = $;

    $(content).find(".frst-timeline-content").css("position", "relative");
    var defaultAnimation = $(content).find(".frst-container").attr("data-animation-name");
    function n(n, i) {
        n.each(function () {
            var n = t(this).data("animation") || defaultAnimation;
            $(this).find(".frst-timeline-content").addClass("is-hidden").removeClass("animated " + n)
        })
    }

    function i(n, i) {

        n.each(function () {

            var elemTop = $(this).offset().top;
            var docViewBottom = $(content).height();
            if ((elemTop > 0) && (elemTop < docViewBottom)) {
                var n = t(this).data("animation") || defaultAnimation;
                t(this).find(".frst-timeline-content").removeClass("is-hidden").addClass("animated " + n)
            }
        })
    }

    function e(n, i) {
        var e = 0;
        n.each(function () {

            var elem = t(this);
            var elemTop = $(this).offset().top;
            var docViewBottom = $(content).height() - $(this).height();
            if ((elemTop >= 0) && (elemTop < docViewBottom)) {
                setTimeout(function () {

                    var n = elem.data("animation") || defaultAnimation;
                    elem.find(".frst-timeline-content").removeClass("is-hidden").addClass("animated " + n);
                }, e)
                e += 200;
            }
        })
    }
    var a = t(content).find(".frst-timeline-block"),
        s = .8;

    n(a, s), i(a, s), t(content).on("scroll", function () {
        content.requestAnimationFrame ? content.requestAnimationFrame(function () {
            i(a, s)
        }) : setTimeout(function () {
            i(a, s)
        }, 100)
    }), t(".frst-date").length && t(".check-style").show()
};

function hideSidenavPanel() {
    $('[data-sidenav]').removeClass('show');
    $('body').removeClass('sidenav-no-scroll');
    $('[data-sidenav-overlay]').fadeOut('fast');
};


function BloquearComboBoxSelect2(id) {

    $($('#' + id).select2("container")).addClass("loadComboBox");
    $('#' + id).prop("disabled", true);
    //$('#' + id).addClass("loadComboBox");
    //document.getElementById(id).disabled = true;
};

function DesbloquearComboBoxSelect2(id) {
    $($('#' + id).select2("container")).removeClass("loadComboBox");
    $("#" + id).prop("disabled", false);
    //$('#' + id).removeClass("loadComboBox");
    //document.getElementById(id).disabled = false;
};

function SetDataComboBox(idcontrol, vardata, varvalue, vartext, firstelemnt) {

    if (typeof vardata === 'undefined' || vardata == null) {
        $("#" + idcontrol).empty();
        return;
    }

    var select = $('#' + idcontrol);

    $('option', select).remove();

    if (firstelemnt != null) {
        var option = new Option(firstelemnt, '');
        select.append($(option));
    }

    $.each(vardata, function (i, item) {
        option = new Option(item[vartext], item[varvalue]);
        select.append($(option));
    });
};

/* ALERT TYPE  success = 1, warning = 2,error = 3*/
function MsgAlert(type, message) {
    var objectAlert;
    switch (type) {
        case 1:
            objectAlert = '<div class="notice verde"><div class="notice-body-verde">'
                + '<i class="el-ok-circled"></i>'
                + '<div class="noticeText">' + message + '<div>'
                + '</div></div>';
            break;
        case 2:
            objectAlert = '<div class="notice naranja"><div class="notice-body-naranja">'
                + '<i class="fa fa-warning"></i>'
                + '<div class="noticeText">' + message + '<div>'
                + '</div></div>';
            break;
        case 3:
            objectAlert = '<div class="notice rojo"><div class="notice-body-rojo">'
                + '<i class="el-cancel-circled"></i>'
                + '<div class="noticeText">' + message + '<div>'
                + '</div></div>';

            break;
    }
    $(objectAlert).purr({ usingTransparentPNG: true });
};

function stringLeft(str, n) {
    if (n <= 0)
        return "";
    else if (n > String(str).length)
        return str;
    else
        return String(str).substring(0, n);
};

function stringRight(str, n) {
    if (n <= 0)
        return "";
    else if (n > String(str).length)
        return str;
    else {
        var iLen = String(str).length;
        return String(str).substring(iLen, iLen - n);
    }
};

function getIndexThumb(timeStops, date) {
    var index;

    timeStops.forEach(function (item,idx) {
        if (item.getTime() === date.getTime())
            index = idx;
    });


    return index;
}

window.mobileCheck = function () {
    let check = false;
    (function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
    return check;
};
