equalheight = function(container){

    var anchura_navegador = $(window).width();
    if(anchura_navegador>600)
    {
        var currentTallest = 0,
            currentRowStart = 0,
            rowDivs = new Array(),
            $el,
            topPosition = 0;
        $(container).each(function() {

            $el = $(this);
            $($el).height('auto')
            topPostion = $el.position().top;

            if (currentRowStart != topPostion) {
                for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
                    rowDivs[currentDiv].height(currentTallest);
                }
                rowDivs.length = 0; // empty the array
                currentRowStart = topPostion;
                currentTallest = $el.height();
                rowDivs.push($el);
            } else {
                rowDivs.push($el);
                currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
            }
            for (currentDiv = 0 ; currentDiv < rowDivs.length ; currentDiv++) {
                rowDivs[currentDiv].height(currentTallest);
            }
        });
    }
}


$.fn.firstWord = function() {
    var text = this.text().trim().split(" ");
    var first = text.shift();
    this.html((text.length > 0 ? "<span class='firstWord'>"+ first + "</span> " : first) + text.join(" "));
};

$(window).load(function() {
    equalheight('.igual_altura');
    equalheight('.igual_altura2');
    equalheight('.igual_altura3');
    equalheight('.cuadricula-imagenes .col');
});


$(window).resize(function(){
    equalheight('.igual_altura');
    equalheight('.igual_altura2');
    equalheight('.igual_altura3');
    equalheight('.cuadricula-imagenes .col');
});


$( document ).ready(function()
{


    /*------------------------------------------------------------------------------------------
    VERSIÓN 2 DEL TEMA DE DIPCAS
    --------------------------------------------------------------------------------------------*/

    //---> DESTACADOS HOME
    var mySwiper = new Swiper ('.swiper-destacados-home', {
        // Optional parameters
        direction: 'horizontal',
        loop: false,
        speed: 1200,
        grabCursor: true,
        pagination: {
            el: ".swiper-pagination",
            clickable: true
        }
    });

    //---> VIDEOS HOME
    var mySwiper = new Swiper ('.swiper-videos-home', {
        // Optional parameters
        direction: 'horizontal',
        loop: false,
        speed: 1200,
        grabCursor: true,
        // Navigation arrows
        navigation: {
            nextEl: '.swiper-button-next',
            prevEl: '.swiper-button-prev',
        },

        on: {
            slideChangeTransitionStart: function () {
                // Slide captions
                var swiper = this;
                var slideTitle = $(swiper.slides[swiper.activeIndex]).attr("data-title");
                $(".videos-home .col-txt .titulo").html(slideTitle);
            }
        }
    });



    /*------------------------------------------------------------------------------------------
     FIN VERSIÓN 2 DEL TEMA DE DIPCAS
     --------------------------------------------------------------------------------------------*/

    //--> FULL SLIDESHOW
    if(('.mouse-scroll').length>0)
    {
        setInterval(function(){
            $('.mouse-scroll .flecha').toggleClass('bajo');
        }, 800);

        $('.mouse-scroll').click(function()
        {
            $('html, body').animate(
            {
                scrollTop: $('.layout-content.pagina').offset().top
            }, 1000);
        });

        var new_effect=3;
        var old_effect;

        $('.cycle-slideshow.slide-full div:first-child').addClass('scale');
        $('.cycle-slideshow.slide-full div:first-child').addClass('fx' + new_effect);

        $('.cycle-slideshow.slide-full').on('cycle-before', function(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
            old_effect = new_effect;
            new_effect = 3;
            $(incomingSlideEl).addClass('scale');
            $(incomingSlideEl).addClass('fx' + new_effect);
        });

        $('.cycle-slideshow.slide-full').on('cycle-after', function(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
            $(outgoingSlideEl).removeClass('scale');
            $(outgoingSlideEl).removeClass('fx' + old_effect);
        });


    }

    if($('.contenido-covid .tab-widget').length>0)
    {
        $('.tab-widget__tabs').slimScroll({
            position: 'right',
            height: '500px',
            railVisible: true,
            alwaysVisible: true,
            color: '#c00c37',
            distance: '20px',
            railColor: '#999',
        });


        $('.contenedor-noticias-grid3 .titulo-noticias-grid span').remove();
    }

    $('.editable').removeAttr('title');


    $('body.publico').find("[contenteditable='true']").each(function()
    {
        $(this).removeAttr("contenteditable");
    });

    if($('.destacados-libreta .slick_slide_libreta').length>0)
    {
        $('.slick_slide_libreta').slick({
            infinite: true,
            slidesToShow: 3,
            autoplay:true,
            dots: true,
            autoplaySpeed:5000,
            slidesToScroll: 1,
            arrows: false,
            responsive: [
                {
                    breakpoint: 1020,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 1,
                        autoplay:true,
                        dots: true,
                        autoplaySpeed:6000,
                        infinite: true,
                        arrows: false,
                    }
                },
                {
                    breakpoint: 768,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                        infinite: true,
                        dots: true,
                        arrows: false,
                        prevArrow: '<button type="button" class="slick-prev"></button>',
                        nextArrow: '<button type="button" class="slick-next"></button>',
                    }
                }
            ]
        });
    }


    /*------------------------------------------------------------------
    BUSCADOR DE ÁREAS Y ENTIDADES
     --------------------------------------------------------------------*/
    $('.buscador-areas').on('keyup', function(e) {

        var sSearch = this.value;

        var data = {
            q: sSearch
        };
        var url = BASE_HOST + AUTO_LANGUAGE + '/corporacion/public/buscar_areas';
        $.ajax({
            type: "POST",
            url: url,
            data: data,
            success: function(data)
            {
                $('.listado-areas').html(data);

            }
        });



    });

    /*------------------------------------------------------------------
    MODULO GALERIAS
    --------------------------------------------------------------------*/
    // --> VER LA GALERIA
    $(document).on("click", '.ver-galeria', function(event)
    {
        var id_galeria = $(this).attr('data-idgaleria');
        $('.contenido-fotografias-' + id_galeria).fadeIn(300);

    });
    // --> VOLVER AL LISTADO DE CATEGORÍAS DE LA GALERIA
    $(document).on("click", '.volver-galeria', function(event)
    {
        $(this).parent().fadeOut(300);

    });



    $(document).on('click', 'a.smooth-scroll[href^="#"]', function (e) {
        e.preventDefault();

        $('html, body').animate({
            scrollTop: $($.attr(this, 'href')).offset().top
        }, 500);
    });

    if($('.sldr').length>0)
    {
        $('.sldr').each(function () {
            var th = $(this);
            th.sldr({
                focalClass: 'focalPoint',
                offset: th.width() / 2,
                sldrWidth: 'responsive',
                nextSlide: th.nextAll('.sldr-nav.next:first'),
                previousSlide: th.nextAll('.sldr-nav.prev:first'),
                selectors: th.nextAll('.selectors:first').find('li'),
                toggle: th.nextAll('.captions:first').find('div'),
                sldrAuto: true,
                sldrTime: 5000,
                hasChange: true
            });
        });
    }


    if($('.slick_slide_agenda').length>0)
    {
        $('.slick_slide_agenda').slick({
            infinite: true,
            slidesToShow: 4,
            slidesToScroll: 4,
            arrows: true,
            prevArrow: '<button type="button" class="slick-prev"></button>',
            nextArrow: '<button type="button" class="slick-next"></button>',
            responsive: [
                {
                    breakpoint: 1200,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 2,
                        infinite: true,
                        arrows: true,
                        prevArrow: '<button type="button" class="slick-prev"></button>',
                        nextArrow: '<button type="button" class="slick-next"></button>',
                    }
                },
                {
                    breakpoint: 768,
                    settings: {
                        slidesToShow: 1,
                        slidesToScroll: 1,
                        infinite: true,
                        arrows: true,
                        prevArrow: '<button type="button" class="slick-prev"></button>',
                        nextArrow: '<button type="button" class="slick-next"></button>',
                    }
                }
            ]
        });
    }


    setTimeout(function(){
        
        $('#cont_8db4f50508ea1c48a421ef765a36bf5f').css({'margin': 0,'margin-top':'-12px','background-color':'#D0D0D0'});
        $('iframe #BwG').css({'background-color':'#D0D0D0 !important'});

    }, 1000)


    // VALIDACIÓN DE LOS FORMULARIOS
    $('.form-envio-formulario').each(function()
    {
        var formulario = $(this);
        $(this).validate({
             invalidHandler: function(event, validator) {
                // 'this' refers to the form
                var errors = validator.numberOfInvalids();
                if (errors)
                {
                    $('.preloader-formulario').hide();
                    $('.form-envio-formulario .btn-enviar').show();
                }
            }
        });
    });


    $('.form-envio-formulario .btn-enviar').click(function()
    {
        $('.preloader-formulario').show();
        $(this).hide();
    });




    $('.selector-fecha').datepicker(
        {
            beforeShow: function(input, inst)
            {
                $('#ui-datepicker-div').addClass('datepicker-fecha');
            },
            changeMonth: true,
            changeYear: true,
            yearRange: "-20:+0",
            monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
            monthNamesShort: ['Ene','Feb','Mar','Abr', 'May','Jun','Jul','Ago','Sep', 'Oct','Nov','Dic'],
            dayNames: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
            dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
            dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
            dateFormat: 'dd/mm/yy',
            weekHeader: 'Sm',
            firstDay: 1,
        });


    // Cuenta atrás

    if(('#cuenta-atras').length>0)
    {
        $("#cuenta-atras")
            .countdown("2018/05/12 07:00:00", function(event) {
                $(this).html(
                    event.strftime(''
                        + '<div class="col-cuenta">%-m <span>meses</span></div>'
                        + '<div class="col-cuenta">%-n <span>días</span></div>'
                        + '<div class="col-cuenta">%H <span>horas</span></div>'
                        + '<div class="col-cuenta">%M <span>minutos</span></div>'
                        + '<div class="col-cuenta">%S <span>segundos</span></div>'
                    )
                );
            });
    }


  // Slick slider lateral

    $('.lateral-destacados-resp').slick({
      // dots: false,
      infinite: true,
      //              centerMode: true,
      slidesToShow: 1,
      slidesToScroll: 1,
      //              centerPadding: '220px',
      arrows: true,
      prevArrow: '<button type="button" data-role="none" class="slick-prev slick-arrow" aria-label="Previous" role="button" style="display: block;"><i class="fa fa-chevron-left" aria-hidden="true"></i></button>',
      nextArrow: '<button type="button" data-role="none" class="slick-next slick-arrow" aria-label="Next" role="button" style="display: block;"><i class="fa fa-chevron-right" aria-hidden="true"></i></button>',
      responsive: [
        {
          breakpoint: 768,
          settings: {
            slidesToShow: 2,
            slidesToScroll: 2,
            infinite: true
          }
        },
        {
          breakpoint: 668,
          settings: {
            slidesToShow: 1,
            slidesToScroll: 1,
            infinite: true
          }
        },
      ]
    });

    $.widget.bridge('uitooltip', $.ui.tooltip);

    $('[data-toggle="tooltip"]').tooltip();

    $('.gallery-item').magnificPopup({
        type: 'image',
        gallery:{
            enabled:true
        }
    });

    $('.img-magnific').magnificPopup({
        type: 'image',
        gallery:{
            enabled:false
        }
    });

    $('.popup-player').magnificPopup({
        type: 'iframe',
        mainClass: 'mfp-fade',
        removalDelay: 160,
        preloader: false,
        fixedContentPos: true,
        iframe: {
            markup: '<div class="mfp-iframe-scaler">'+
            '<div class="mfp-close"></div>'+
            '<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+
            '</div>',

            srcAction: 'iframe_src',
        }
    });

    $('.ajax-popup-link').magnificPopup({
        type: 'ajax'
    })



    $('#myCarousel').carousel({
        interval: 0
    })


    $('.menu ul').slicknav({
        label: '',
        prependTo:'.cabecera-inferior'
    });


    /*------------------------------------------------------------------------------------------
     MENU RESPONSIVE
     --------------------------------------------------------------------------------------------*/
    $('label.icon').click(function(){

        $('.menu-responsive').toggleClass('abierto');
        $('body').toggleClass('abierto');

    });

    /*------------------------------------------------------------------------------------------
     CABECERA FIJA EN RESPONSIVE
     --------------------------------------------------------------------------------------------*/
    $(window).scroll(function()
    {
        var sticky = $('.cabecera'),
            scroll = $(window).scrollTop();

        if (scroll >= 130) sticky.addClass('fixed');
        else sticky.removeClass('fixed');
    });
    /*------------------------------------------------------------------------------------------
     ALERTAS
     --------------------------------------------------------------------------------------------*/
    if($('.alerta-popup').length>0)
    {
        setTimeout(function()
        {
            $('.alerta-popup').addClass('abierto');
        }, 1500);
    }
    $('.cerrar-alerta').click(function()
    {
        var id_alerta = $(this).attr('data-id');
        $.cookie("alerta_" + id_alerta, 1, { expires : 3, path    : '/'});
        $('.alerta-popup').slideUp(200);
    });


    $('.tab-widget__link').click(function()
    {

        //--> CAMB

        equalheight('.igual_altura');
        equalheight('.igual_altura2');
        equalheight('.igual_altura3');
        equalheight('.cuadricula-imagenes .col');

        setTimeout(function(){

            equalheight('.igual_altura');
            equalheight('.igual_altura2');
            equalheight('.igual_altura3');
            equalheight('.cuadricula-imagenes .col');

        }, 1000);

        setTimeout(function(){

            equalheight('.igual_altura');
            equalheight('.igual_altura2');
            equalheight('.igual_altura3');
            equalheight('.cuadricula-imagenes .col');

        }, 3000);

    });




    $('.btn-buscar-movil-eventos').click(function()
    {
        if($(this).hasClass('activo'))
        {
            $('.fila-buscador').css({'bottom': '-435px'});
            $(this).removeClass('activo');
        }
        else
        {
            $('.fila-buscador').css({'bottom': '0'});
            $(this).addClass('activo');
        }

    });

    $('.btn-buscar-movil-eventos-mapa').click(function()
    {
        if($(this).hasClass('activo'))
        {
            $('.fila-buscador').css({'bottom': '-420px'});
            $(this).removeClass('activo');
        }
        else
        {
            $('.fila-buscador').css({'bottom': '0'});
            $(this).addClass('activo');
        }

    });

    $('.btn-buscar-movil-posts').click(function()
    {
        if($(this).hasClass('activo'))
        {
            $('.fila-buscador').css({'bottom': '-300px'});
            $(this).removeClass('activo');
        }
        else
        {
            $('.fila-buscador').css({'bottom': '0'});
            $(this).addClass('activo');
        }
    });

    $('.btn-buscar-movil-competiciones,.btn-buscar-movil-embajadores').click(function()
    {
        if($(this).hasClass('activo'))
        {
            $('.fila-buscador').css({'bottom': '-170px'});
            $(this).removeClass('activo');
        }
        else
        {
            $('.fila-buscador').css({'bottom': '0'});
            $(this).addClass('activo');
        }
    });

    // RESPONSIVE SLIDES
    var an_pantalla = $(window).width();
    if($('.cycle-slideshow').length>0 && an_pantalla<600 )
    {
        $('.item-home').each(function()
        {
            var img_responsive = $(this).attr('data-img-responsive');
            $(this).css("background-image", "url("+img_responsive+")");
        });
    }

    $("[contenteditable='true']").each(function() {
        $(this).removeAttr("contenteditable");
    });


    $('.titulo-acordeon').click(function()
    {
        $(this).parent().find('.cuerpo-acordeon').slideToggle();
        $(this).toggleClass('abierto');
        setTimeout(function(){ equalheight('.igual_altura'); }, 400);
        setTimeout(function(){ equalheight('.igual_altura'); }, 1100);
    });

    $('.boton-busqueda,.btn-buscador').click(function()
    {
        if($(this).hasClass('abierto'))
        {
            $('.contenedor-busqueda').fadeOut(400);
            $('body').css({'overflow' : 'visible'});
        }
        else
        {
            $('.contenedor-busqueda').fadeIn(500);
            $('body').css({'overflow' : 'hidden'});
        }
    });

    $('.contenedor-busqueda .cerrar').click(function()
    {
        $('.contenedor-busqueda').fadeOut(400);
        $('body').css({'overflow' : 'visible'});
    });

    $('ul.tab-widget__list li').click(function(){
        equalheight('.igual_altura');
        setTimeout(function(){ equalheight('.igual_altura'); }, 800);

    });

    $('.tabla-ordenable').dataTable({
        "language": {
            "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"
        },
        paging: false,
        responsive: true,
        "aaSorting": []
    });

    $('.tabla-ordenable-formacion').dataTable({
        "language": {
            "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json"
        },
        paging: true,
        pageLength: 20,
        responsive: true,
        "aaSorting": []
    });





    $(".calendario-competiciones .titulo-mas").firstWord();
    $(".listado-noticias .titulo-mas").firstWord();
    $("h2.subtitulo").firstWord();

/* GALERIA WORKS */

    $('.works_detalle .slick_proyectos').slick({
      centerMode: true,
      centerPadding: '60px',
      dots: false,
      infinite: true,
      speed: 300,
      slidesToShow: 4,
      slidesToScroll: 1,
      focusOnSelect: true,
      responsive: [
        {
          breakpoint: 1024,
          settings: {
            slidesToShow: 1,
            slidesToScroll: 1,
            infinite: true,
            dots: false
          }
        },
        {
          breakpoint: 600,
          settings: {
            slidesToShow: 2,
            slidesToScroll: 1,
            dots: false
          }
        },
        {
          breakpoint: 480,
          settings: {
            centerMode: false,
            slidesToShow: 1,
            slidesToScroll: 1,
            dots: false
          }
        }
        // You can unslick at a given breakpoint now by adding:
        // settings: "unslick"
        // instead of a settings object
      ]
    });

    /* Ajax GALERIA WORKS */
    $('.slick_proyectos').on('click','.proy_rest', function (){
      var id_prod = $(this).attr("data-id");
      var data = {
          id_prod: id_prod
      };
      var url = BASE_HOST+AUTO_LANGUAGE + '/works/public/cargar_works_ajax';
      $.ajax({
          type: "POST",
          url: url,
          data: data,
          success: function(data)
          {
            $('.works_detalle .ficha_producto').empty();
            if(!$(".works_detalle .ficha_producto").hasClass("triggered")){
              $('.works_detalle .ficha_producto').html(data);
              $('.works_detalle .ficha_producto').slideDown(800);
              $('.works_detalle .ficha_producto').addClass("triggered");

              $('.works_detalle .cycle-slideshow').cycle({
                  speed: 600,
                  manualSpeed: 100
              });

            }else{
              $('.works_detalle .ficha_producto').hide().html(data).fadeIn("slow");

              $('.works_detalle .cycle-slideshow').cycle({
                  speed: 600,
                  manualSpeed: 100
              });
            }
              $('.works_detalle .small').hide();
            // Igualamos altura
            setTimeout(function()
            {
                $('.layout-right-col').css({'height': 'auto'});
                equalheight('.igual_altura');
                $('html, body').animate({
                    scrollTop: $('.ancla_proyectos').offset().top
                }, 400);
            }, 900);

          }
      });


    });


    setTimeout(function(){

        equalheight('.igual_altura');
        equalheight('.igual_altura2');
        equalheight('.igual_altura3');
        equalheight('.cuadricula-imagenes .col');

    }, 1500)

});


(function (document, window, $, undefined) {
    'use strict';

    var $tabWidget = $('.js-tab-widget');

    var setupTabs = function($tab, $allTabs, $tabPanels, $tabListItems, i) {
        $tab
            .attr({
                'id': 'tab-link-' + i,
                'tabindex': '-1',
                'role': 'tab',
                'aria-selected': 'false',
                'aria-controls': 'tab-panel-' + i
            });

        if (i === 0)
        {
            $tab
                .attr({
                    'tabindex': '0',
                    'aria-selected': 'true',
                    'aria-describedby': 'tab-widget-description'
                })
                .addClass('tab-widget__link--active');

            $tab.parent().toggleClass('tab_li_activo');
        }

        $tab.on('click', function(e)
        {
            var url = $(this).attr('href');
            if(url.indexOf('http') !== -1)
            {

            }
            else
            {
                e.preventDefault();
                tabClick($(this),  $allTabs, $tabPanels, i);
            }
        });

        $tab.on('focus', function(e)
        {
            var url = $(this).attr('href');
            if(url.indexOf('http') !== -1)
            {

            }
            else
            {
                tabClick($(this),  $allTabs, $tabPanels, i);
            }
        });

        $tab.on('keydown', function (e)
        {
            var url = $(this).attr('href');
            if(url.indexOf('http') !== -1)
            {

            }
            else
            {
                tabKeydown($(this), $allTabs, $tabPanels, $tabListItems, i, e);
            }
        });
    };

    var setupTabPanels = function(tabPanel, i) {
        tabPanel
            .attr({
                'id': 'tab-panel-' + i,
                'role': 'tabpanel',
                'aria-hidden': 'true',
                'aria-labelledby': 'tab-link-' + i
            });

        if (i === 0) {
            tabPanel
                .attr('aria-hidden', 'false')
                .addClass('tab-widget__tab-content--active');
        }
    };

    var tabClick = function($thisTab, $allTabs, $tabPanels, i) {
        $allTabs
            .attr({
                'tabindex': -1,
                'aria-selected': 'false'
            })
            .removeAttr('aria-describedby')
            .removeClass('tab-widget__link--active');

        $thisTab
            .attr({
                'tabindex': 0,
                'aria-selected': 'true',
                'aria-describedby': 'tab-widget-description'
            })
            .addClass('tab-widget__link--active');

        $thisTab.parent().parent().find('.tab_li_activo').removeClass('tab_li_activo');
        $thisTab.parent().addClass('tab_li_activo');

        $tabPanels
            .attr('aria-hidden', 'true')
            .removeClass('tab-widget__tab-content--active');

        $tabPanels.eq(i)
            .attr('aria-hidden', 'false')
            .addClass('tab-widget__tab-content--active');
    };

    var tabKeydown = function($thisTab, $allTabs, $tabPanels, $tabListItems, i, e) {
        var keyCode = e.which,
            $nextTab = $thisTab.parent().next().is('li') ? $thisTab.parent().next().find('a') : false,
            $previousTab = $thisTab.parent().prev().is('li') ? $thisTab.parent().prev().find('a') : false,
            $firstTab = $thisTab.parent().parent().find('li:first').find('a'),
            $lastTab = $thisTab.parent().parent().find('li:last').find('a');

        switch(keyCode) {
            // Left/Up
            case 37:
            case 38:
                e.preventDefault();
                e.stopPropagation();

                if (!$previousTab) {
                    $lastTab.focus();
                } else {
                    $previousTab.focus();
                }

                break;

            // Right/Down
            case 39:
            case 40:
                e.preventDefault();
                e.stopPropagation();

                if (!$nextTab) {
                    $firstTab.focus();
                } else {
                    $nextTab.focus();
                }

                break;

            // Home
            case 36:
                e.preventDefault();
                e.stopPropagation();

                $firstTab.focus();

                break;

            // End
            case 35:
                e.preventDefault();
                e.stopPropagation();

                $lastTab.focus();

                break;

            // Enter/Space
            case 13:
            case 32:
                e.preventDefault();
                e.stopPropagation();

                break;
        }
    };

    $tabWidget.each(function () {
        var $this = $(this),
            $tabList = $this.find('> ul'),
            $tabListItems = $tabList.find('li'),
            $allTabs = $tabListItems.find('a'),
            $tabPanels = $this.find('> div > div');

        $tabList.attr('role', 'tablist');
        $tabListItems.attr('role', 'presentation');

        $allTabs.each(function (i) {
            setupTabs($(this), $allTabs, $tabPanels, $tabListItems, i);
        });

        $tabPanels.each(function (i) {
            setupTabPanels($(this), i);
        });
    });

    $('html').addClass('js').removeClass('no-js');

})(document, window, jQuery);
