
////site-uploads/1001528/frontjs/main.js
/* Menu */
$(document).ready(function () {
  $(".navbar-toggle").on("click", function () {
      $(this).toggleClass("active");
  });
});

/* Active State Menu */
$(document).ready(function () {
  var url = window.location.pathname;
  $('ul.nav a[href="'+ url +'"]').parent().addClass('active');
  $('ul.nav a').filter(function() {
       return this.href == url;
  }).parent().addClass('active');
});

/* Sticky Menu on Scroll */
$(function () {
  $(window).on("scroll", function () {
      if ($(window).scrollTop() > 48) {
          $("#comp_1708126004027").addClass("sticky-nav");
      } else {
          $("#comp_1708126004027").removeClass("sticky-nav");
      }
  });
});

/* Change Slider transition from slide to fade */
$(function () {
  $(".carousel").removeClass("slide");
  $(".carousel").addClass("carousel-fade");
});

/* Remove link on carousel images */
$(".carousel .carousel-inner a.item").removeAttr("href");

/* Slide to top */
$(document).ready(function () {
  $("a[href='#top']").on('click', function (e) {
    e.preventDefault();
    $("html, body").animate({
      scrollTop: 0
    }, "slow");
    return false;
  });
});

/* Display Slide to top on scroll */
$(function () {
  $(window).on("scroll", function () {
      if ($(window).scrollTop() > 48) {
          $("#to-up-container").addClass("show");
      } else {
          $("#to-up-container").removeClass("show");
      }
  });
});

/* Change Get Financed to open page */
var theLanguage = $('html').attr('lang');
// Diferent language
if (theLanguage == "fr") {
  $(".finacning-link").attr(
    "href",
    "/fr/Finance-Request"
  );
  
  $(".finacning-link").attr("target", "_self");
  $(".finacning-link").text('Obtenir une pré-approbation');

} else {
  $(".finacning-link").attr(
    "href",
    "/Finance-Request"
  );
  
  $(".finacning-link").attr("target", "_self");
  $(".finacning-link").text('Get Pre-Approved');
  $(".trade-btn").text('Value Your Trade');
}


/* Mobile filters fix */
$(document).ready(function() {
  $(".filter-xs-btn").click(function(){
    $("#filters").addClass("open");
});
});

/* Hide html above component on vdp */
if($("#detailsParentDiv").size()>0){
  $('#page-banner').css("display","none");
  $('.inventory-page').css("display","none");
  };

  /* Move VDP Header from CenterDiv to HeaderDiv */
  if($("#detailsParentDiv").size()>0){
    $('#HeaderDiv').append( $('.vdp-header'));
    $(".vdp-header").removeClass("hidden-xs");
    };

/* Blog Srp, move FooterDiv from CenterDiv???? to parent */
if($(".blog-srp").size()>0){
  $('#parent').append( $('#FooterDiv') );
  };

/* Move ads-per-page to the bottom of the srp, next to the pagination */
$(document).ready(function() {
if($(".seamaster-srp").size()>0){
  $('.seamaster-srp').append( $('.ads-per-page'));
  };
});

/* 404 page */
$(function () {
  if ($("img[alt='Error:404 Page Not Found']").length) {
    console.log('404');
    var content = `<div class="_404-container">
                    <div id="page-banner">
                      <div class="banner-image"><img alt="Page not found" src="/site-uploads/1001528/Images/banner-inventory.jpg" loading="lazy"><h1>404 PAGE NOT FOUND</h1></div>
                      </div>
                        <div>
                            <p align="center">CHECKOUT OUR INVENTORY OR <a href="/Contact-Us/">CONTACT US</a></p>

                            <div class="btn-link">
                                <a href="/New-Inventory/">New Inventory</a>
                                <a href="/Pre-Owned/">Pre-Owned</a>
                                <a href="/Brochures/">Brochures</a>
                            </div>
                        </div>
                    </div>`;

    $('#CenterDiv').html(content);
  }
});
////site-uploads/1001630/frontjs/Search_script.js
if($('#searchbox2').length){
    setTimeout(function() {
        document.getElementById("searchbox2")?.addEventListener("keyup", function(event) {
            event.preventDefault();
            if (event.keyCode === 13) {
                document.getElementById("searchbtn2")?.click();
            }
        });
    }, 2000);
    }
    
    var theLanguage = $("html").attr("lang");
    // Diferent language
    if (theLanguage == "fr") {
        function srch() {
            //var e = document.getElementById("pagedd");
            //var dest= e.options[e.selectedIndex].value;
            var valuee = document.getElementById('searchbox2').value;
            if (valuee != "") {
                window.location = "/fr/Inventaire/search/".concat(valuee);
            } else {
                document.getElementById('searchbox2').placeholder = "This field is required";
                var sheet = window.document.styleSheets[0];
                sheet.insertRule('input#searchbox2::-webkit-input-placeholder {color: red !important}', sheet.cssRules.length);
                sheet.insertRule('input#searchbox2::-moz-placeholder {color:#909; opacity:1;}', sheet.cssRules.length);
                sheet.insertRule('input#searchbox2:-moz-placeholder {color:#909; opacity:1;}', sheet.cssRules.length);
            }
        }
    } else {
        function srch() {
            //var e = document.getElementById("pagedd");
            //var dest= e.options[e.selectedIndex].value;
            var valuee = document.getElementById('searchbox2').value;
            if (valuee != "") {
                window.location = "/Inventory/search/".concat(valuee);
            } else {
                document.getElementById('searchbox2').placeholder = "This field is required";
                var sheet = window.document.styleSheets[0];
                sheet.insertRule('input#searchbox2::-webkit-input-placeholder {color: red !important}', sheet.cssRules.length);
                sheet.insertRule('input#searchbox2::-moz-placeholder {color:#909; opacity:1;}', sheet.cssRules.length);
                sheet.insertRule('input#searchbox2:-moz-placeholder {color:#909; opacity:1;}', sheet.cssRules.length);
            }
        }
    }
    
    
    
    $(function () {
        /* Focus on input afrer modal open */
        $('#searchModal').on('shown.bs.modal', function () {
            $('#searchbox2').focus();
        }); 
    });
////site-uploads/1001630/frontjs/sticky.js

$(function () {
    $(window).on("scroll", function () {
        if ($(window).scrollTop() > $("#header-top").eq(0).height()) {
            $("#comp_1734892138655,#side-nav").addClass("sticky-nav");
            var centerDivMargin = $('#comp_1734892138655').height();
            $('#CenterDiv').css({ "margin-top": centerDivMargin });
        } else {
            $("#comp_1734892138655").removeClass("sticky-nav");
            $('#CenterDiv').css({ "margin-top": 0 });
        }
    });
});
////site-uploads/1001630/frontjs/Stop Video Modal_v1.3.js
$(document).ready(function () {
    $('.modal').each(function () {
        var src = $(this).find('video').attr('src'); // Store the original video src

        // When the modal is closed
        $(this).on('click', '.close', function () {
            var modal = $(this).closest('.modal');
            modal.find('video').attr('src', ''); // Clear the src to stop the video
        });

        // When the modal is opened
        $(this).on('show', function () {
            $(this).find('video').attr('src', src); // Restore the original src
        });
    });
});


/* For stop video Iframe 
$(document).ready(function(){
    $('.modal').each(function(){
            var src = $(this).find('iframe').attr('src');

        $(this).on('click', function(){

            $(this).find('iframe').attr('src', '');
            $(this).find('iframe').attr('src', src);

        });
    });
});*/

/* For stop video Tag 
$(document).ready(function(){
    $('.modal').each(function(){
            var src = $(this).find('video').attr('src');

        $(this).on('click', function(){

            $(this).find('video').attr('src', '');
            $(this).find('video').attr('src', src);

        });
    });
});

*/