/**
 * Exoplanet Custom JS
 *
 * @package Exoplanet
 *
 * Distributed under the MIT license - http://opensource.org/licenses/MIT
 */
var menu_width="";
jQuery(function($){
  menu_width=parseInt(jQuery("#menu-width").text().trim());
  /* Mobile responsive Menu*/
  document.getElementById("open_nav").addEventListener("click", open);
      function open() {
          document.getElementById("sidebar1").style.width = menu_width + "px";
          document.getElementById("sidebar1").style.display = "block";
          document.getElementById("sidebar1").style.transform = "translate3d(0, 0, 0)";
  }
  document.getElementById("close_nav").addEventListener("click", close);
      function close() {
          document.getElementById("sidebar1").style.width = "0";
          document.getElementById("sidebar1").style.display = "none";
  }
});
jQuery(function($){
  "use strict";
    // $('.menu > ul').superfish({
    //   delay:       500,                            
    //   animation:   {opacity:'show',height:'show'},  
    //   speed:       'fast'                         
    // });

    jQuery('.search-icon > i').click(function(){
        jQuery(".serach_outer").slideDown(700);  
    });

    jQuery('.closepop i').click(function(){
        jQuery(".serach_outer").slideUp(700);
    });
});



// jQuery("#cart-box").click(function(){ 
  
//      document.getElementById("cart").style.display = "block";

//       // jQuery("#cart-box").hide().fadeIn(1000);
// });


// document.addEventListener('mouseup', function(e) {
//     var cartbox = document.getElementById('cart');
//     if (!cartbox.contains(e.target)) {
//         cartbox.style.display = 'none';
//     }
// });
/* Mobile responsive Menu*/


jQuery(function() {
  //----- OPEN
  jQuery('[data-popup-open]').on('click', function(e) {
    var targeted_popup_class = jQuery(this).attr('data-popup-open');
    jQuery('[data-popup="' + targeted_popup_class + '"]').fadeIn(350);

    e.preventDefault();
  });

  //----- CLOSE
  jQuery('[data-popup-close]').on('click', function(e) {
    var targeted_popup_class = jQuery(this).attr('data-popup-close');
    jQuery('[data-popup="' + targeted_popup_class + '"]').fadeOut(350);

    e.preventDefault();
  });
});

jQuery('document').ready(function(){

  jQuery('.cat_toggle i').click(function() {
  jQuery('#cart_animate').toggle('slow');
  });
  
  var owl = jQuery('#category .owl-carousel');
        owl.owlCarousel({
        margin: 25,
        nav: true,
        autoplay : true,
        lazyLoad: true,
        autoplayTimeout: 3000,
        loop: false,
        navText : ['<i class="fa fa-chevron-left" aria-hidden="true"></i>','<i class="fa fa-chevron-right" aria-hidden="true"></i>'],
        responsive: {
          0: {
            items: 1
          },
          576: {
            items: 2
          },
          1000: {
            items: 4
          }
        },
        autoplayHoverPause : true,
        mouseDrag: true
    });

  var owl = jQuery('#our_records .owl-carousel');
        owl.owlCarousel({
        margin: 10,
        nav: true,
        autoplay : true,
        lazyLoad: true,
        autoplayTimeout: 3000,
        loop: false,
        navText : ['<i class="fa fa-chevron-left" aria-hidden="true"></i>','<i class="fa fa-chevron-right" aria-hidden="true"></i>'],
        responsive: {
          0: {
            items: 1
          },
          576: {
            items: 2
          },
          1000: {
            items: 4
          }
        },
        autoplayHoverPause : true,
        mouseDrag: true
    });

    var owl = jQuery('#best_seller .owl-carousel');
        owl.owlCarousel({
        margin: 10,
        nav: true,
        autoplay : true,
        lazyLoad: true,
        autoplayTimeout: 3000,
        loop: false,
        navText : ['<i class="fa fa-chevron-left" aria-hidden="true"></i>','<i class="fa fa-chevron-right" aria-hidden="true"></i>'],
        responsive: {
          0: {
            items: 1
          },
          600: {
            items: 3
          },
          1000: {
            items: 5
          }
        },
        autoplayHoverPause : true,
        mouseDrag: true
    });

    var owl = jQuery('#testimonials .owl-carousel');
        owl.owlCarousel({
        margin: 25,
        nav: true,
        autoplay : true,
        lazyLoad: true,
        autoplayTimeout: 3000,
        loop: false,
        navText : ['<i class="fa fa-chevron-left" aria-hidden="true"></i>','<i class="fa fa-chevron-right" aria-hidden="true"></i>'],
        responsive: {
          0: {
            items: 1
          },
          600: {
            items: 1
          },
          1000: {
            items: 2
          }
        },
        autoplayHoverPause : true,
        mouseDrag: true
    });
    var owl = jQuery('#latest_post .owl-carousel');
        owl.owlCarousel({
        margin: 25,
        nav: true,
        autoplay : true,
        lazyLoad: true,
        autoplayTimeout: 3000,
        loop: false,
        navText : ['<i class="fa fa-chevron-left" aria-hidden="true"></i>','<i class="fa fa-chevron-right" aria-hidden="true"></i>'],
        responsive: {
          0: {
            items: 1
          },
          576: {
            items: 2
          },
          1000: {
            items: 3
          }
        },
        autoplayHoverPause : true,
        mouseDrag: true
    });
    var owl = jQuery('#author .owl-carousel');
        owl.owlCarousel({
        margin: 20,
        nav: true,
        autoplay : true,
        lazyLoad: true,
        autoplayTimeout: 3000,
        loop: false,
        navText : ['<i class="fa fa-chevron-left" aria-hidden="true"></i>','<i class="fa fa-chevron-right" aria-hidden="true"></i>'],
        responsive: {
          0: {
            items: 1
          },
          576: {
            items: 2
          },
          1000: {
            items: 4
          }
        },
        autoplayHoverPause : true,
        mouseDrag: true
    });

    var owl = jQuery('#our_partners .owl-carousel');
        owl.owlCarousel({
        margin: 25,
        nav: true,
        autoplay : true,
        lazyLoad: true,
        autoplayTimeout: 3000,
        loop: false,
        navText : ['<i class="fa fa-chevron-left" aria-hidden="true"></i>','<i class="fa fa-chevron-right" aria-hidden="true"></i>'],
        responsive: {
          0: {
            items: 1
          },
          576: {
            items: 2
          },
          1000: {
            items: 4
          }
        },
        autoplayHoverPause : true,
        mouseDrag: true
    });

    jQuery('a.accordion-toggle').click(function() {
        jQuery("i", this).toggleClass("fas fa-plus fas fa-times");
    });

    var interval=null;
    function show_loading_box()
    {
      jQuery(".eco-box").css("display","none");
      clearInterval(interval);
    }
    jQuery('document').ready(function(){   

      interval = setInterval(show_loading_box,1000);
    });
});
/* Counter */
jQuery(document).ready(function(){
  jQuery('.vwcount').each(function () {
      jQuery(this).prop('Counter',0).animate({
          Counter: jQuery(this).text()
      }, {
          duration: 30000,
          easing: 'swing',
          step: function (now) {
             jQuery(this).text(Math.ceil(now));
          }
      });
  });
   // ------------ Scroll Top ---------------

  jQuery(window).scroll(function() {
    if (jQuery(this).scrollTop() >= 50) {        // If page is scrolled more than 50px
      jQuery('#return-to-top').fadeIn(200);    // Fade in the arrow
    } else {
      jQuery('#return-to-top').fadeOut(200);   // Else fade out the arrow
    }
  });
  jQuery('#return-to-top').click(function() {      // When arrow is clicked
    jQuery('body,html').animate({
      scrollTop : 0                       // Scroll to top of body
    }, 2000);
  });

});

jQuery(function($){

    $(window).scroll(function(){
      var scrollTop = $(window).scrollTop();
      if( scrollTop > 100 ){
        $('.menubar').addClass('scrolled');
      }else{
        $('.menubar').removeClass('scrolled');
      }
        $('.main-header').css('background-position', 'center ' + (scrollTop / 2) + 'px');
    });

 });

  //At the document ready event
jQuery(function(){
  new WOW().init();
});

//also at the window load event
jQuery(window).on('load', function(){

     new WOW().init();
});

jQuery('body').on('added_to_cart', function(e, fragments, cart_hash, button) {
      var product = '';
      var img = '';
      var title = '';
      var url = '';

     if (vw_book_store_pro_customscripts_obj.is_home == "1" ) {
        var product = jQuery(button).closest('.product-content');
        var img = product.find('img').attr('src');
        var title = product.find('.product_head').text();
        var url = product.find('.woocommerce-loop-product__link').attr('href');
      } else {
        var product = jQuery(button).closest('.product');
        var img = product.find('img').attr('src');
        var title = product.find('.woocommerce-loop-product__title').text();
        var url = product.find('.product_head').attr('href');
      }
      if ( product != '' ) {
        jQuery.notify({
          icon: img,
          title: title,
          message: "Product has been added to your cart.",
          url: url
        }, {
          type: 'minimalist',
          delay: "3000",
          icon_type: 'image',
          template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-{0}" role="alert">' +
            '<img data-notify="icon" class="img-circle pull-left">' +
            '<span class="prod-title" data-notify="title">{1}</span>' +
            '<div class="prod-messg" data-notify="message">{2}</div>' +
            '</div>'
        });
      }

    });