(function ($) {
  Drupal.behaviors.basepack_banner = {
    attach: function (context, settings) {

      //VIDEO LIST PAGE 
      $(once('el', '.basepack-banner--switch')).click(function() {                                                                                                                                            
        $(this).addClass('hidden');
        $(this).next('.basepack-banner--item--video').removeClass('hidden');

        $('.view-videos-lists iframe').each(function(index) {
          var videoYte = $(this);
          var srca = videoYte.attr('src');

          if (srca.indexOf("autoplay=1") >= 0) {
            srca = srca.replace('autoplay=1', 'autoplay=0')
            $(this).attr('src', srca);
          } else {
            $(this).attr('src', $(this).attr('src'));
          }   
        }); 

        var videoYt = $(this).next('.basepack-banner--item--video').find("iframe");
        var src = videoYt.attr('src');
        src = src.replace('autoplay=0', 'autoplay=1')
        $(this).next('.basepack-banner--item--video').find("iframe")[0].src = src;

      }); 


    }
  };

})(jQuery);
