Journal.notificationTimer = parseInt('{{ journal2.settings.get('notification_hide') }}', 10);

Journal.quickviewText = '{{ journal2.settings.get('quickview_button_text') }}';

Journal.scrollToTop = parseInt('{{ journal2.settings.get('scroll_to_top', '1') }}', 10);

Journal.searchInDescription = {{ journal2.settings.get('search_autocomplete_include_description', '1') == '1' ? 'true' : 'false' }};

Journal.galleryZoom = {{ journal2.settings.get('pp_gallery_zoom', 'on') == 'on' ? 'true' : 'false' }};
Journal.galleryThumb = {{ journal2.settings.get('pp_gallery_thumbs', 'on') == 'on' ? 'true' : 'false' }};
Journal.galleryThumbHide = {{ journal2.settings.get('pp_gallery_thumbs_hide', 'on') == 'off' ? 'true' : 'false' }};
Journal.galleryThumbWidth = parseInt('{{ journal2.settings.get('pp_gallery_thumbs_width', '100') }}', 10);
Journal.galleryThumbHeight = parseInt('{{ journal2.settings.get('pp_gallery_thumbs_height', '100') }}', 10);
Journal.galleryThumbSpacing = parseInt('{{ journal2.settings.get('pp_gallery_thumbs_spacing', '7') }}', 10);
Journal.galleryBarsDelay = parseInt('{{ journal2.settings.get('hide_gallery_bars_after', '5000') }}', 10);

Journal.infiniteScrollStatus = {{ journal2.settings.get('infinite_scroll', '1') ? 'true' : 'false' }};
Journal.infiniteScrollLoadingText = '{{ journal2.settings.get('infinite_scroll_loading_text', 'Loading') | replace ("'","\\'") }}';
Journal.infiniteScrollNoMoreItemsText = '{{ journal2.settings.get('infinite_scroll_no_more_items_text', 'No items left.') | replace ("'","\\'") }}';
Journal.infiniteScrollLoadMoreItemsText = '{{ journal2.settings.get('infinite_scroll_load_more_items_text', 'Load more') | replace ("'","\\'") }}';
Journal.infiniteScrollLoadMoreItemsOffset = parseInt('{{ journal2.settings.get('infinite_scroll_load_more_items_offset', '0') | replace ("'","\\'") }}', 10);
Journal.hasCountdownEnabled = {{ journal2.settings.get('show_countdown', 'never') == 'never' ? 'false' : 'true' }};
Journal.hasStickyScroll = {{ journal2.settings.get('sticky_header_hide', '1')}};


Journal.BASE_HREF = 'url(' + $('base').attr('href') + ')';

$(document).ready(function () {

$(".product-page .rating a").click(function() {
    $('html, body').animate({
        scrollTop: $("#tabs").offset().top - 50
    }, 600);
});

if ($('html').hasClass('filter-on-mobile')) {
$('.journal-sf').before($('<div class="open-filter" style="display:none">{{ journal2.settings.get('filter_mobile_text', 'Product Filters') }}</div>'));
$('.open-filter').on('click', function () {
var $filter = $('.journal-sf .box').first();
if ($filter.hasClass('is-visible')) {
$('.side-column .journal-sf .box').slideUp(300);
$('.sf-reset').fadeOut(200);
$filter.removeClass('is-visible');
} else {
$('.side-column .journal-sf .box').slideDown(300);
$('.sf-reset').fadeIn(200);
$filter.addClass('is-visible');
}
});
}

Journal.productPage();

{% if not journal2.html_classes.hasClass('mobile') and ((journal2.settings.get('sticky_header', '1') == '1' and staticCall('Journal2Utils', 'getDevice') == 'desktop') or (journal2.settings.get('sticky_header_tablet', '1') == '1' and staticCall('Journal2Utils', 'getDevice') == 'tablet')) %}
  Journal.enableStickyHeader({{ journal2.settings.get('boxed_top_spacing', 0) }});
{% endif %}

{% if journal2.settings.get('mobile_menu_cart_display', 'on') == 'off' %}
  $('header').addClass('menu-cart-off');
{% endif %}

{% if journal2.settings.get('sticky_menu_phone_2', 'on') == 'on' %}
  $(window).scroll( function() {
  if ($(window).scrollTop() > $('.journal-cart').offset().top){
  $('header').addClass('phone-sticky-cart');
  }
  else{
  $('header').removeClass('phone-sticky-cart');
  }

  if ($(window).scrollTop() > $('.journal-cart').offset().top + 40){
  $('header').addClass('phone-sticky-menu');
  }
  else{
  $('header').removeClass('phone-sticky-menu');
  }
  });
{% endif %}


{% if journal2.settings.get('product_page_tabs_position', 'on') == 'off' %}
  $('.product-tabs').insertAfter('.product-info');
{% endif %}

{% if journal2.settings.get('product_page_auto_update_price', '1') == '1' %}
  Journal.enableProductOptions();
  Journal.updatePrice = true;
{% endif %}

{% if staticCall('Journal2Utils', 'getDevice') == 'desktop' %}
  Journal.enableSideBlocks();
{% endif %}

{# enable search autocomplete #}
{% if (staticCall('Journal2Utils', 'getDevice') == 'desktop' and journal2.settings.get('search_autocomplete', '1') == '1') or
(staticCall('Journal2Utils', 'getDevice') == 'tablet' and journal2.settings.get('search_autocomplete_tablet', '1') == '1') or
(staticCall('Journal2Utils', 'getDevice') == 'phone' and journal2.settings.get('search_autocomplete_phone', '1') == '1') %}
  Journal.searchAutoComplete();
{% endif %}

{# enable quickview #}
{% if journal2.settings.get('quickview_status') == '1' and staticCall('Journal2Utils', 'getDevice') == 'desktop' and not journal2.html_classes.hasClass("ie8") %}
  Journal.enableQuickView();
  Journal.quickViewStatus = true;
{% else %}
  Journal.quickViewStatus = false;
{% endif %}

{# enable cloudzoom #}
{% if journal2.settings.get('product_page_cloud_zoom') == '1' and staticCall('Journal2Utils', 'getDevice') == 'desktop' %}
  if ($('html').hasClass('product-page') || $('html').hasClass('quickview')) {
  Journal.enableCloudZoom('{{ journal2.settings.get('product_page_cloud_zoom_inner', '0') == '0' ? 'standard' : 'inner' }}');
  }
{% endif %}

{# enable product page gallery #}
{% if journal2.settings.get('product_page_gallery') == '1' %}
  Journal.productPageGallery();
{% else %}
  $('.product-info .image a').css('cursor','default').click(function(){
  return false;
  });
{% endif %}


{% if (staticCall('Journal2Utils', 'getDevice') == 'desktop' and journal2.settings.get('scroll_top', '1') == '1') or
(staticCall('Journal2Utils', 'getDevice') == 'tablet' and journal2.settings.get('scroll_top_tablet', '1') == '1') or
(staticCall('Journal2Utils', 'getDevice') == 'phone' and journal2.settings.get('scroll_top_phone', '1') == '1') %}
  $(window).scroll(function () {
  if ($(this).scrollTop() > 300) {
  $('.scroll-top').fadeIn(200);
  } else {
  $('.scroll-top').fadeOut(200);
  }
  });

  $('.scroll-top').click(function () {
  $('html, body').animate({scrollTop: 0}, 700);
  });
{% endif %}


$('#top-modules > .hide-on-mobile').parent().addClass('hide-on-mobile');
$('#bottom-modules > .hide-on-mobile').parent().addClass('hide-on-mobile');

$('#top-modules .gutter-on').parent().addClass('gutter');
$('#bottom-modules .gutter-on').parent().addClass('gutter');

if (Journal.infiniteScrollStatus && $('.main-products').length) {
Journal.infiniteScroll();
}

$(window).resize();

Journal.init();
});

/* Custom JS */
{{ journal2.settings.get('custom_js') }}
