
////site-uploads/1001437/frontjs/speed.js
$(function () {
  /*Delete slider component in mobile*/
  if ($(window).width() < 700) {
    $('#comp_1686834959063').remove();
    $('.slide').remove();
    $('.hidden-xs').remove();
    $('.desktop-only').remove();
  }

  /* load weatehr widget  */
  const userInteractionEvents = [
    'mouseover',
    'keydown',
    'touchmove',
    'touchstart',
  ];
  userInteractionEvents.forEach(function (event) {
    window.addEventListener(event, triggerScriptLoader, {
      passive: true,
    });
  });

  function triggerScriptLoader() {
    loadScripts();
    userInteractionEvents.forEach(function (event) {
      window.removeEventListener(event, triggerScriptLoader, {
        passive: true,
      });
    });
  }
});

function loadScripts() {
  if (!$('#_GoogleTagManager').length) {
    $(
      '<script id="_GoogleTagManager">\
      (function (w, d, s, l, i) {\
          w[l] = w[l] || [];\
          w[l].push({\
              "gtm.start": new Date().getTime(),\
              event: "gtm.js"\
          });\
          var f = d.getElementsByTagName(s)[0],\
              j = d.createElement(s),\
              dl = l != "dataLayer" ? "&l=" + l : "";\
          j.async = true;\
          j.src =\
              "https://www.googletagmanager.com/gtm.js?id=" + i + dl;\
          f.parentNode.insertBefore(j, f);\
      })(window, document, "script", "dataLayer", "GTM-WKXGJK8");\
  </script>'
    ).appendTo('head');
  }

  if ($('#_home_youtube_video_container').find('iframe').length === 0) {
    $('#_home_youtube_video_container').html(
      '<iframe id="_home_youtube_video" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="" frameborder="0" height="650" src="https://www.youtube-nocookie.com/embed/ldhAtkA5gBI" title="YouTube video player" width="100%"></iframe>'
    );
  }
}
////site-uploads/1001437/frontjs/handle-bread-crumb.js
jQuery(function ($) {
  /* Start for add custom breadcrumb Link */
  function returnPageSlug() {
    console.log('window.location.href => ', window.location.href);
    var allURL = window.location.href;
    var domainName = window.location.hostname;
    var currentPage = allURL.replace(domainName, '');
    var currentPage = currentPage.replace('https', '');
    var currentPage = currentPage.replace('http', '');
    var currentPage = currentPage.replace(/\//g, '');
    var currentPage = currentPage.replace(/:/g, '');
    if (currentPage.includes('?')) {
      var currentPage = currentPage.slice(0, currentPage.indexOf('?'));
    }
    console.log('currentPage => ', currentPage);
    return currentPage;
  }

  var pagesNeedCustomBreadcrumb = [
    // {
    //   target: {
    //     name: 'BOAT & PWC LIFTS',
    //     url: '/Boat-&-PWC-Lifts'
    //   },
    //   pages: [
    //     'Naylor-Dock-Products-'
    //   ]
    // }
  ];
  /* End It Here*/
  if ($('nav.breadcrumbParent').length) {
    var breadcrumbListItemsCount = $('ol.breadcrumb li').length;

    /*Related to add custom breadcrumb*/
    if (pagesNeedCustomBreadcrumb && pagesNeedCustomBreadcrumb.length !== 0) {
      var currentPageURL = returnPageSlug();
      for (let i = 0; i < pagesNeedCustomBreadcrumb.length; i++) {
        console.log(pagesNeedCustomBreadcrumb[i]);
        if (pagesNeedCustomBreadcrumb[i].pages.includes(currentPageURL)) {
          console.log('found');
          var el =
            '<li class="breadcrumb-item" style="text-transform: capitalize;"><a href="' +
            pagesNeedCustomBreadcrumb[i].target.url +
            '">' +
            pagesNeedCustomBreadcrumb[i].target.name +
            '</a></li>';
          $(el).insertBefore($('.breadcrumb-item.active'));
          breadcrumbListItemsCount++;
        }
      }
    }
    /* End It Here*/

    var modelTitle = '';
    if ($('.model-details-content.container .model-title').length) {
      $('.model-details-content.container .model-title').hide();
      modelTitle = $('.model-details-content.container .model-title').text();
    }

    var elementToHide = $('.breadcrumb-item.active');
    var new_title = elementToHide.text();
    console.log('new_title => ', new_title);
    elementToHide.hide();
    new_title = new_title
      .split('-')
      .filter(function (item) {
        item = item ? item.replace(/-/g, '') : item;
        return item;
      })
      .join(' ');

    new_title =
      modelTitle.length === 0 ? new_title.replace(/  +/g, ' - ') : modelTitle;
    /* handle get breadcrumb text from DOM Element */
    var customTitleExist = document.getElementById('_custome_breadcrumb_title');
    if (customTitleExist) {
      console.log(customTitleExist.innerText);
      customTitleExist.style.display = 'none';
      new_title = customTitleExist.innerText;
    }
    console.log('customTitleExist => ', customTitleExist);
    new_titleCharCount = new_title.length;
    if (new_titleCharCount > 25 || breadcrumbListItemsCount > 2 || 1 === 1) {
      var style =
        '<style>@media screen and (max-width: 620px){.breadcrumbParent {flex-direction: column;}.breadcrumbParent h2 {padding-top: 1.5vw;}}</style>';
      $('nav.breadcrumbParent').prepend(style);
    }
    ttlelement = '<h2>' + new_title + '</h2>';
    $('nav.breadcrumbParent').prepend(ttlelement);
    if ($('.col-sm-9.col-xs-12.model-ttl .model-title').length) {
      $('.col-sm-9.col-xs-12.model-ttl .model-title').hide();
    }

    /* start Capitalize other breadcrumb li elements */
    var oltherListItems = $('ol.breadcrumb li').not('.active');
    oltherListItems.each(function () {
      $(this).css({ 'text-transform': 'capitalize' });
    });
    /* End */
  }
});

function capitalizeFirstLetter(string) {
  return string.charAt(0).toUpperCase() + string.slice(1);
}

jQuery(function ($) {
  if (
    $(
      'div.col-lg-8.col-md-10.col-sm-10.col-xs-7.text-left.descColumnResponsive'
    ).length
  ) {
    $(
      'div.col-lg-8.col-md-10.col-sm-10.col-xs-7.text-left.descColumnResponsive'
    ).each(function () {
      console.log($(this).text());
      var text = $(this).text().replace(/\s/g, '');
      if (text === 'N/A') {
        $(this).parent().hide();
      }
    });
  }
});
////site-uploads/1001437/frontjs/slide-to-top.js
$(document).ready(function () {
  $('body').find('i').text('');
});

/* slide to top */
$(document).ready(function () {
    $("a[href='#top']").on('click', function (e) {
      e.preventDefault();
      $('html, body').animate({
          scrollTop: 0,
        },
        'slow'
      );
      return false;
    });
  });
  
  $('.goto-Agco-apply-link').on('click', function (e) {
    e.preventDefault();
    $('html,body').animate({
        scrollTop: $('#Agco-apply-link').offset().top - 200,
      },
      'slow'
    );
  });
////site-uploads/1001437/frontjs/sticky.js

$(function () {
    $(window).on("scroll", function () {
        if ($(window).scrollTop() > 48) {
            $("#comp_1663353813698").addClass("sticky-header");
            var centerDivMargin = $('#comp_1663353813698').height();
            $('#CenterDiv').css({ "margin-top": centerDivMargin });
        } else {
            $("#comp_1663353813698").removeClass("sticky-header");
            $('#CenterDiv').css({ "margin-top": 0 });
        }
    });
});
////site-uploads/1001437/frontjs/Search_script1.js
if($('#searchbox').length){
setTimeout(function() {
    document.getElementById("searchbox")?.addEventListener("keyup", function(event) {
        event.preventDefault();
        if (event.keyCode === 13) {
            document.getElementById("searchbtn2")?.click();
        }
    });
}, 2000);
}
function srch() {
    //var e = document.getElementById("pagedd");
    //var dest= e.options[e.selectedIndex].value;
    var valuee = document.getElementById('searchbox2')?.value;
    if (valuee != "") {
        window.location = "/Search-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);
    }
}
////site-uploads/1001437/frontjs/frontjs.js
$(function () {
  $('#mfg-gallery').lightSlider({
    item: 7,
    slideMove: 2,
    easing: 'cubic-bezier(0.25, 0, 0.25, 1)',
    speed: 600,
    auto: true,
    loop: true,
    pager: false,
    responsive: [
      {
        breakpoint: 800,
        settings: {
          item: 3,
          slideMove: 1,
          slideMargin: 6,
        },
      },
      {
        breakpoint: 480,
        settings: {
          item: 2,
          slideMove: 1,
        },
      },
    ],
  });

  $('#imageGallery').on('DOMSubtreeModified', function () {
    if ($('#normal_vdp').size() > 0) {
      $('.vertical .lSSlideWrapper').prepend($('.stock-num, div.back-btn'));
    }
  });

  $('.slid-logo .lSSlideOuter').prepend($('.lSAction'));
});

$(function () {
  $('#_17-2_event').modal('show');
});
