
////site-uploads/1001583/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_1718931892598").addClass("sticky-nav");
    } else {
      $("#comp_1718931892598").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;
  });
});

/* Web Site Only */

// /* Hide breadcrumb in VDP */
$(document).ready(function () {
  if (
    $("#seamaster_vdp").length ||
    $(".blog-VDP").length ||
    $(".blog-srp").length
  ) {
    $(".breadcrumbParent").remove();
  }
});

// update global 404
$(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>
                    </div>`;

    $("#CenterDiv").html(content);
  }
});

/* Change SRP when no data - update empty inventory */
function changeSRPLable() {
  if ($(".seamaster-srp").length) {
    if ($(".no-ads-box").length) {
      $(".no-ads-box .row-custom").remove();
    }
  }
}

$(document).ajaxComplete(function () {
  changeSRPLable();
});

$(document).ready(function () {
  changeSRPLable();
});

$(function () {
  $("#mc-embedded-subscribe-form").on("submit", function (e) {
    console.log({ e });
    e.preventDefault();
    // /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/

    if (
      /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(
        e.currentTarget[0].value
      )
    ) {
      console.log(e.currentTarget[0].value);
      location.href = "/Newsletter-Sign-Up?email=" + e.currentTarget[0].value;
    } else {
      alert("Please enter a valid E-mail");
    }
  });
});

$(function () {
  if (
    window.location.href.indexOf("email") != -1 &&
    window.location.href.indexOf("Newsletter-Sign-Up") != -1
  ) {
    var emailParam = window.location.href.slice(
      window.location.href.indexOf("?") + 1
    );
    var str1 = emailParam.slice(0, emailParam.indexOf("="));
    var val = emailParam.slice(emailParam.indexOf("=") + 1);
    val = val.replaceAll("%20", " ");
    var selector = str1.charAt(0) + str1.slice(1);

    $("#" + selector).attr("value", val);
    $("#" + selector).attr("style", "background-color: #d6d6d6 !important");
  }
});

$(function () {
  if ($("._follow-us-container").find("script").length === 0) {
    $("._follow-us-container").append(
      '<script src="https://snapwidget.com/js/snapwidget.js"></script>'
    );
  }
  if ($("._follow-us-container").find("iframe").length === 0) {
    $("._follow-us-container").append(
      '<iframe src="https://snapwidget.com/embed/1054182" class="snapwidget-widget" allowtransparency="true" frameborder="0" scrolling="no" style="border:none; overflow:hidden;"></iframe>'
    );
  }
});

/* Testimonial content */

$(function () {
  if ($("#testimonial-list").length) {
    var Testimonials = [
      {
        name: "shaun ram",
        review: "The staff there is amazing. Always go the extra mile",
        stars: 5,
        date: "a month ago",
      },
      {
        name: "Bernhard Koppe",
        review: "",
        stars: 5,
        date: "2 months ago",
      },
      {
        name: "G Lau",
        review:
          "Great service. Friendly staff. Cares about customers past and present. Greg and his crew are genuine. Will always use them for my boating needs. Gerald",
        stars: 5,
        date: "3 months ago",
      },
      {
        name: "Valerie Blomme",
        review: "Staff is super helpful! thanks",
        stars: 5,
        date: "5 months ago",
      },
      {
        name: "Christopher Smith",
        review: "",
        stars: 5,
        date: "5 months ago",
      },
      {
        name: "Will S",
        review:
          "Great workmanship, and very helpful staff! We are new boat owners and North Shore Marine was very thorough in explaining their services. Would definitely come back again for my future!",
        stars: 5,
        date: "5 months ago",
      },
      {
        name: "Cheekeye the-dog",
        review: "Great business Very very very very very busy but very good",
        stars: 5,
        date: "6 months ago",
      },
      {
        name: "AmandaE",
        review: "Great staff!",
        stars: 5,
        date: "6 months ago",
      },
      {
        name: "Austin Markey",
        review:
          "Shaun is the best. Now this is my new shop for my 420 sea ray sedan",
        stars: 5,
        date: "7 months ago",
      },
      {
        name: "Summer Muzyka",
        review: "",
        stars: 5,
        date: "10 months ago",
      },
      {
        name: "Canpac Marine",
        review: "",
        stars: 5,
        date: "a year ago",
      },
      {
        name: "Bob Lapp",
        review:
          "I brought in a Merc 3.0 that had a frustrating stalling problem. I had taken the boat into another well known shop and they could not find the problem. North Shore Marine took the boat out for a test in the water until the problem occurred again. They recommended working on the carb as the likely problem. We eventually had to rebuild the carb. This was not a cheap job but they were in close contact throughout the job and discussed options with me. I would highly recommend this company as they will get to the bottom of your problem and fix it with no surprises.",
        stars: 5,
        date: "a year ago",
      },
      {
        name: "Max H",
        review: "Very knowledgeable staff",
        stars: 5,
        date: "a year ago",
      },
      {
        name: "Carl Jarrett",
        review:
          "I had both of my stern drive bellow replaced by North Shore Marine. High quality service and ended up coming in below original estimates. Very happy with the work and the cost. They answered all my newbie boater questions and helped me out. Much appreciated, thank you.",
        stars: 5,
        date: "a year ago",
      },
      {
        name: "Hesam Navidi",
        review: "",
        stars: 5,
        date: "2 years ago",
      },
      {
        name: "J M",
        review:
          "Bought a refurbished Generator from them.   Was a very clean unit at a great price, ran amazing.",
        stars: 5,
        date: "2 years ago",
      },
      {
        name: "Derek Dodds",
        review: "Great service",
        stars: 5,
        date: "2 years ago",
      },
      {
        name: "Pete Arduini",
        review: "",
        stars: 5,
        date: "2 years ago",
      },
      {
        name: "German Villarreal",
        review: "",
        stars: 5,
        date: "2 years ago",
      },
      {
        name: "DJJMC",
        review: "Great prices and quality workmanship",
        stars: 5,
        date: "2 years ago",
      },
      {
        name: "Westcoaster",
        review:
          "Friendly and  knowledgeable.  Took the time to sort us out with a new (small 30hp) engine and did a water trial.",
        stars: 5,
        date: "3 years ago",
      },
      {
        name: "Kasra Roghanian",
        review: "These guy are awesome and always helped me out",
        stars: 5,
        date: "3 years ago",
      },
      {
        name: "Hartland Ross",
        review:
          "I had an issue with my fuel gauge not working and I called and talked to Jordan the electrician and not only did he offer to fit me in when they were super busy but he gave me directions to try to diagnose the issue myself and although I ended up getting his help to confirm what I had done, he only charged me for a quick diagnostic vs the over $500 another shop wanted just to look at it. Jordan behind the counter then found the same gauge and ordered it in quickly for me. I just installed it myself and am back in business! Team Jordan was amazing. Thanks so much guys. I highly recommend giving them a call!",
        stars: 5,
        date: "3 years ago",
      },
      {
        name: "Admiral B.",
        review:
          "I have contacted Greg many times in a pinch. And he's always helped. I appreciate that. Thanks NSM Ltd.",
        stars: 5,
        date: "3 years ago",
      },
    ];

    var ulInner = "";
    for (let i = 0; i < Testimonials.length; i++) {
      ulInner +=
        "\
      <li class='testimonial testimonial-1'> \
    <div class='testimonial-rating'>\
    <div class='testimonial-overall-rating'>\
    <div class='rating-value'>\
    <span aria-hidden='true' class='fa fa-fw fa-star rate1'>&nbsp;</span>\
    <span aria-hidden='true' class='fa fa-fw fa-star rate2'>&nbsp;</span>\
    <span aria-hidden='true' class='fa fa-fw fa-star rate3'>&nbsp;</span>\
    <span aria-hidden='true' class='fa fa-fw fa-star rate4'>&nbsp;</span>\
    <span aria-hidden='true' class='fa fa-fw fa-star rate5'>&nbsp;</span></div> </div>\
    <div class='testimonial-date'>" +
        Testimonials[i].date +
        "</div> </div>\
    <div class='testimonial-content'>\
    <div class='testimonial-comment'>\
    <p>" +
        Testimonials[i].review +
        "</p> </div>\
    <div class='testimonial-attribution'>\
    <div class='attribution-details'>\
    <span class='attribution-first-name'>" +
        Testimonials[i].name +
        "</span>\
    <span class='attribution-last-name'>&nbsp;</span>\
    <span class='attribution-city'>&nbsp;</span>\
    <span class='attribution-state'>&nbsp;</span></div>\
    </div> </div> </div> </li>";
    }

    $("#testimonial-list").html(ulInner);
  }
});

$(document).ready(function () {
  if ($(".seamaster-srp").length && $("#page_66660").length) {
    var mainDiv = $("#CenterDiv");
    var content =
      '<div class="build-your-boat-btns"><a id="build-your-boat" href="https://www.rossiterboats.com/build-your-boat/" target="_blank">Build Your Rossiter Boat</a></div>';
    var content2 =
      '<div class="build-your-boat-btns _center"><a id="build-your-boat" href="https://www.rossiterboats.com/build-your-boat/" target="_blank">Build Your Rossiter Boat</a></div>';

    mainDiv.prepend(content);
    mainDiv.append(content2);
  }
});

// var theLanguage = $('html').attr('lang');
// // Diferent language
// if (theLanguage == 'fr') {
//   $('.finacning-link').attr('href', '/fr/Get-Financed');

//   $('.finacning-link').attr('target', '_self');
// } else {
//   $('.finacning-link').attr('href', '/Get-Financed');

//   $('.finacning-link').attr('target', '_self');
// }

// /* Slider Content */
// $(document).ready(function () {
//   var content =
//     '\
//   <div id="inner_content">\
//       <a href="/New-Inventory">\
//           <span>New Inventory</span>\
//           <span>Shop Here &nbsp; <i class="far fa-long-arrow-right">&nbsp;</i></span>\
//       </a>\
//       <a href="/Pre-Owned">\
//           <span>Pre-Owned</span>\
//           <span>Shop Here &nbsp; <i class="far fa-long-arrow-right">&nbsp;</i></span>\
//       </a>\
//       <a href="/Shop">\
//           <span>Shop Online</span>\
//           <span>Shop Here &nbsp; <i class="far fa-long-arrow-right">&nbsp;</i></span>\
//       </a>\
//   </div>\
//   ';

//   var target = $('#comp_1695457074806');
//   target.append(content);
// });
////site-uploads/1001583/frontjs/Search_script.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/1001583/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();
      }
    });
  }
});
