
////site-uploads/1001518/frontjs/main_v4.js
/* Menu */
$(document).ready(function () {
  $(".navbar-toggle").on("click", function () {
    $(this).toggleClass("active");
  });
  
  
  /* Make Guest checkout phone number field required*/
  $('#completeBuyerProfile input[placeholder="Phone Number"]').attr("required","true");
});

/* 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) {
      $("#html_1705994171125").addClass("sticky-nav");
    } else {
      $("#html_1705994171125").removeClass("sticky-nav");
    }
  });
});

/* Slide to top */
$(document).ready(function () {
  $("a[href='#top']").on("click", function (e) {
    e.preventDefault();
    $("html, body").animate(
      {
        scrollTop: 0,
      },
      "slow"
    );
    return false;
  });
});

/* Stop the pause on mouse hover - carousel */
$(".carousel").carousel({
  pause: "false",
});

/* 404 page */

$(function () {
  if ($("img[alt='Error:404 Page Not Found']").length) {
    console.log("404");
    var content = `<div class="_404-container">
                          <div>
                              <p>404 PAGE NOT FOUND. CHECKOUT OUR INVENTORY OR <a href="/Contact-Us/">CONTACT US</a></p>
  
                              <div class="btn-link">
                                  <a href="/Yamaha-Parts/">Yamaha Parts</a>
                                  <a href="/Yamaha-Accessories/">Yamaha Accessories</a>
                              </div>
                          </div>
                      </div>`;

    $("#CenterDiv").html(content);
  }
});

/* this website */

// Update Menu
$(document).ready(function () {
  var oldHtml = $(".navbar-toggle").html();
  $(".navbar-toggle").html("<span class='wrapper'>" + oldHtml + "</span>");
});

$(document).mouseup(function (e) {
  var container = $(".navbar-collapse.collapse");

  // if the target of the click isn't the container nor a descendant of the container
  if (!container.is(e.target) && container.has(e.target).length === 0) {
    container.removeClass("in");
  }
});

/* hamdle panel */
$(document).ready(function () {
  $(".clickToOpenAndHideME").on("click", function (e) {
    $(this).parent().removeClass("visible-xs");
    $(this).parent().addClass("hidden");
  });

  $(".clickToOpenAndHideOther").on("click", function (e) {
    var targetClass = $(this).attr("aria-controls").replace("-accord", "");
    console.log({ targetClass });

    $(".clickToOpenAndHideME." + targetClass)
      .parent()
      .addClass("visible-xs");
    $(".clickToOpenAndHideME." + targetClass)
      .parent()
      .removeClass("hidden");
  });
});

/* Start Handle Fake anchors */
$(function () {
  $("[data-href]").on("click", function (e) {
    var target = $(this).attr("target") || undefined;
    if (!e.target.matches("a")) {
      console.log("target => ", target);
      var href = $(this).data("href");
      if (target === "blank") {
        window.open(href, target);
      } else {
        window.location = href;
      }
    }
  });
});
/* End Handle Fake anchors */

$(function () {
  if ($("#detailsParentDiv").length) {
    $(".fitment-div").hide();
  }

  if ($(".fitment-div").length) {
    if ($(".fitment-drop.title").length) {
      return;
    } else {
      var el =
        '<div class="fitment-drop title"><i class="fas fa-sliders-h">&nbsp;</i> <span>Fitment Accessory</span></div>';
      var wrapper = $(".fitment-div .row.drops-box");
      wrapper.prepend(el);
    }
  }
  
  
  
  
  /* Yamalube Fitments button*/

});
  $("#page_71096 #comp_1707511643113, #page_67904 #comp_1707511643113").remove();
 
$(function(){
	 $("#page_67904 #fitmentSearch").click(function(){
	  var paremes = $('#fitmentForm').serialize();
	  var href = '/Yamaha-Service-Parts';
	  href = href + '?' + paremes;
	  console.log(href);
	  //window.location.assign(href);
	  window.location.href = href;
	});
	
  $("#page_71096 #fitmentSearch").click(function(){
	  var paremes = $('#fitmentForm').serialize();
	  var href = '/Yamalube-Products';
	  href = href + '?' + paremes;
	  //console.log(href);
	  //window.location.assign(href);
	  window.location.href = href;
	});
	
});
 
	
	
////site-uploads/1001518/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);
}

if ($("#_searchbox2").length) {
  setTimeout(function () {
    document
      .getElementById("_searchbox2")
      .addEventListener("keyup", function (event) {
        event.preventDefault();
        if (event.keyCode === 13) {
          document.getElementById("_searchbtn")?.click();
        }
      });
  }, 2000);
}

function srch() {
  //var e = document.getElementById("pagedd");
  //var dest= e.options[e.selectedIndex].value;
  var valuee =
    document.getElementById("_searchbox2").value ||
    document.getElementById("searchbox2")?.value;
  if (valuee != "") {
    window.location = "/Search-Parts/search/".concat(valuee);
  } else {
    document.getElementById("_searchbox2").placeholder =
      "This field is required";
    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/1001518/frontjs/breadcrumbs.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 = "<h1>" + new_title + "</h1>";
    $("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();
      }
    });
  }
});
