
  (function ($) {

    $(window).load(function () {
        $("#pre-loader").delay(500).fadeOut();
        $(".loader-wrapper").delay(1000).fadeOut("slow");
    });

    $(document).ready(function () {
        $('.navbar li>a').addClass('hvr-underline-from-left');
        $('.navbar li li>a').removeClass('hvr-underline-from-left');
        $('.testimonial-section').find('.item').first().addClass('active');
        $('.quick-links .links li a').prepend("<i class='fas fa-angle-double-right'></i>");
        $('.blog .image').find('img').addClass('img-responsive');       
        /*-- page builder --*/
        $('.panel-layout > div .panel-row-style').wrapInner('<div class="container"></div>'); 
        $('.panel-layout > div.panel-no-style').wrapInner('<div class="container"></div>');         
        /*--woocommerce--*/
        $('.woocommerce .woocommerce-ordering select').wrap('<div class="dropdown"></div>'); 
        $('.navbar .widget.woocommerce.widget_shopping_cart').wrap('<li class="right"></li>'); 
        $('.navbar .mini_cart_item a').removeClass('hvr-underline-from-left');


        /* menu hover */
        var limit = 767;
        var window_width = window.innerWidth;
        if(window_width>limit){
            $('.navbar .wc-cart-menu').hover(function(){
            $('.navbar .widget.woocommerce.widget_shopping_cart').css('display', 'block');
            } ,function(){         
            $('.navbar .widget.woocommerce.widget_shopping_cart').css('display', 'none');
          });  
        }    
        else{
            $('.navbar li>a').removeClass('hvr-underline-from-left');
            $('#navigation .navbar > .active > a').css('box-shadow', 'none');
        }
        $('.navbar .widget.woocommerce.widget_shopping_cart').hover(function(){
            $('.navbar .widget.woocommerce.widget_shopping_cart').css('display', 'block');
        },function(){         
            $('.navbar .widget.woocommerce.widget_shopping_cart').css('display', 'none');
        });   


        /*-- Mobile menu --*/
        if($('#soma-main-menu-wrapper').length) {
            $('#soma-main-menu-wrapper .nav li.dropdown').append(function () {
              return '<i class="fa fa-angle-down" aria-hidden="true"></i>';
            });
            $('#soma-main-menu-wrapper .nav li.dropdown .fa').on('click', function () {
              $(this).parent('li').children('ul').slideToggle();
            });
        }

       
       /*-- Background image--*/
        var clientHeight = $( window ).height();        
        $('#slider #slider-inner').css('height', clientHeight);        

        /*-- adding sidebar class to page having sidebar --*/
        if (!document.contains(document.getElementById('secondary'))) {
          document.body.classList.add('no-sidebar');
        }
        else{
          document.body.classList.add('has-sidebar'); 
        }

        /*-- button up --*/
        var btnUp = $('<div/>', { 'class': 'btntoTop' });
        btnUp.appendTo('body');
        $(document)
        .on('click', '.btntoTop', function () {
            $('html, body').animate({
                scrollTop: 0
            }, 700);
        });
        $(window)
        .on('scroll', function () {
            if ($(this).scrollTop() > 200)
                $('.btntoTop').addClass('active');
            else
                $('.btntoTop').removeClass('active');
        });

        /*-- Counters --*/
        var timer = $('.timer');  
        timer.appear(function () {
            timer.countTo();
        }) 

        /*-- wow js initialize --*/
        new WOW().init();        

        /*-- Magnific Popup --*/
        $('.image-popup-link').magnificPopup({
            type: 'image',
            closeOnBgClick: true,
            fixedContentPos: false,              
        });
        $('.video-popup-link').magnificPopup({
            type: 'iframe',
            closeOnBgClick: true,
            fixedContentPos: false,              
        });
        $('.gallery-item').magnificPopup({
          type: 'image',
          closeOnBgClick: true,
          fixedContentPos: false,              
          gallery:{
            enabled:true
          }
        });                
        
    });
})(this.jQuery);