<% if VideoGalleryItems %>
<section class="container-fluid content-and-video py-5 <% if BlockThemeMode == 'Dark' %>bg-dark text-white<% end_if %> <% if CustomClass %>$CustomClass<% end_if %>">
    <div class="container py-3">
      <div class="row">
        <div class="col-md-8 order-2 order-md-1 mb-5">
            <% with VideoGalleryItems.First %>
            <div id="VideoGalleryContainer{$Top.ID}" class="simple-video-container ratio ratio-16x9 <% if BlockThemeMode == 'Dark' %>bg-dark text-white<% end_if %>">
                <video controls="true" src="$VideoURL" poster="$PosterImageFile.URL" type="video/mp4"></video>
            </div>
            <% end_with %>
        </div>
        <div class="col-md-3 offset-md-1 order-1 order-md-2">
          <% if $ShowTitle %>
            <h2 class="scroll-toggle line-anim mt-5">$Title</h2>
            <% if SubTitle %><p class="h2 title">$SubTitle</p><% end_if %>
          <% end_if %>
          $HTMLContent
        </div>
        <div class="col-md-12 order-3">
          <div class="position-relative">
            <div class="swiper video-carousel">
              <!-- Additional required wrapper -->
              <div class="swiper-wrapper">
                  <% include swipeIcon %>
                  <!-- Slides -->
                  <% loop VideoGalleryItems %>
                  <div class="swiper-slide text-white">
                    <a class="btn btn-link video-link text-white text-shadow" href="#VideoGalleryContainer{$Top.ID}" data-videourl="$VideoURL" data-poster="$PosterImageFile.URL"><img src="$PosterImageFile.URL" class="d-block w-100" alt="..."></a>
                      <div class="slide-content w-100">
                        <div class="slide-caption w-100">
                          <a class="btn btn-link video-link text-white text-shadow" href="#VideoGalleryContainer{$Top.ID}" data-videourl="$VideoURL" data-poster="$PosterImageFile.URL"><i class="las la-play x-large"></i></a>
                        </div>
                      </div>
                  </div>
                  <% end_loop %>
              </div>
              <!-- If we need pagination -->
              <div class="swiper-pagination"></div>
              
              <!-- If we need navigation buttons -->
            </div>
            <div class="swiper-button-prev-outside videoGallery-swiper-button-prev-outside"></div>
            <div class="swiper-button-next-outside videoGallery-swiper-button-next-outside"></div>
          </div>
      </div>
    </div>
  </section>
  <% end_if %>

  <script>
    $(".video-link").click(function()
    {
      var videoURL = $(this).data("videourl");
      var poster = $(this).data("poster");

      $("#VideoGalleryContainer{$Top.ID} video").replaceWith(
        '<video controls="true" src="'+videoURL+'" poster="'+poster+'" type="video/mp4"></video>'
      );
      $("#VideoGalleryContainer{$Top.ID} video").get(0).play();
    });
  </script>