var Wick = Wick || {};
Wick.PDP = (function () {
  var $page = $('.page-product-details');
  function bindEvents(){
    $('[data-open-tab]').on('click', function () {
      var tabLink = $(this).attr('data-open-tab');
      $(tabLink).tab('show');
      $('html, body').animate({
        scrollTop: $('.tabs_pdp').offset().top - 30
      }, 300);

      return false;
    });

    $('[data-link]').on('click', function () {
      var linkTo = $(this).attr('data-link');
      $('html, body').animate({
        scrollTop: $(linkTo).offset().top - 30
      }, 700);

      return false;
    });

    $page
      .find('.btn-add-to-basket, .card-store-collect__btn')
      .on('click', function(){
        Wick.MiniBasket.showJustAdded();
      });
  }

  function init(){
    if (!$page.length){
      return;
    }

    bindEvents();
  }

  init();
})();
