HEX
Server: Apache
System: Linux p3plzcpnl504902.prod.phx3.secureserver.net 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: nhqyemt2u0zd (3690907)
PHP: 7.2.34
Disabled: NONE
Upload Files
File: /home/nhqyemt2u0zd/public_html/wp-content/cache/minify/96ffa.js_old
/*!
 * Packery layout mode PACKAGED v2.0.0
 * sub-classes Packery
 */

!function(a,b){"function"==typeof define&&define.amd?define("packery/js/rect",b):"object"==typeof module&&module.exports?module.exports=b():(a.Packery=a.Packery||{},a.Packery.Rect=b())}(window,function(){function a(b){for(var c in a.defaults)this[c]=a.defaults[c];for(c in b)this[c]=b[c]}a.defaults={x:0,y:0,width:0,height:0};var b=a.prototype;return b.contains=function(a){var b=a.width||0,c=a.height||0;return this.x<=a.x&&this.y<=a.y&&this.x+this.width>=a.x+b&&this.y+this.height>=a.y+c},b.overlaps=function(a){var b=this.x+this.width,c=this.y+this.height,d=a.x+a.width,e=a.y+a.height;return this.x<d&&b>a.x&&this.y<e&&c>a.y},b.getMaximalFreeRects=function(b){if(!this.overlaps(b))return!1;var c,d=[],e=this.x+this.width,f=this.y+this.height,g=b.x+b.width,h=b.y+b.height;return this.y<b.y&&(c=new a({x:this.x,y:this.y,width:this.width,height:b.y-this.y}),d.push(c)),e>g&&(c=new a({x:g,y:this.y,width:e-g,height:this.height}),d.push(c)),f>h&&(c=new a({x:this.x,y:h,width:this.width,height:f-h}),d.push(c)),this.x<b.x&&(c=new a({x:this.x,y:this.y,width:b.x-this.x,height:this.height}),d.push(c)),d},b.canFit=function(a){return this.width>=a.width&&this.height>=a.height},a}),function(a,b){if("function"==typeof define&&define.amd)define("packery/js/packer",["./rect"],b);else if("object"==typeof module&&module.exports)module.exports=b(require("./rect"));else{var c=a.Packery=a.Packery||{};c.Packer=b(c.Rect)}}(window,function(a){function b(a,b,c){this.width=a||0,this.height=b||0,this.sortDirection=c||"downwardLeftToRight",this.reset()}var c=b.prototype;c.reset=function(){this.spaces=[];var b=new a({x:0,y:0,width:this.width,height:this.height});this.spaces.push(b),this.sorter=d[this.sortDirection]||d.downwardLeftToRight},c.pack=function(a){for(var b=0;b<this.spaces.length;b++){var c=this.spaces[b];if(c.canFit(a)){this.placeInSpace(a,c);break}}},c.columnPack=function(a){for(var b=0;b<this.spaces.length;b++){var c=this.spaces[b],d=c.x<=a.x&&c.x+c.width>=a.x+a.width&&c.height>=a.height-.01;if(d){a.y=c.y,this.placed(a);break}}},c.rowPack=function(a){for(var b=0;b<this.spaces.length;b++){var c=this.spaces[b],d=c.y<=a.y&&c.y+c.height>=a.y+a.height&&c.width>=a.width-.01;if(d){a.x=c.x,this.placed(a);break}}},c.placeInSpace=function(a,b){a.x=b.x,a.y=b.y,this.placed(a)},c.placed=function(a){for(var b=[],c=0;c<this.spaces.length;c++){var d=this.spaces[c],e=d.getMaximalFreeRects(a);e?b.push.apply(b,e):b.push(d)}this.spaces=b,this.mergeSortSpaces()},c.mergeSortSpaces=function(){b.mergeRects(this.spaces),this.spaces.sort(this.sorter)},c.addSpace=function(a){this.spaces.push(a),this.mergeSortSpaces()},b.mergeRects=function(a){var b=0,c=a[b];a:for(;c;){for(var d=0,e=a[b+d];e;){if(e==c)d++;else{if(e.contains(c)){a.splice(b,1),c=a[b];continue a}c.contains(e)?a.splice(b+d,1):d++}e=a[b+d]}b++,c=a[b]}return a};var d={downwardLeftToRight:function(a,b){return a.y-b.y||a.x-b.x},rightwardTopToBottom:function(a,b){return a.x-b.x||a.y-b.y}};return b}),function(a,b){"function"==typeof define&&define.amd?define("packery/js/item",["outlayer/outlayer","./rect"],b):"object"==typeof module&&module.exports?module.exports=b(require("outlayer"),require("./rect")):a.Packery.Item=b(a.Outlayer,a.Packery.Rect)}(window,function(a,b){var c=document.documentElement.style,d="string"==typeof c.transform?"transform":"WebkitTransform",e=function(){a.Item.apply(this,arguments)},f=e.prototype=Object.create(a.Item.prototype),g=f._create;f._create=function(){g.call(this),this.rect=new b};var h=f.moveTo;return f.moveTo=function(a,b){var c=Math.abs(this.position.x-a),d=Math.abs(this.position.y-b),e=this.layout.dragItemCount&&!this.isPlacing&&!this.isTransitioning&&1>c&&1>d;return e?void this.goTo(a,b):void h.apply(this,arguments)},f.enablePlacing=function(){this.removeTransitionStyles(),this.isTransitioning&&d&&(this.element.style[d]="none"),this.isTransitioning=!1,this.getSize(),this.layout._setRectSize(this.element,this.rect),this.isPlacing=!0},f.disablePlacing=function(){this.isPlacing=!1},f.removeElem=function(){this.element.parentNode.removeChild(this.element),this.layout.packer.addSpace(this.rect),this.emitEvent("remove",[this])},f.showDropPlaceholder=function(){var a=this.dropPlaceholder;a||(a=this.dropPlaceholder=document.createElement("div"),a.className="packery-drop-placeholder",a.style.position="absolute"),a.style.width=this.size.width+"px",a.style.height=this.size.height+"px",this.positionDropPlaceholder(),this.layout.element.appendChild(a)},f.positionDropPlaceholder=function(){this.dropPlaceholder.style[d]="translate("+this.rect.x+"px, "+this.rect.y+"px)"},f.hideDropPlaceholder=function(){this.layout.element.removeChild(this.dropPlaceholder)},e}),function(a,b){"function"==typeof define&&define.amd?define("packery/js/packery",["get-size/get-size","outlayer/outlayer","./rect","./packer","./item"],b):"object"==typeof module&&module.exports?module.exports=b(require("get-size"),require("outlayer"),require("./rect"),require("./packer"),require("./item")):a.Packery=b(a.getSize,a.Outlayer,a.Packery.Rect,a.Packery.Packer,a.Packery.Item)}(window,function(a,b,c,d,e){function f(a,b){return a.position.y-b.position.y||a.position.x-b.position.x}function g(a,b){return a.position.x-b.position.x||a.position.y-b.position.y}function h(a,b){var c=b.x-a.x,d=b.y-a.y;return Math.sqrt(c*c+d*d)}c.prototype.canFit=function(a){return this.width>=a.width-1&&this.height>=a.height-1};var i=b.create("packery");i.Item=e;var j=i.prototype;j._create=function(){b.prototype._create.call(this),this.packer=new d,this.shiftPacker=new d,this.isEnabled=!0,this.dragItemCount=0;var a=this;this.handleDraggabilly={dragStart:function(){a.itemDragStart(this.element)},dragMove:function(){a.itemDragMove(this.element,this.position.x,this.position.y)},dragEnd:function(){a.itemDragEnd(this.element)}},this.handleUIDraggable={start:function(b,c){c&&a.itemDragStart(b.currentTarget)},drag:function(b,c){c&&a.itemDragMove(b.currentTarget,c.position.left,c.position.top)},stop:function(b,c){c&&a.itemDragEnd(b.currentTarget)}}},j._resetLayout=function(){this.getSize(),this._getMeasurements();var a,b,c;this._getOption("horizontal")?(a=1/0,b=this.size.innerHeight+this.gutter,c="rightwardTopToBottom"):(a=this.size.innerWidth+this.gutter,b=1/0,c="downwardLeftToRight"),this.packer.width=this.shiftPacker.width=a,this.packer.height=this.shiftPacker.height=b,this.packer.sortDirection=this.shiftPacker.sortDirection=c,this.packer.reset(),this.maxY=0,this.maxX=0},j._getMeasurements=function(){this._getMeasurement("columnWidth","width"),this._getMeasurement("rowHeight","height"),this._getMeasurement("gutter","width")},j._getItemLayoutPosition=function(a){if(this._setRectSize(a.element,a.rect),this.isShifting||this.dragItemCount>0){var b=this._getPackMethod();this.packer[b](a.rect)}else this.packer.pack(a.rect);return this._setMaxXY(a.rect),a.rect},j.shiftLayout=function(){this.isShifting=!0,this.layout(),delete this.isShifting},j._getPackMethod=function(){return this._getOption("horizontal")?"rowPack":"columnPack"},j._setMaxXY=function(a){this.maxX=Math.max(a.x+a.width,this.maxX),this.maxY=Math.max(a.y+a.height,this.maxY)},j._setRectSize=function(b,c){var d=a(b),e=d.outerWidth,f=d.outerHeight;(e||f)&&(e=this._applyGridGutter(e,this.columnWidth),f=this._applyGridGutter(f,this.rowHeight)),c.width=Math.min(e,this.packer.width),c.height=Math.min(f,this.packer.height)},j._applyGridGutter=function(a,b){if(!b)return a+this.gutter;b+=this.gutter;var c=a%b,d=c&&1>c?"round":"ceil";return a=Math[d](a/b)*b},j._getContainerSize=function(){return this._getOption("horizontal")?{width:this.maxX-this.gutter}:{height:this.maxY-this.gutter}},j._manageStamp=function(a){var b,d=this.getItem(a);if(d&&d.isPlacing)b=d.rect;else{var e=this._getElementOffset(a);b=new c({x:this._getOption("originLeft")?e.left:e.right,y:this._getOption("originTop")?e.top:e.bottom})}this._setRectSize(a,b),this.packer.placed(b),this._setMaxXY(b)},j.sortItemsByPosition=function(){var a=this._getOption("horizontal")?g:f;this.items.sort(a)},j.fit=function(a,b,c){var d=this.getItem(a);d&&(this.stamp(d.element),d.enablePlacing(),this.updateShiftTargets(d),b=void 0===b?d.rect.x:b,c=void 0===c?d.rect.y:c,this.shift(d,b,c),this._bindFitEvents(d),d.moveTo(d.rect.x,d.rect.y),this.shiftLayout(),this.unstamp(d.element),this.sortItemsByPosition(),d.disablePlacing())},j._bindFitEvents=function(a){function b(){d++,2==d&&c.dispatchEvent("fitComplete",null,[a])}var c=this,d=0;a.once("layout",b),this.once("layoutComplete",b)},j.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&(this.options.shiftPercentResize?this.resizeShiftPercentLayout():this.layout())},j.needsResizeLayout=function(){var b=a(this.element),c=this._getOption("horizontal")?"innerHeight":"innerWidth";return b[c]!=this.size[c]},j.resizeShiftPercentLayout=function(){var b=this._getItemsForLayout(this.items),c=this._getOption("horizontal"),d=c?"y":"x",e=c?"height":"width",f=c?"rowHeight":"columnWidth",g=c?"innerHeight":"innerWidth",h=this[f];if(h=h&&h+this.gutter){this._getMeasurements();var i=this[f]+this.gutter;b.forEach(function(a){var b=Math.round(a.rect[d]/h);a.rect[d]=b*i})}else{var j=a(this.element)[g]+this.gutter,k=this.packer[e];b.forEach(function(a){a.rect[d]=a.rect[d]/k*j})}this.shiftLayout()},j.itemDragStart=function(a){if(this.isEnabled){this.stamp(a);var b=this.getItem(a);b&&(b.enablePlacing(),b.showDropPlaceholder(),this.dragItemCount++,this.updateShiftTargets(b))}},j.updateShiftTargets=function(a){this.shiftPacker.reset(),this._getBoundingRect();var b=this._getOption("originLeft"),d=this._getOption("originTop");this.stamps.forEach(function(a){var e=this.getItem(a);if(!e||!e.isPlacing){var f=this._getElementOffset(a),g=new c({x:b?f.left:f.right,y:d?f.top:f.bottom});this._setRectSize(a,g),this.shiftPacker.placed(g)}},this);var e=this._getOption("horizontal"),f=e?"rowHeight":"columnWidth",g=e?"height":"width";this.shiftTargetKeys=[],this.shiftTargets=[];var h,i=this[f];if(i=i&&i+this.gutter){var j=Math.ceil(a.rect[g]/i),k=Math.floor((this.shiftPacker[g]+this.gutter)/i);h=(k-j)*i;for(var l=0;k>l;l++)this._addShiftTarget(l*i,0,h)}else h=this.shiftPacker[g]+this.gutter-a.rect[g],this._addShiftTarget(0,0,h);var m=this._getItemsForLayout(this.items),n=this._getPackMethod();m.forEach(function(a){var b=a.rect;this._setRectSize(a.element,b),this.shiftPacker[n](b),this._addShiftTarget(b.x,b.y,h);var c=e?b.x+b.width:b.x,d=e?b.y:b.y+b.height;if(this._addShiftTarget(c,d,h),i)for(var f=Math.round(b[g]/i),j=1;f>j;j++){var k=e?c:b.x+i*j,l=e?b.y+i*j:d;this._addShiftTarget(k,l,h)}},this)},j._addShiftTarget=function(a,b,c){var d=this._getOption("horizontal")?b:a;if(!(0!==d&&d>c)){var e=a+","+b,f=-1!=this.shiftTargetKeys.indexOf(e);f||(this.shiftTargetKeys.push(e),this.shiftTargets.push({x:a,y:b}))}},j.shift=function(a,b,c){var d,e=1/0,f={x:b,y:c};this.shiftTargets.forEach(function(a){var b=h(a,f);e>b&&(d=a,e=b)}),a.rect.x=d.x,a.rect.y=d.y};var k=120;j.itemDragMove=function(a,b,c){function d(){f.shift(e,b,c),e.positionDropPlaceholder(),f.layout()}var e=this.isEnabled&&this.getItem(a);if(e){b-=this.size.paddingLeft,c-=this.size.paddingTop;var f=this,g=new Date;this._itemDragTime&&g-this._itemDragTime<k?(clearTimeout(this.dragTimeout),this.dragTimeout=setTimeout(d,k)):(d(),this._itemDragTime=g)}},j.itemDragEnd=function(a){function b(){d++,2==d&&(c.element.classList.remove("is-positioning-post-drag"),c.hideDropPlaceholder(),e.dispatchEvent("dragItemPositioned",null,[c]))}var c=this.isEnabled&&this.getItem(a);if(c){clearTimeout(this.dragTimeout),c.element.classList.add("is-positioning-post-drag");var d=0,e=this;c.once("layout",b),this.once("layoutComplete",b),c.moveTo(c.rect.x,c.rect.y),this.layout(),this.dragItemCount=Math.max(0,this.dragItemCount-1),this.sortItemsByPosition(),c.disablePlacing(),this.unstamp(c.element)}},j.bindDraggabillyEvents=function(a){this._bindDraggabillyEvents(a,"on")},j.unbindDraggabillyEvents=function(a){this._bindDraggabillyEvents(a,"off")},j._bindDraggabillyEvents=function(a,b){var c=this.handleDraggabilly;a[b]("dragStart",c.dragStart),a[b]("dragMove",c.dragMove),a[b]("dragEnd",c.dragEnd)},j.bindUIDraggableEvents=function(a){this._bindUIDraggableEvents(a,"on")},j.unbindUIDraggableEvents=function(a){this._bindUIDraggableEvents(a,"off")},j._bindUIDraggableEvents=function(a,b){var c=this.handleUIDraggable;a[b]("dragstart",c.start)[b]("drag",c.drag)[b]("dragstop",c.stop)};var l=j.destroy;return j.destroy=function(){l.apply(this,arguments),this.isEnabled=!1},i.Rect=c,i.Packer=d,i}),function(a,b){"function"==typeof define&&define.amd?define(["isotope/js/layout-mode","packery/js/packery"],b):"object"==typeof module&&module.exports?module.exports=b(require("isotope-layout/js/layout-mode"),require("packery")):b(a.Isotope.LayoutMode,a.Packery)}(window,function(a,b){var c=a.create("packery"),d=c.prototype,e={_getElementOffset:!0,_getMeasurement:!0};for(var f in b.prototype)e[f]||(d[f]=b.prototype[f]);var g=d._resetLayout;d._resetLayout=function(){this.packer=this.packer||new b.Packer,this.shiftPacker=this.shiftPacker||new b.Packer,g.apply(this,arguments)};var h=d._getItemLayoutPosition;d._getItemLayoutPosition=function(a){return a.rect=a.rect||new b.Rect,h.call(this,a)};var i=d.needsResizeLayout;d.needsResizeLayout=function(){return this._getOption("horizontal")?this.needsVerticalResizeLayout():i.call(this)};var j=d._getOption;return d._getOption=function(a){return"horizontal"==a?void 0!==this.options.isHorizontal?this.options.isHorizontal:this.options.horizontal:j.apply(this.isotope,arguments)},c});
;var kitgreenThemeModule;

(function($) {
    "use strict";

    kitgreenThemeModule = (function() {



        return {

            init: function() {


                this.productsLoadMore();
                this.productsTabs();
                this.blogLoadMore();
                this.productImages();
                this.blogMasonry();
                this.portfolioLoadMore();
                this.stickyFooter();
                this.getSliderSettings();
                $(window).resize();

                $('body').addClass('document-ready');

                $(document.body).on('updated_cart_totals', function() {
                    kitgreenThemeModule.woocommerceWrappTable();
                });

            },

            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * add class in wishlist   
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */

            wishList: function() {
                var body = $("body");

                body.on("click", ".add_to_wishlist", function() {

                    $(this).parent().addClass("feid-in");

                });

            },


            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Google map
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */

            googleMap: function() {
                var gmap = $(".google-map-container-with-content");

                $(window).resize(function() {
                    gmap.css({
                        'height': gmap.find('.kitgreen-google-map.with-content').outerHeight()
                    })
                });

            },

            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * mobile responsive navigation 
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */

            woocommerceWrappTable: function() {

                var wooTable = $(".woocommerce .shop_table");

                var cartTotals = $(".woocommerce .cart_totals table");

                var wishList = $("#yith-wcwl-form .shop_table");

                wooTable.wrap("<div class='responsive-table'></div>");

                cartTotals.wrap("<div class='responsive-table'></div>");

                wishList.wrap("<div class='responsive-table'></div>");

            },



            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * mobile responsive navigation 
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */

            mobileNavigation: function() {

                var body = $("body"),
                    mobileNav = $(".mobile-nav"),
                    wrapperSite = $(".website-wrapper"),
                    dropDownCat = $(".mobile-nav .site-mobile-menu .menu-item-has-children"),
                    elementIcon = '<span class="icon-sub-menu"></span>',
                    butOpener = $(".icon-sub-menu");

                dropDownCat.append(elementIcon);

                mobileNav.on("click", ".icon-sub-menu", function(e) {
                    e.preventDefault();

                    if ($(this).parent().hasClass("opener-page")) {
                        $(this).parent().removeClass("opener-page").find("> ul").slideUp(200);
                        $(this).parent().removeClass("opener-page").find(".sub-menu-dropdown .container > ul").slideUp(200);
                        $(this).parent().find('> .icon-sub-menu').removeClass("up-icon");
                    } else {
                        $(this).parent().addClass("opener-page").find("> ul").slideDown(200);
                        $(this).parent().addClass("opener-page").find(".sub-menu-dropdown .container > ul").slideDown(200);
                        $(this).parent().find('> .icon-sub-menu').addClass("up-icon");
                    }
                });


                body.on("click", ".mobile-nav-icon", function() {

                    if (body.hasClass("act-mobile-menu")) {
                        closeMenu();
                    } else {
                        openMenu();
                    }

                });

                body.on("click touchstart", ".kitgreen-close-side", function() {
                    closeMenu();
                });

                function openMenu() {
                    body.addClass("act-mobile-menu");
                    wrapperSite.addClass("left-wrapp");
                }

                function closeMenu() {
                    body.removeClass("act-mobile-menu");
                    wrapperSite.removeClass("left-wrapp");
                }
            },


            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Function to make columns the same height 
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            equalizeColumns: function() {

                $.fn.kitgreen_equlize = function(options) {

                    var settings = $.extend({
                        child: "",
                    }, options);

                    var that = this;

                    if (settings.child != '') {
                        that = this.find(settings.child);
                    }

                    var resize = function() {

                        var maxHeight = 0;
                        var height;
                        that.each(function() {
                            $(this).attr('style', '');
                            if ($(window).width() > 767 && $(this).outerHeight() > maxHeight)
                                maxHeight = $(this).outerHeight();
                        });

                        that.each(function() {
                            $(this).css({
                                minHeight: maxHeight
                            });
                        });

                    }

                    $(window).bind('resize', function() {
                        resize();
                    });
                    setTimeout(function() {
                        resize();
                    }, 200);
                    setTimeout(function() {
                        resize();
                    }, 500);
                    setTimeout(function() {
                        resize();
                    }, 800);
                }

                $('.equal-columns').each(function() {
                    $(this).kitgreen_equlize({
                        child: '> [class*=col-]'
                    });
                });
            },


            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Enable masonry grid for blog
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            blogMasonry: function() {
                if (typeof($.fn.isotope) == 'undefined' || typeof($.fn.imagesLoaded) == 'undefined') return;
                var $container = $('.masonry-container.kitgreen-portfolio-holder');

                // initialize Masonry after all images have loaded  
                $container.imagesLoaded(function() {
                    $container.isotope({
                        gutter: 0,
                        isOriginLeft: !$('body').hasClass('rtl'),
                        itemSelector: '.item_portfolio',
                        hiddenStyle: {
                            opacity: 0
                            /* , transform: 'scale(0.001)' -- disabled scaling */
                        },
                        visibleStyle: {
                            opacity: 1
                            /* , transform: 'scale(1)' -- disabled scaling */
                        },
                        transitionDuration: "0.8s",

                    });
                });

                $('.masonry-filter').on('click', 'a', function(e) {
                    e.preventDefault();
                    $('.masonry-filter').find('.filter-active').removeClass('filter-active');
                    $(this).addClass('filter-active');
                    var filterValue = $(this).attr('data-filter');
                    $container.isotope({
                        filter: filterValue
                    });
                });


            },
            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Load more button for blog shortcode
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */

            blogLoadMore: function() {

                $('.kitgreen-blog-load-more').on('click', function(e) {
                    e.preventDefault();

                    var $this = $(this),
                        holder = $this.parent().siblings('.kitgreen-blog-holder'),
                        atts = holder.data('atts'),
                        paged = holder.data('paged');
                    var $loaded = $('.posts-loaded');
                    $this.addClass('loading');

                    $.ajax({
                        url: MS_Ajax.ajaxurl,
                        data: {
                            atts: atts,
                            paged: paged,
                            action: 'kitgreen_get_blog_shortcode'
                        },
                        dataType: 'json',
                        method: 'POST',
                        success: function(data) {
                            if (data.items) {

                                // initialize Masonry after all images have loaded  
                                var items = $(data.items);

                                holder.append(items).isotope('appended', items);
                                holder.imagesLoaded().progress(function() {
                                    holder.isotope('layout');

                                });
                                holder.data('paged', paged + 1);
                            }
                            if (data.status == 'no-more-posts') {
                                $this.hide();
                                $loaded.addClass('active');
                            }

                        },
                        error: function(data) {
                            console.log('ajax error');
                        },
                        complete: function() {
                            $this.removeClass('loading');
                        },
                    });

                });

            },

            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Load more button for products shortcode
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            productsLoadMore: function() {

                var process = false,
                    intervalID;

                $('.kitgreen-products-element').each(function() {
                    var $this = $(this),
                        cache = [],
                        inner = $this.find('.kitgreen-products-holder');

                    if (!inner.hasClass('pagination-arrows') && !inner.hasClass('pagination-more-btn')) return;

                    cache[1] = {
                        items: inner.html(),
                        status: 'have-posts'
                    };

                    $this.on('recalc', function() {
                        calc();
                    });

                    // if( inner.hasClass('pagination-arrows') ) {
                    //$(window).resize(function() {
                    //calc();
                    //});
                    //}

                    var calc = function() {
                        var height = inner.outerHeight();
                        $this.stop().css({
                            height: height
                        });
                    };

                    // sticky buttons

                    var body = $('body'),
                        btnWrap = $this.find('.products-footer'),
                        btnLeft = btnWrap.find('.kitgreen-products-load-prev'),
                        btnRight = btnWrap.find('.kitgreen-products-load-next'),
                        loadWrapp = $this.find('.kitgreen-products-loader'),
                        scrollTop,
                        holderTop,
                        btnOffsetContainer,
                        holderBottom,
                        holderHeight,
                        btnsHeight,
                        offsetArrow = 50,
                        offset,
                        windowWidth;

                    if (body.hasClass('rtl')) {
                        btnLeft = btnRight;
                        btnRight = btnWrap.find('.kitgreen-products-load-prev');
                    }

                    $(window).scroll(function() {
                        buttonsPos();
                    });

                    function buttonsPos() {

                        offset = $(window).height() / 2;

                        windowWidth = $(window).outerWidth(true) + 17;

                        // length scroll
                        scrollTop = $(window).scrollTop();

                        // distance from the top to the element
                        holderTop = $this.offset().top - offset;

                        // offset left to button
                        btnOffsetContainer = $this.offset().left - offsetArrow;

                        // height of buttons
                        btnsHeight = btnLeft.outerHeight();

                        // height of elements
                        holderHeight = $this.height() - 50 - btnsHeight;

                        // and height of element
                        holderBottom = holderTop + holderHeight;

                        if (windowWidth <= 1047 && windowWidth >= 992 || windowWidth <= 825 && windowWidth >= 768) {
                            btnOffsetContainer = btnOffsetContainer + 18;
                        }

                        if (windowWidth < 768 || body.hasClass('wrapper-boxed') || body.hasClass('wrapper-boxed-small') || $('.main-header').hasClass('header-vertical')) {
                            btnOffsetContainer = btnOffsetContainer + 51;
                        }


                        btnLeft.css({
                            'left': btnOffsetContainer + 'px'
                        });

                        // Right arrow position for vertical header
                        if ($('.main-header').hasClass('header-vertical') && !body.hasClass('rtl')) {
                            btnOffsetContainer -= $('.main-header').outerWidth();
                        } else if ($('.main-header').hasClass('header-vertical') && body.hasClass('rtl')) {
                            btnOffsetContainer += $('.main-header').outerWidth();
                        }

                        btnRight.css({
                            'right': btnOffsetContainer + 'px'
                        });


                        if (scrollTop < holderTop || scrollTop > holderBottom) {
                            btnWrap.removeClass('show-arrow');
                            loadWrapp.addClass('hidden-loader');
                        } else {
                            btnWrap.addClass('show-arrow');
                            loadWrapp.removeClass('hidden-loader');
                        }

                    };

                    $this.find('.kitgreen-products-load-more').on('click', function(e) {
                        e.preventDefault();

                        if (process) return;
                        process = true;
                        
                        var $this = $(this),
                            holder = $this.parent().siblings('.kitgreen-products-holder'),
                            atts = holder.data('atts'),
                            paged = holder.data('paged');

                        paged++;

                        loadProducts(atts, paged, holder, $this, [], function(data) {
                            if (data.items) {
                                if (holder.hasClass('grid-masonry')) {
                                    isotopeAppend(holder, data.items);
                                } else {
                                    holder.append(data.items);
                                }

                                holder.data('paged', paged);
                            }

                            if (data.status == 'no-more-posts') {
                                $this.hide();
                                $('.loaded-all').show();
                            }
                        });

                    });

                    $this.find('.kitgreen-products-load-prev, .kitgreen-products-load-next').on('click', function(e) {
                        e.preventDefault();

                        if (process || $(this).hasClass('disabled')) return;
                        process = true;

                        clearInterval(intervalID);

                        var $this = $(this),
                            holder = $this.parent().siblings('.kitgreen-products-holder'),
                            next = $this.parent().find('.kitgreen-products-load-next'),
                            prev = $this.parent().find('.kitgreen-products-load-prev'),
                            atts = holder.data('atts'),
                            paged = holder.attr('data-paged');
                        if ($this.hasClass('kitgreen-products-load-prev')) {
                            if (paged < 2) return;
                            paged = paged - 2;
                        }

                        paged++;

                        loadProducts(atts, paged, holder, $this, cache, function(data) {
                            holder.addClass('kitgreen-animated-products');

                            if (data.items) {
                                holder.html(data.items).attr('data-paged', paged);
                            }

                            if ($(window).width() < 768) {
                                $('html, body').stop().animate({
                                    scrollTop: holder.offset().top - 150
                                }, 400);
                            }


                            var iter = 0;
                            intervalID = setInterval(function() {
                                holder.find('.tb-products-grid').eq(iter).addClass('kitgreen-animated');
                                iter++;
                            }, 100);

                            if (paged > 1) {
                                prev.removeClass('disabled');
                            } else {
                                prev.addClass('disabled');
                            }

                            if (data.status == 'no-more-posts') {
                                next.addClass('disabled');
                            } else {
                                next.removeClass('disabled');
                            }
                        });

                    });
                });

                var loadProducts = function(atts, paged, holder, btn, cache, callback) {

                    if (cache[paged]) {
                        holder.addClass('loading');
                        setTimeout(function() {
                            callback(cache[paged]);
                            holder.removeClass('loading');
                            process = false;
                        }, 300);
                        return;
                    }

                    holder.addClass('loading').parent().addClass('element-loading');

                    btn.addClass('loading');

                    $.ajax({
                        url: MS_Ajax.ajaxurl,
                        data: {
                            atts: atts,
                            paged: paged,
                            action: 'kitgreen_get_products_shortcode'
                        },
                        dataType: 'json',
                        method: 'POST',
                        success: function(data) {
                            cache[paged] = data;
                            callback(data);
                        },
                        error: function(data) {
                            console.log('ajax error');
                        },
                        complete: function() {
                            holder.removeClass('loading').parent().removeClass('element-loading');
                            btn.removeClass('loading');
                            process = false; 

                        },
                    });
                };
                var isotopeAppend = function(el, items) {
                    // initialize Masonry after all images have loaded  
                    var items = $(items);
                    el.append(items).isotope('appended', items);
                    el.isotope('layout');
                    setTimeout(function() {
                        el.isotope('layout');
                    }, 100);
                    el.imagesLoaded().progress(function() {
                        el.isotope('layout');
                    });
                };

            },


            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Products tabs element AJAX loading
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            productsTabs: function() {


                var process = false;

                $('.kitgreen-products-tabs , .kitgreen-kitchen-tabs-portfolio').each(function() {
                    var $this = $(this),
                        $inner = $this.find('.kitgreen-tab-content'),
                        cache = [];

                    if ($inner.find('.owl-carousel').length < 1) {
                        cache[0] = {
                            html: $inner.html()
                        };
                    }

                    $this.find('.products-tabs-title li').on('click', function(e) {
                        e.preventDefault();

                        var $this = $(this),
                            atts = $this.data('atts'),
                            index = $this.index();

                        if (process || $this.hasClass('active-tab-title')) return;
                        process = true;

                        loadTab(atts, index, $inner, $this, cache, function(data) {
                            if (data.html) {
                                $inner.html(data.html);
                                kitgreenThemeModule.shopMasonry();
                                kitgreenThemeModule.productsLoadMore();
                            }
                        });

                    });
                    
                    $this.find('.kitchen-tabs-title li').on('click', function(e) {
                        e.preventDefault();

                        var $this = $(this),
                            atts = $this.data('atts'),
                            index = $this.index();

                        if (process || $this.hasClass('active-tab-title')) return;
                        process = true;

                         loadTab2(atts, index, $inner, $this, cache, function(data) {
                            var getSliderSettings  = {
                                slidesToScroll: 1,
                                draggable: false,
                                prevArrow: '<span class="lnr lnr-chevron-left"></span>',
                                nextArrow: '<span class="lnr lnr-chevron-right"></span>',
                            }; 
                            if (data.html) {
                              
                               $('.kitgreen-tab-portfolio').slick('unslick'); /* ONLY remove the classes and handlers added on initialize */
                                $inner.html(data.html);
                                $('.image_before_after').imagesLoaded( function() {
                                        $('.image_before_after').twentytwenty();
                               });
                                $('.kitgreen-tab-portfolio').slick(getSliderSettings); /* Initialize the slick again */
                            
                               
                                
                            }
                        });

                    });

                    var $nav = $this.find('.tabs-navigation-wrapper'),
                        $subList = $nav.find('ul'),
                        time = 300;

                    $nav.on('click', '.open-title-menu', function() {
                            var $btn = $(this);

                            if ($subList.hasClass('list-shown')) {
                                $btn.removeClass('toggle-active');
                                $subList.removeClass('list-shown');
                            } else {
                                $btn.addClass('toggle-active');
                                $subList.addClass('list-shown');
                                setTimeout(function() {
                                    $('body').one('click', function(e) {
                                        var target = e.target;
                                        if (!$(target).is('.tabs-navigation-wrapper') && !$(target).parents().is('.tabs-navigation-wrapper')) {
                                            $btn.removeClass('toggle-active');
                                            $subList.removeClass('list-shown');
                                            return false;
                                        }
                                    });
                                }, 10);
                            }

                        })
                        .on('click', 'li', function() {
                            var $btn = $nav.find('.open-title-menu'),
                                text = $(this).text();

                            if ($subList.hasClass('list-shown')) {
                                $btn.removeClass('toggle-active').text(text);
                                $subList.removeClass('list-shown');
                            }
                        });

                });

                var loadTab = function(atts, index, holder, btn, cache, callback) {

                    btn.parent().find('.active-tab-title').removeClass('active-tab-title');
                    btn.addClass('active-tab-title')

                    if (cache[index]) {
                        holder.addClass('loading');
                        setTimeout(function() {
                            callback(cache[index]);
                            holder.removeClass('loading');
                            process = false;
                        }, 300);
                        return;
                    }

                    holder.addClass('loading').parent().addClass('element-loading');

                    btn.addClass('loading');

                    $.ajax({
                        url: MS_Ajax.ajaxurl,
                        data: {
                            atts: atts,
                            action: 'kitgreen_get_products_tab_shortcode'
                        },
                        dataType: 'json',
                        method: 'POST',
                        success: function(data) {
                            cache[index] = data;
                            callback(data);
                        },
                        error: function(data) {
                            console.log('ajax error');
                        },
                        complete: function() {
                            holder.removeClass('loading').parent().removeClass('element-loading');
                            btn.removeClass('loading');
                            process = false;
                        },
                    });
                };

                  var loadTab2 = function(atts, index, holder, btn, cache, callback) {

                    btn.parent().find('.active-tab-title').removeClass('active-tab-title');
                    btn.addClass('active-tab-title')
                    
                    if (cache[index]) {
                        holder.addClass('loading');
                        setTimeout(function() {
                            callback(cache[index]);
                            holder.removeClass('loading');
                            process = false;
                        }, 300);

                        return;
                    }

                    holder.addClass('loading').parent().addClass('element-loading');

                    btn.addClass('loading');

                    $.ajax({
                        url: MS_Ajax.ajaxurl,
                        data: {
                            atts: atts,
                            action: 'kitgreen_get_kitchen_tab_shortcode'
                        },
                        dataType: 'json',
                        method: 'POST',
                        success: function(data) {
                            cache[index] = data;
                            callback(data);
                        },
                        error: function(data) {
                            console.log('ajax error');
                        },
                        complete: function() {
                               setTimeout(function() {
                                 holder.removeClass('loading').parent().removeClass('element-loading');
                               }, 800);
                            
                            btn.removeClass('loading');
                            process = false;

                        },
                    });
                };
            },

            galleryIlightbox: function() {
                         if (jQuery(".masonry-container").length) {
                            jQuery("a.open_popup").iLightBox({
                               skin: "metro-black",
                               path: "horizontal",
                               type: "inline, video, image",
                               maxScale: 1,
                               controls: {
                                  slideshow: true,
                                  arrows: true
                               },
                               overlay: {
                                  opacity: "0.7"
                               }
                            });
                         }
                      },
             getSliderSettings: function() {
                   $('.kitgreen-tab-portfolio').slick({
                        slidesToScroll: 1,
                        draggable: false,
                        prevArrow: '<span class="lnr lnr-chevron-left"></span>',
                        nextArrow: '<span class="lnr lnr-chevron-right"></span>',
                     });  
             },         
            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Load more button for portfolio shortcode
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            portfolioLoadMore: function() {
                var waypoint = $('.kitgreen-portfolio-load-more.load-on-scroll').waypoint(function() {
                        $('.kitgreen-portfolio-load-more.load-on-scroll').trigger('click');
                    }, {
                        offset: '100%'
                    }),
                    process = false;

                $('.kitgreen-portfolio-load-more').on('click', function(e) {
                    e.preventDefault();

                    if (process) return;

                    process = true;

                    var $this = $(this),
                        holder = $this.parent().parent().find('.kitgreen-portfolio-holder'),
                        source = holder.data('source'),
                        action = 'kitgreen_get_portfolio_' + source,
                        ajaxurl = MS_Ajax.ajaxurl,
                        dataType = 'json',
                        method = 'POST',
                        timeout,
                        atts = holder.data('atts'),
                        paged = holder.data('paged');

                    $this.addClass('loading');

                    var data = {
                        atts: atts,
                        paged: paged,
                        action: action
                    };

                    if (source == 'main_loop') {
                        ajaxurl = $(this).attr('href');
                        method = 'GET';
                        data = {};
                    }


                    $.ajax({
                        url: ajaxurl,
                        data: data,
                        dataType: dataType,
                        method: method,
                        success: function(data) {

                            var items = $(data.items);

                            if (items) {
                                if (holder.hasClass('masonry-container')) {
                                    // initialize Masonry after all images have loaded  
                                    holder.append(items).isotope('appended', items);
                                    holder.imagesLoaded().progress(function() {
                                        holder.isotope('layout');

                                        clearTimeout(timeout);

                                        timeout = setTimeout(function() {
                                            $('.kitgreen-portfolio-load-more.load-on-scroll').waypoint('destroy');
                                            waypoint = $('.kitgreen-portfolio-load-more.load-on-scroll').waypoint(function() {
                                                $('.kitgreen-portfolio-load-more.load-on-scroll').trigger('click');
                                            }, {
                                                offset: '100%'
                                            });
                                        }, 1000);
                                    });
                                } else {
                                    holder.append(items);
                                }

                                holder.data('paged', paged + 1);

                                $this.attr('href', data.nextPage);
                            }

                            //kitgreenThemeModule.mfpPopup();

                            if (data.status == 'no-more-posts') {
                                $this.hide();
                            }

                        },
                        error: function(data) {
                            console.log('ajax error');
                        },
                        complete: function() {
                            $this.removeClass('loading');
                            process = false;
                            kitgreenThemeModule.galleryIlightbox();
                        },
                    });

                });

            },
            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Enable masonry grid for shop isotope type
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            shopMasonry: function() {
                if (typeof($.fn.isotope) == 'undefined' || typeof($.fn.imagesLoaded) == 'undefined') return;
                var $container = $('.elements-grid.grid-masonry');
                // initialize Masonry after all images have loaded  
                $container.imagesLoaded(function() {
                    $container.isotope({
                        isOriginLeft: !$('body').hasClass('rtl'),
                        itemSelector: '.category-grid-item, .product-grid-item',
                    });
                });
                
         
                    var el = $('.kitgreen-products-holder.jws-masonry');
                            el.each(function(i, val) {
                                var _option = $(this).data('masonry');
                    
                                if (_option !== undefined) {
                                    var _selector = _option.selector,
                                        _width = _option.columnWidth,
                                        _layout = _option.layoutMode;
                    
                                    $(this).imagesLoaded(function() {
                                        $(val).isotope({
                                            layoutMode: _layout,
                                            itemSelector: _selector,
                                            percentPosition: true,
                                            masonry: {
                                                columnWidth: _width
                                            }
                                        });
                                    });
                    
                                }
                            });
                        
                // Categories masonry
                $(window).resize(function() {
                    var $catsContainer = $('.categories-masonry');
                    var colWidth = ($catsContainer.hasClass('categories-style-masonry')) ? '.category-grid-item' : '.col-md-3.category-grid-item';
                    $catsContainer.imagesLoaded(function() {
                        $catsContainer.isotope({
                            resizable: false,
                            isOriginLeft: !$('body').hasClass('rtl'),
                            layoutMode: 'packery',
                            packery: {
                                gutter: 0,
                                columnWidth: colWidth
                            },
                            itemSelector: '.category-grid-item',
                            // masonry: {
                            // gutter: 0
                            // }
                        });
                    });
                });

            },



            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Product thumbnail images & photo swipe gallery
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            productImages: function() {
                var currentImage,
                    mainImage = $('.woocommerce-main-image'),
                    thumbs = $('.product-images .thumbnails'),
                    currentClass = 'current-image',
                    gallery = $('.photoswipe-images'),
                    galleryType = 'photo-swipe'; // magnific photo-swipe

                thumbs.addClass('thumbnails-ready');

                mainImage.on('click', function(e) {
                    e.preventDefault();

                    currentImage = $(this).attr('href');

                    if (galleryType == 'magnific') {
                        $.magnificPopup.open({
                            type: 'image',
                            image: {
                                verticalFit: false
                            },
                            items: getProductItems(),
                            gallery: {
                                enabled: true,
                                navigateByImgClick: false
                            },
                        }, 0);
                    }

                    if (galleryType == 'photo-swipe') {

                        // build items array
                        var items = getProductItems();

                        callPhotoSwipe(0, items, mainImage);

                    }

                });

                thumbs.on('click', '.image-link', function(e) {
                    e.preventDefault();

                    if (thumbs.hasClass('thumbnails-large')) {
                        var index = $(e.currentTarget).index() + 1;
                        var items = getProductItems();
                        callPhotoSwipe(index, items, $(e.currentTarget));
                        return;
                    }

                    var href = $(this).attr('href'),
                        src = $(this).attr('data-single-image'),
                        width = $(this).attr('data-width'),
                        height = $(this).attr('data-height'),
                        title = $(this).attr('title');

                    thumbs.find('.' + currentClass).removeClass(currentClass);
                    $(this).addClass(currentClass);

                    if (mainImage.find('img').attr('src') == src) return;

                    mainImage.addClass('loading-image').attr('href', href).find('img').attr('src', src).attr('srcset', src).one('load', function() {
                        mainImage.removeClass('loading-image').data('width', width).data('height', height).attr('title', title);
                    });

                });

                gallery.each(function() {
                    var $this = $(this);
                    $this.on('click', 'a', function(e) {
                        e.preventDefault();
                        var index = $(e.currentTarget).data('index') - 1;
                        var items = getGalleryItems($this, []);
                        callPhotoSwipe(index, items, $(e.currentTarget));
                    });
                })

                var callPhotoSwipe = function(index, items, $target) {
                    var pswpElement = document.querySelectorAll('.pswp')[0];

                    if ($('body').hasClass('rtl')) {
                        index = items.length - index - 1;
                        items = items.reverse();
                    }

                    // define options (if needed)
                    var options = {
                        // optionName: 'option value'
                        // for example:
                        index: index, // start at first slide
                        getThumbBoundsFn: function(index) {

                            // // get window scroll Y
                            // var pageYScroll = window.pageYOffset || document.documentElement.scrollTop; 
                            // // optionally get horizontal scroll

                            // // get position of element relative to viewport
                            // var rect = $target.offset(); 

                            // // w = width
                            // return {x:rect.left, y:rect.top + pageYScroll, w:rect.width};

                        }
                    };

                    // Initializes and opens PhotoSwipe
                    var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
                    gallery.init();
                };

                var getProductItems = function() {
                    var src = mainImage.attr('href'),
                        width = mainImage.data('width'),
                        height = mainImage.data('height'),
                        items = getGalleryItems(thumbs, [{
                            src: src,
                            w: width,
                            h: height,
                            title: (MS_Ajax.product_images_captions == 'yes') ? mainImage.attr('title') : false
                        }]);

                    return items;
                };

                var getGalleryItems = function($gallery, items) {
                    var src, width, height, title;

                    $gallery.find('a').each(function() {
                        src = $(this).attr('href');
                        width = $(this).data('width');
                        height = $(this).data('height');
                        title = $(this).attr('title');
                        if (!isItemInArray(items, src)) {
                            items.push({
                                src: src,
                                w: width,
                                h: height,
                                title: (MS_Ajax.product_images_captions == 'yes') ? title : false
                            });
                        }
                    });

                    return items;
                };

                var isItemInArray = function(items, src) {
                    var i;
                    for (i = 0; i < items.length; i++) {
                        if (items[i].src == src) {
                            return true;
                        }
                    }

                    return false;
                };
            },

            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Banner hover effect with jquery panr
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            bannersHover: function() {
                $(".promo-banner.hover-4").panr({
                    sensitivity: 20,
                    scale: false,
                    scaleOnHover: true,
                    scaleTo: 1.15,
                    scaleDuration: .34,
                    panY: true,
                    panX: true,
                    panDuration: 0.5,
                    resetPanOnMouseLeave: true
                });
            },


            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Scroll top button
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            scrollTop: function() {
                //Check to see if the window is top if not then display button
                $(window).scroll(function() {
                    if ($(this).scrollTop() > 100) {
                        $('.scrollToTop').addClass('button-show');
                    } else {
                        $('.scrollToTop').removeClass('button-show');
                    }
                });

                //Click event to scroll to top
                $('.scrollToTop').click(function() {
                    $('html, body').animate({
                        scrollTop: 0
                    }, 800);
                    return false;
                });
            },


            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Sticky footer: margin bottom for main wrapper
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            stickyFooter: function() {

                if (!$('.footer-main').hasClass('sticky-footer-on') || $(window).width() < 991) return;

                var $footer = $('.footer-main'),
                    $footerContent = $footer.find('#footer-jws'),
                    footerHeight = $footer.outerHeight(),
                    $page = $('.main-content'),
                    $doc = $(document),
                    $window = $(window),
                    docHeight = $doc.outerHeight(),
                    windowHeight = $window.outerHeight(),
                    position,
                    bottomSpace;
                //opacity;

                var footerOffset = function() {
                    $page.css({
                        marginBottom: $footer.outerHeight()
                    })
                };

                var footerEffect = function() {
                    position = $doc.scrollTop();
                    docHeight = $doc.outerHeight();
                    windowHeight = $window.outerHeight();
                    bottomSpace = (docHeight - (position + windowHeight));
                    footerHeight = $footer.outerHeight();
                    //opacity         = parseFloat( (bottomSpace ) / footerHeight).toFixed(5);

                    // If scrolled to footer
                    if (bottomSpace > footerHeight) return;


                };

                $window.on('resize', footerOffset);
                $window.on('scroll', footerEffect);

                $footer.imagesLoaded(function() {
                    footerOffset();
                });

            },




            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * init shop page JS functions
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            shopPageInit: function() {
                this.shopMasonry();
                //this.filtersArea();
                this.ajaxSearch();
                this.btnsToolTips();
                this.filterDropdowns();
                this.categoriesMenuBtns();
                this.categoriesAccordion();
                this.woocommercePriceSlider();
                this.updateCartWidgetFromLocalStorage(); // refresh cart in sidebar
                this.nanoScroller();

                $('.woocommerce-ordering').on('change', 'select.orderby', function() {
                    $(this).closest('form').find('[name="_pjax"]').remove();
                    $(this).closest('form').submit();
                });
            },



            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Sale final date countdown
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            countDownTimer: function() {

                $('.kitgreen-timer').each(function() {
                    $(this).countdown($(this).data('end-date'), function(event) {
                        $(this).html(event.strftime('' +
                            '<span class="countdown-days">%-D <span>' + MS_Ajax.countdown_days + '</span></span> ' +
                            '<span class="countdown-hours">%H <span>' + MS_Ajax.countdown_hours + '</span></span> ' +
                            '<span class="countdown-min">%M <span>' + MS_Ajax.countdown_mins + '</span></span> ' +
                            '<span class="countdown-sec">%S <span>' + MS_Ajax.countdown_sec + '</span></span>'));
                    });
                });

            },


            /**
             *-------------------------------------------------------------------------------------------------------------------------------------------
             * Remove click delay on mobile
             *-------------------------------------------------------------------------------------------------------------------------------------------
             */
            mobileFastclick: function() {

                if ('addEventListener' in document) {
                    document.addEventListener('DOMContentLoaded', function() {
                        FastClick.attach(document.body);
                    }, false);
                }

            },


        }
    }());

})(jQuery);


jQuery(document).ready(function() {

    kitgreenThemeModule.init();


});
;(function($) {

    'use strict';

    if (!$.nmThemeExtensions)
        $.nmThemeExtensions = {};


    function NmTheme() {
        var self = this;

        // Page width "breakpoints"
        //self.BREAKPOINT_SMALL = 0;
        //self.BREAKPOINT_MEDIUM = 0;
        self.BREAKPOINT_LARGE = 864;

        // CSS Classes
        self.classWidgetPanelOpen = 'widget-panel-open';

        // Page elements
        self.$window = $(window);
        self.$document = $(document);
        self.$html = $('html');
        self.$body = $('body');



        // Page overlays
        self.$widgetPanelOverlay = $('#jws-widget-panel-overlay');

        // Header
        self.$header = $('#jws-header');

        // Mobile menu
        self.$shopBrowseWrap = $('.bt-product-items');
        // Widget panel
        self.$widgetPanel = $('.jws-mini-cart');
        self.widgetPanelAnimSpeed = 250;

        // Slide panels animation speed
        self.panelsAnimSpeed = 200;

        // Initialize scripts
        self.init();
        self.bind();

    };


    NmTheme.prototype = {



        /**
         *	Initialize
         */
        init: function() {
            var self = this;
            // Init widget panel
            self.widgetPanelPrep();

            // Load extension scripts
            self.loadExtension();



            // "Add to cart" redirect: Show cart panel
            if (self.$body.hasClass('jws-added-to-cart')) {
                self.$body.removeClass('jws-added-to-cart')

                self.$window.load(function() {
                    // Is widget/cart panel enabled?
                    if (self.$widgetPanel.length) {
                        // Show cart panel
                        self.widgetPanelShow(true); // Args: showLoader
                        // Hide cart panel "loader" overlay
                        setTimeout(function() {
                            self.widgetPanelCartHideLoader();
                        }, 1000);
                    }
                });
            }
        },
        /**
         *	Extensions: Load scripts
         */
        loadExtension: function() {
            var self = this;

            if ($.nmThemeExtensions.singleProduct) {
                $.nmThemeExtensions.singleProduct.call(self);
            }
            // Shop scripts
            if ($.nmThemeExtensions.add_to_cart) {
                $.nmThemeExtensions.add_to_cart.call(self);
            }
            // Load Pagination scripts
            if ($.nmThemeExtensions.infload) {
                $.nmThemeExtensions.infload.call(self);
            }
            if ($.nmThemeExtensions.cart) {
                $.nmThemeExtensions.cart.call(self);
            }

        },
        /**
         *  Helper: Add/update a key-value pair in the URL query parameters 
         */
        updateUrlParameter: function(uri, key, value) {
            // Remove #hash before operating on the uri
            var i = uri.indexOf('#'),
                hash = i === -1 ? '' : uri.substr(i);
            uri = (i === -1) ? uri : uri.substr(0, i);

            var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i"),
                separator = (uri.indexOf('?') !== -1) ? "&" : "?";

            if (uri.match(re)) {
                uri = uri.replace(re, '$1' + key + "=" + value + '$2');
            } else {
                uri = uri + separator + key + "=" + value;
            }

            return uri + hash; // Append #hash
        },
        /**
         *	Bind scripts
         */
        bind: function() {
            var self = this;




            /* Bind: Page overlay */
            $('#jws-page-overlay, #jws-widget-panel-overlay , .close-cart ').bind('click', function() {
                var $this = $(this);

                self.widgetPanelHide();


                $this.addClass('fade-out');
                setTimeout(function() {
                    $this.removeClass('show fade-out');
                }, self.panelsAnimSpeed);
            });

            /* Bind: Widget panel */
            if (self.$widgetPanel.length) {
                self.widgetPanelBind();
            }
        },




        /**
         *	Widget panel: Prepare
         */
        widgetPanelPrep: function() {
            var self = this;


            // Cart panel: Set Ajax state
            self.cartPanelAjax = null;

            // Cart panel: Bind quantity-input buttons
            self.quantityInputsBindButtons(self.$widgetPanel);


            // Quantity inputs: Bind "blur" event
            self.$widgetPanel.on('blur', 'input.qty', function() {
                var $quantityInput = $(this),
                    currentVal = parseFloat($quantityInput.val()),
                    max = parseFloat($quantityInput.attr('max'));

                // Validate input values
                if (currentVal === '' || currentVal === 'NaN') {
                    currentVal = 0;
                }
                if (max === 'NaN') {
                    max = '';
                }

                // Make sure the value is not higher than the max value
                if (currentVal > max) {
                    $quantityInput.val(max);
                    currentVal = max;
                };

                // Is the quantity value more than 0?
                if (currentVal > 0) {
                    self.widgetPanelCartUpdate($quantityInput);
                }
            });

            // Quantity inputs: Bind "nm_qty_change" event
            self.$document.on('nm_qty_change', function(event, quantityInput) {
                // Is the widget-panel open?

                self.widgetPanelCartUpdate($(quantityInput));

            });
        },

        /**
         *	Widget panel: Bind
         */
        widgetPanelBind: function() {
            var self = this;



            /* Bind: "Cart" buttons */
            $('.cart-contents  ').bind('click', function(e) {
                e.preventDefault();
                    self.$body.removeClass('.open-mobile-menu');
                    self.widgetPanelShow();
                
            });

            /* Bind: "Close" button */
            $('.close-cart').bind('click.close-cart', function(e) {
                e.preventDefault();
                $('#jws-widget-panel-overlay').trigger('click');
            });

            /* Bind: "Continue shopping" button */
            self.$widgetPanel.on('click.close-cart', '#jws-cart-panel-continue', function(e) {
                e.preventDefault();
                $('#jws-widget-panel-overlay').trigger('click');
            });

            /* Bind: Cart panel - Remove product */
            self.$widgetPanel.on('click', '#jws-cart-panel .cart_list .remove', function(e) {
                e.preventDefault();
                // Is an Ajax request already running?

                self.widgetPanelCartRemoveProduct(this);

            });
        },

        /**
         *	Widget panel: Show
         */
        widgetPanelShow: function(showLoader) {
            var self = this;

            if (showLoader) {
                self.widgetPanelCartShowLoader();
            }

            self.$body.addClass('widget-panel-opening ' + self.classWidgetPanelOpen);
            self.$widgetPanelOverlay.addClass('show');

            setTimeout(function() {
                self.$body.removeClass('widget-panel-opening');
            }, self.widgetPanelAnimSpeed);
        },


        /**
         *	Widget panel: Hide
         */
        widgetPanelHide: function() {
            var self = this;

            self.$body.addClass('widget-panel-closing');
            self.$body.removeClass(self.classWidgetPanelOpen);

            setTimeout(function() {
                self.$body.removeClass('widget-panel-closing');
            }, self.widgetPanelAnimSpeed);
        },


        /**
         *	Widget panel: Cart - Show loader
         */
        widgetPanelCartShowLoader: function() {
            $('#jws-cart-panel-loader').addClass('show');
        },


        /**
         *	Widget panel: Cart - Hide loader
         */
        widgetPanelCartHideLoader: function() {
            var self = this;

            $('#jws-cart-panel-loader').addClass('fade-out');
            setTimeout(function() {
                $('#jws-cart-panel-loader').removeClass('fade-out show');
            }, 200);
        },

        /**
         *	Widget panel: Cart - Remove product
         */
        widgetPanelCartRemoveProduct: function(button) {
            var self = this,
                $button = $(button),
                $itemLi = $button.closest('li'),
                $itemUl = $itemLi.parent('ul'),
                cartItemKey = $button.data('cart-item-key');

            // Show thumbnail loader
            $itemLi.closest('li').addClass('loading');

            self.cartPanelAjax = $.ajax({
                type: 'POST',
                url: MS_Ajax.ajaxurl,
                data: {
                    action: 'nm_cart_panel_remove_product',
                    cart_item_key: cartItemKey
                },
                dataType: 'json',
                // Note: Disabling these to avoid "origin policy" AJAX error in some cases
                //cache: false,
                //headers: {'cache-control': 'no-cache'},
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    console.log('NM: AJAX error - widgetPanelCartRemoveProduct() - ' + errorThrown);
                    $itemLi.closest('li').removeClass('loading'); // Hide thumbnail loader
                },
                complete: function(response) {
                    self.cartPanelAjax = null; // Reset Ajax state

                    var json = response.responseJSON;

                    if (json && json.status === '1') {
                        // Fade-out cart item
                        $itemLi.css({
                            '-webkit-transition': '0.2s opacity ease',
                            transition: '0.2s opacity ease',
                            opacity: '0'
                        });

                        setTimeout(function() {
                            // Slide-up cart item
                            $itemLi.css('display', 'block').slideUp(150, function() {
                                $itemLi.remove();

                                // Show "cart empty" elements?
                                var $cartLis = $itemUl.children('li');
                                if ($cartLis.length == 1) {
                                    $('#jws-cart-panel').addClass('jws-cart-panel-empty');
                                }

                                // Replace cart/shop fragments
                                self.shopReplaceFragments(json.fragments);

                                // Trigger "added_to_cart" event to make sure the HTML5 "sessionStorage" fragment values are updated
                                self.$body.trigger('added_to_cart', [json.fragments, json.cart_hash]);
                            });
                        }, 160);
                    } else {
                        console.log("NM: Couldn't remove product from cart");
                    }
                }
            });
        },


        /**
         *	Widget panel: Cart - Update quantity
         */
        widgetPanelCartUpdate: function($quantityInput) {
            var self = this;

            // Is an Ajax request already running?
            if (self.cartPanelAjax) {
                self.cartPanelAjax.abort(); // Abort current Ajax request
            }

            // Show thumbnail loader
            $quantityInput.closest('li').addClass('loading');

            // Ajax data
            var data = {
                action: 'nm_cart_panel_update'
            };
            data[$quantityInput.attr('name')] = $quantityInput.val();

            self.cartPanelAjax = $.ajax({
                type: 'POST',
                url: MS_Ajax.ajaxurl,
                data: data,
                dataType: 'json',
                complete: function(response) {
                    //self.cartPanelAjax = null; // Reset Ajax state

                    var json = response.responseJSON;

                    if (json && json.status === '1') {
                        self.shopReplaceFragments(json.fragments); // Replace cart/shop fragments
                    }

                    // Hide any visible thumbnail loaders
                    $('#jws-cart-panel .cart_list').children('.loading').removeClass('loading');
                }
            });
        },


        /**
         *	Shop: Replace fragments
         */
        shopReplaceFragments: function(fragments) {
            var $fragment;
            $.each(fragments, function(selector, fragment) {
                $fragment = $(fragment);
                if ($fragment.length) {
                    $(selector).replaceWith($fragment);
                }
            });
        },


        /**
         *	Quantity inputs: Bind buttons
         */
        quantityInputsBindButtons: function($container) {
            var self = this;

            // Add buttons
            // Note: Added these to the "../global/quantity-input.php" template instead (required for the Ajax Cart)
            //$container.find('.quantity').append('<div class="jws-qty-plus jws-font jws-font-media-play rotate-270"></div>').prepend('<div class="jws-qty-minus jws-font jws-font-media-play rotate-90"></div>');

            /* 
             *	Bind buttons click event
             *	Note: Modified code from WooCommerce core (v2.2.6)
             */
            $container.off('click.nmQty').on('click.nmQty', '.jws-qty-plus, .jws-qty-minus', function() {
                // Get elements and values
                var $this = $(this),
                    $qty = $this.closest('.quantity').find('.qty'),
                    currentVal = parseFloat($qty.val()),
                    max = parseFloat($qty.attr('max')),
                    min = parseFloat($qty.attr('min')),
                    step = $qty.attr('step');

                // Format values
                if (!currentVal || currentVal === '' || currentVal === 'NaN') currentVal = 0;
                if (max === '' || max === 'NaN') max = '';
                if (min === '' || min === 'NaN') min = 0;
                if (step === 'any' || step === '' || step === undefined || parseFloat(step) === 'NaN') step = 1;

                // Change the value
                if ($this.hasClass('jws-qty-plus')) {
                    if (max && (max == currentVal || currentVal > max)) {
                        $qty.val(max);
                    } else {
                        $qty.val(currentVal + parseFloat(step));
                        self.quantityInputsTriggerEvents($qty);
                    }
                } else {
                    if (min && (min == currentVal || currentVal < min)) {
                        $qty.val(min);
                    } else if (currentVal > 0) {
                        $qty.val(currentVal - parseFloat(step));
                        self.quantityInputsTriggerEvents($qty);
                    }
                }
            });
        },
        /**
         *    Quantity inputs: Trigger events
         */
        quantityInputsTriggerEvents: function($qty) {
            var self = this;

            // Trigger quantity input "change" event
            $qty.trigger('change');

            // Trigger custom event
            self.$document.trigger('nm_qty_change', $qty);
        },

    };
    // Add core script to $.nmTheme so it can be extended
    $.nmTheme = NmTheme.prototype;
    $(document).ready(function() {
        // Initialize script
        new NmTheme();
    });
})(jQuery);
;(function($) {

    'use strict';

    // Extend core script
    $.extend($.nmTheme, {

        /**
         *	Initialize scripts
         */
        atc_init: function() {
            var self = this;

            self.atcBind();
        },


        /**
         *	Bind
         */
        atcBind: function() {
            var self = this;

            // Bind: Single product "add to cart" buttons
            self.$body.on('click', '  .quick-view-modal .single_add_to_cart_button', function(e) {

                var $thisButton = $(this);

                // Make sure the add-to-cart button isn't disabled
                if ($thisButton.is('.disabled')) {
                    console.log('NM: Add-to-cart button disabled');
                    return;
                }

                // Only allow simple and variable product types
                if ($thisButton.hasClass('jws-simple-add-to-cart-button') || $thisButton.hasClass('jws-variable-add-to-cart-button')) {
                    e.preventDefault();


                    // Set button disabled state
                    $thisButton.attr('disabled', 'disabled');

                    var $productForm = $thisButton.closest('form');

                    if (!$productForm.length) {
                        return;
                    }

                    var data = {
                        product_id: $productForm.find("[name*='add-to-cart']").val(),
                        //product_variation_id:	$productForm.find("input[name*='variation_id']").val(),
                        //cart_num_items:			$productForm.find("input[name*='cart_num_items']").val(),
                        //update_page: 			$productForm.find("input[name*='update_page']").val(),
                        product_variation_data: $productForm.serialize()
                    };

                    // Trigger "adding_to_cart" event
                    self.$body.trigger('adding_to_cart', [$thisButton, data]);

                    // Submit product form via Ajax
                    self.atcAjaxSubmitForm($thisButton, data);
                }
            });
        },


        /**
         *	Submit product form via Ajax
         */
        atcAjaxSubmitForm: function($thisButton, data) {
            var self = this;
            if (!data.product_id) {
                console.log('NM (Error): No product id found');
                return;
            }

            var atcUrl = wc_add_to_cart_params.wc_ajax_url.toString().replace('wc-ajax=%%endpoint%%', 'add-to-cart=' + data.product_id + '&jws-ajax-add-to-cart=1');

            // Submit product form via Ajax
            $.ajax({
                type: 'POST',
                url: atcUrl,
                data: data.product_variation_data,
                dataType: 'html',
                cache: false,
                headers: {
                    'cache-control': 'no-cache'
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    console.log('NM: AJAX error - atcAjaxSubmitForm() - ' + errorThrown);
                },
                success: function(response) {

                    var $response = $('<div>' + response + '</div>'), // Wrap the returned HTML string so we can get the replacement elements
                        $shopNotices = $response.find('#jws-shop-notices-wrap'), // Shop notices
                        hasError = ($shopNotices.find('.woocommerce-error').length) ? true : false, // Is there an error notice?
                        cartHash = ''; // Note: Add the cart-hash to an element (data attribute) in the redirect template?

                    // Get replacement elements/values
                    // Note: Using ".prop('outerHTML')" to convert the jQuery objects/elements into strings (since they are passed to the "added_to_cart" event below)
                    var fragments = {
                        '.jws-menu-cart-count': $response.find('.jws-menu-cart-count').prop('outerHTML'), // Header menu cart count
                        '#jws-shop-notices-wrap': $shopNotices.prop('outerHTML'),
                        '#jws-cart-panel': $response.find('#jws-cart-panel').prop('outerHTML') // Cart panel
                    };

                    // Replace cart/shop fragments
                    self.shopReplaceFragments(fragments);

                    // Trigger "added_to_cart" event
                    // Note: The "fragments" object is passed to make sure the various shop/cart fragments are updated
                    self.$body.trigger('added_to_cart', [fragments, cartHash]);

                    if (self.quickviewOpen) {
                        // Close quickview modal

                        $.magnificPopup.close();

                        if (hasError) {
                            if (self.isShop) {
                                // Smooth-scroll to shop-top
                                self.shopScrollToTop();
                            }
                        } else {
                            // Is widget/cart panel enabled?
                            if (self.$widgetPanel.length) {
                                // Only show widget/cart panel if no error notice is returned
                                setTimeout(function() {
                                    self.widgetPanelShow(false); // Args: showLoader
                                }, 350);
                            }
                        }
                    } else {
                        // Remove button disabled state
                        $thisButton.removeAttr('disabled');

                        if (hasError) {
                            setTimeout(function() {
                                // Hide cart panel and overlay
                                $('#jws-widget-panel-overlay').trigger('click');

                                if (self.isShop) {
                                    // Smooth-scroll to shop-top
                                    self.shopScrollToTop();
                                }
                            }, 500);
                        }
                    }

                    $response.empty();
                }
            });
        }

    });

    // Add extension so it can be called from $.nmThemeExtensions
    $.nmThemeExtensions.add_to_cart = $.nmTheme.atc_init;

})(jQuery);
;(function($) {

    'use strict';

    // Extend core script
    $.extend($.nmTheme, {

        /**
         *	Initialize cart scripts
         */
        cart_init: function() {
            var self = this;


            // Init quantity buttons
            if ($('body').hasClass('woocommerce-cart')) {
                self.quantityInputsBindButtons($('.woocommerce'));
            }
            /* Bind: Update-cart button */
            /*self.$document.on('click', '#jws-cart-update-button', function() {
                self.cartTriggerUpdate();
            });*/


            /* Bind: "added_to_cart" event (products can be added via cross sells) */
            self.$body.on('added_to_cart', function() {
                // Is the quick-view visible?
                if ($('#jws-quickview').is(':visible')) {
                    self.cartTriggerUpdate();
                }
            });


            /* Coupon - Bind: Coupon toggle button */
            $('#jws-coupon-btn').bind('click', function(e) {
                e.preventDefault();

                $(this).next('.jws-coupon').slideToggle('slow');
            });


            /* Coupon - Bind: "Apply coupon" button */
            $('#jws-apply-coupon-btn').bind('click', function(e) {
                e.preventDefault();

                var couponInputVal = $('#jws-coupon-code').val();

                if (couponInputVal && couponInputVal.length > 0) {
                    var $woocommerceCouponField = $('#coupon_code');

                    // Add coupon code to original WooCommerce coupon field
                    $woocommerceCouponField.val(couponInputVal);
                    // Trigger "click" event on original WooCommerce "Apply coupon" button to submit form
                    $woocommerceCouponField.next('.button').trigger('click');

                    // Scroll to page top (so loading-overlay and notice is visible)
                    setTimeout(function() {
                        $('html, body').animate({
                            'scrollTop': 0
                        }, self.shopScrollSpeed);
                    }, 200);
                }
            });
        },


        /**
         *	Trigger update button
         */
        cartTriggerUpdate: function() {
            // Get original update button
            var $wooUpdateButton = $('div.woocommerce > form input[name="update_cart"]');

            // Remove "disabled" state/attribute
            $wooUpdateButton.prop('disabled', false);

            // Trigger "click" event
            setTimeout(function() { // Use a small timeout to make sure the element isn't disabled
                $wooUpdateButton.trigger('click');
            }, 100);
        }

    });

    // Add extension so it can be called from $.nmThemeExtensions
    $.nmThemeExtensions.cart = $.nmTheme.cart_init;

})(jQuery);
;(function($) {

    'use strict';

    // Extend core script
    $.extend($.nmTheme, {
        /**
         *	Initialize scripts
         */
        infload_init: function() {
            var self = this,
                $shopPagination = self.$shopBrowseWrap.children('.jws-paginations');


            // Bind
            self.shopInfLoadBind();

        },


        /**
         *	Shop: Initialize infinite load
         */
        shopInfLoadBind: function() {
            var self = this,
                $infloadControls = self.$shopBrowseWrap.children('.jws-infload-controls'),
                nextPageUrl;


            // Used to check if "infload" needs to be initialized after Ajax page load
            self.shopInfLoadBound = true;


            self.infloadScroll = ($infloadControls.hasClass('scroll-mode')) ? true : false;

            if (self.infloadScroll) {
                self.infscrollLock = false;

                var pxFromWindowBottomToBottom,
                    pxFromMenuToBottom = Math.round(self.$document.height() - $infloadControls.offset().top);
                //bufferPx = 0;

                /* Bind: Window resize event to re-calculate the 'pxFromMenuToBottom' value (so the items load at the correct scroll-position) */
                var to = null;
                self.$window.resize(function() {
                    if (to) {
                        clearTimeout(to);
                    }
                    to = setTimeout(function() {
                        var $infloadControls = self.$shopBrowseWrap.children('.jws-infload-controls'); // Note: Don't cache, element is dynamic
                        pxFromMenuToBottom = Math.round(self.$document.height() - $infloadControls.offset().top);
                    }, 100);
                });

                /* Bind: Window scroll event */
                self.$window.bind('smartscroll.infscroll', function() {
                    if (self.infscrollLock) {
                        return;
                    }

                    pxFromWindowBottomToBottom = 0 + self.$document.height() - (self.$window.scrollTop()) - self.$window.height();

                    // If distance remaining in the scroll (including buffer) is less than the pagination element to bottom:
                    if ((pxFromWindowBottomToBottom /* - bufferPx*/ ) < pxFromMenuToBottom) {
                        self.shopInfLoadGetPage();
                    }
                });

            } else {
                var $productsWrap = $('.bt-product-items');

                /* Bind: "Load" button */
                $productsWrap.on('click', '.jws-infload-btn', function(e) {
                    e.preventDefault();


                    self.shopInfLoadGetPage();
                });

                /* Bind: Up-arrow button (visible after all products are loaded) */
                $productsWrap.on('click', '.jws-infload-to-top', function(e) {
                    e.preventDefault();
                    // Smooth-scroll to shop-top
                    self.shopScrollToTop();
                });
            }


            if (self.infloadScroll) {
                self.$window.trigger('scroll'); // Trigger scroll in case the pagination element (+buffer) is above the window bottom
            }
        },

        /**
         *	Shop: AJAX load next page
         */
        shopInfLoadGetPage: function() {
            var self = this;

            //if (self.shopAjax) return false;


            // Get elements (these can be replaced with AJAX, don't pre-cache)
            var $nextPageLink = self.$shopBrowseWrap.children('.jws-infload-link').find('a'),
                $infloadControls = self.$shopBrowseWrap.children('.jws-infload-controls'),
                nextPageUrl = $nextPageLink.attr('href');

            if (nextPageUrl) {
                // Add/update the 'shop_load=products' query parameter to the page URL
                // Note: Don't use the 'data' setting in the '$.ajax' function or the query will be appended, not updated (if 'shop_load' is added to the URL)
                nextPageUrl = self.updateUrlParameter(nextPageUrl, 'shop_load', 'products');

                // Show 'loader'
                $infloadControls.addClass('jws-loader');

                self.shopAjax = $.ajax({
                    url: nextPageUrl,
                    dataType: 'html',
                    cache: false,
                    headers: {
                        'cache-control': 'no-cache'
                    },
                    method: 'GET',
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        console.log('NM: AJAX error - shopInfLoadGetPage() - ' + errorThrown);
                    },
                    complete: function() {
                        // Hide 'loader'
                        $infloadControls.removeClass('jws-loader');
                    },
                    success: function(response) {
                        var $response = $('<div>' + response + '</div>'), // Wrap the returned HTML string in a dummy 'div' element we can get the elements
                            $newElements = $response.children('.product-list').children('.tb-products-grid');

                        // Append the new elements
                        self.$shopBrowseWrap.find('.product-list').append($newElements);
                        // Load images (init Unveil)

                        //self.shopLoadImages();

                        // Get the 'next page' URL
                        nextPageUrl = $response.find('.jws-infload-link').children('a').attr('href');

                        if (nextPageUrl) {
                            $nextPageLink.attr('href', nextPageUrl);
                        } else {
                            self.$shopBrowseWrap.addClass('all-products-loaded');

                            if (self.infloadScroll) {
                                self.infscrollLock = true; // "Lock" scroll (no more products/pages)
                            } else {
                                $infloadControls.addClass('hide-btn'); // Hide "load" button (no more products/pages)
                            }

                            $nextPageLink.removeAttr('href');
                        }

                        self.shopAjax = false;

                        if (self.infloadScroll) {
                            self.$window.trigger('scroll'); // Trigger 'scroll' in case the pagination element (+buffer) is still above the window bottom
                        }
                    }
                });
            } else {
                if (self.infloadScroll) {
                    self.infscrollLock = true; // "Lock" scroll (no more products/pages)
                }
            }
        }

    });

    // Add extension so it can be called from $.nmThemeExtensions
    $.nmThemeExtensions.infload = $.nmTheme.infload_init;

})(jQuery);
;(function($) {
	
	'use strict';
	
	// Extend core script
	$.extend($.nmTheme, {
		/**
		 *	Initialize single product scripts
		 */
		singleProduct_init: function() {
			var self = this;
            //self.singleProductVariationsInit();
            self.quantityInputsBindButtons($('.action'));
		},	
	});
	
	// Add extension so it can be called from $.nmThemeExtensions
	$.nmThemeExtensions.singleProduct = $.nmTheme.singleProduct_init;
	
})(jQuery);
;(function($) {
    "use strict";
    // Init mini cart on header
    var initMiniCart = function() {
        $('body').on('click', '.single_add_to_cart_button , .ajax_add_to_cart', function(e) {
            if (!$(this).hasClass('disabled')) {
                e.preventDefault();
                $('body').addClass('widget-panel-open');
                $('#jws-widget-panel-overlay').addClass('show');
                $('body').removeClass('modal-open');
                $('.cart_list').addClass('show');
            };
        });
    }
    /**
     * DOMready event.
     */
    $(document).ready(function() {
        initMiniCart();
    });
})(jQuery);
;jQuery(document).on('ready', function($) {
    "use strict";

    function totop() {

        if ($('#back-to-top').length) {
            var scrollTrigger = 100, // px
                backToTop = function() {
                    var scrollTop = $(window).scrollTop();
                    if (scrollTop > scrollTrigger) {
                        $('#back-to-top').addClass('show');
                    } else {
                        $('#back-to-top').removeClass('show');
                    }
                };
            backToTop();
            $(window).on('scroll', function() {
                backToTop();
            });
            $('#back-to-top').on('click', function(e) {
                e.preventDefault();
                $('html,body').animate({
                    scrollTop: 0
                }, 700);
            });
        };
        var path = window.location.protocol + "//" + window.location.host + window.location.pathname;
         // Account for home page with empty path
        if ( path == '' ) {
            path = 'index.php';
        }
         var target_menu = $('.nav li a[href="'+path+'"]');
         var target_demo = $('.demo_con a[href="'+path+'"]');
          // Add active class to target link
         target_menu.addClass('active');
         target_demo.next().addClass('active');
    }
    totop();
    /**
     *  Toggle modal
     */
    function toggleModal() {
        $('body').on('click', '.action-search a', function(e) {
            e.preventDefault();

            openModal($('#search-modal'));
            $('#search-modal').addClass('show');


        });

        $('body').on('click', '.close-modal , .moal-overlay ', function(e) {
            e.preventDefault();
            closeModal($('#search-modal'));
            $('#search-modal').removeClass('show');

        });

    };
    toggleModal();
    /**
     * Team Click
     */
    function teamclick() {
        $('body').on('click', '.action_team', function(e) {
            e.preventDefault();
            $(this).toggleClass('active');
            $(this).parent('.team_inner').find('.member-social , .member-bio').slideToggle('slow');
        });

    };
    teamclick();
    /**
     * Sidetoget Mobile
     */
    function sidebar_drop() {
        $(window).on('resize', function() {
            if ($(window).width() < 991) {
                $('.sidebar_blog').addClass('on-mobile');
            } else {
                $('.sidebar_blog').removeClass('on-mobile');
            }
        }).trigger('resize');
        $('.sidebar_blog').on('click', '.widget-title', function(e) {
            if ($(this).closest('.sidebar_blog').hasClass('on-mobile')) {
                e.preventDefault();
                $(this).parent('.widget').find('ul , .tagcloud').slideToggle('slow');
            }
        });
    };
    sidebar_drop();
    /**
     * Product instance search
     */
    function instanceSearch() {
        var xhr = null,
            searchCache = {},
            $modal = $('#search-modal'),
            $form = $modal.find('form'),
            $search = $form.find('input.search-field'),
            $results = $modal.find('.search-results');

        $modal.on('keyup', '.search-field', function(e) {
            var valid = false;

            if (typeof e.which == 'undefined') {
                valid = true;
            } else if (typeof e.which == 'number' && e.which > 0) {
                valid = !e.ctrlKey && !e.metaKey && !e.altKey;
            }

            if (!valid) {
                return;
            }

            if (xhr) {
                xhr.abort();
            }

            search();
        }).on('change', '.product-cats input', function() {
            if (xhr) {
                xhr.abort();
            }

            search();
        }).on('focusout', '.search-field', function() {
            if ($search.val().length < 2) {
                $results.find('.woocommerce, .buttons').slideUp(function() {
                    $modal.removeClass('searching searched actived found-products found-no-product invalid-length');
                });
            }
        });
        /**
         * LazyLoad
         */
        function lazyLoad() {
            $('body').find('img').lazyload();
        };
        //lazyLoad();
        /**
         * Private function for search
         */
        function search() {
            var keyword = $search.val(),
                cat = '';

            if ($modal.find('.product-cats').length > 0) {
                cat = $modal.find('.product-cats input:checked').val();
            }


            if (keyword.length < 1) {
                $modal.removeClass('searching found-products found-no-product').addClass('invalid-length');
                return;
            }

            $modal.removeClass('found-products found-no-product').addClass('searching');

            var keycat = keyword + cat;

            if (keycat in searchCache) {
                var result = searchCache[keycat];

                $modal.removeClass('searching');

                $modal.addClass('found-products');

                $results.find('.woocommerce').html(result.products);

                $(document.body).trigger('jws_ajax_search_request_success', [$results]);

                $results.find('.woocommerce, .buttons').slideDown(function() {
                    $modal.removeClass('invalid-length');
                });

                $modal.addClass('searched actived');
            } else {
                xhr = $.ajax({
                    url: MS_Ajax.ajaxurl,
                    dataType: 'json',
                    method: 'post',
                    data: {
                        action: 'jws_search_products',
                        nonce: MS_Ajax.nextNonce,
                        term: keyword,
                        cat: cat
                    },
                    success: function(response) {
                        var $products = response.data;

                        $modal.removeClass('searching');


                        $modal.addClass('found-products');

                        $results.find('.woocommerce').html($products);

                        $results.find('.woocommerce, .buttons').slideDown(function() {
                            $modal.removeClass('invalid-length');
                        });

                        $(document.body).trigger('jws_ajax_search_request_success', [$results]);

                        // Cache
                        searchCache[keycat] = {
                            found: true,
                            products: $products
                        };


                        $modal.addClass('searched actived');
                    }
                });
            }

            $(document.body).on('jws_ajax_search_request_success', function(e, $results) {
                $results.find('img').lazyload({
                    threshold: 1000
                });
            });
        }

    };
    instanceSearch();

    function selectoption() {
        $(".woocommerce-ordering .current ").on("click", function() {
            $(this).find("ul").slideToggle();
        });

    }
    selectoption();

    function masonryaction() {
        $('.masonry-container.kitgreen-portfolio-holder').isotope({
            layoutMode: 'packery'
        });
        var el = $('.jws-masonry');

        el.each(function(i, val) {
            var _option = $(this).data('masonry');

            if (_option !== undefined) {
                var _selector = _option.selector,
                    _width = _option.columnWidth,
                    _layout = _option.layoutMode;
                    console.log(_layout);

                $(this).imagesLoaded(function() {
                    $(val).isotope({
                        itemSelector: _selector,
                        percentPosition: true,
                        masonry: {
                            columnWidth: _width
                        }
                    });
                });

            }
        });
    }
    masonryaction();


    function menumobi() {
        var body = $("body"),
            mobileNav = $(".mobile_menu"),
            dropDownCat = $(".mobile_menu .mobile_inner .menu-item-has-children"),
            elementIcon = '<span class="icon-sub-menu"></span>',
            butOpener = $(".icon-sub-menu");

        dropDownCat.append(elementIcon);

        mobileNav.on("click", ".icon-sub-menu", function(e) {
            e.preventDefault();

            if ($(this).parent().hasClass("opener-page")) {
                $(this).parent().removeClass("opener-page").find("> ul").slideUp(200);
                $(this).parent().removeClass("opener-page").find(".sub-menu-dropdown  > ul").slideUp(200);
                $(this).parent().find('> .icon-sub-menu').removeClass("up-icon");
            } else {
                $(this).parent().addClass("opener-page").find("> ul").slideDown(200);
                $(this).parent().addClass("opener-page").find(".sub-menu-dropdown  > ul").slideDown(200);
                $(this).parent().find('> .icon-sub-menu').addClass("up-icon");
            }
        });


        $(".button_menu").click(function() {

            if (body.hasClass("open-mobile-menu")) {
                closeMenu();
            } else {
                openMenu();
            }

        });

        body.on("click touchstart", ".mobile-overplay", function() {
            closeMenu();
        });

        function openMenu() {
            body.addClass("open-mobile-menu");
        }

        function closeMenu() {
            body.removeClass("open-mobile-menu");
        }
    }
    menumobi();
    /*----------------------------
        Video Button
    ----------------------------*/
    function youtubevideo() {
        $(".kitgreen-video , .about-video-button").on("click", function() {
            var b = $(this),
                c = b.siblings("iframe"),
                d = c.attr("src"),
                e = d + "&autoplay=1";
            d.indexOf("vimeo.com") + 1 && (e = d + "?autoplay=1"), c.attr("src", e), b.addClass("hidden-video-bg")
        })
    }
    youtubevideo();
    /*----------------------------
        Header sticky
    ----------------------------*/
    function headerstyky() {
        $(".mainmenu-area").sticky({
            topSpacing: 0
        });;
    };
    headerstyky();

    // Get price js slider
    function priceSlider() {
        // woocommerce_price_slider_params is required to continue, ensure the object exists
        if (typeof woocommerce_price_slider_params === 'undefined') {
            return false;
        }

        if ($('.catalog-sidebar').find('.widget_price_filter').length <= 0 && $('#jws-shop-topbar').find('.widget_price_filter').length <= 0) {
            return false;
        }

        // Get markup ready for slider
        $('input#min_price, input#max_price').hide();
        $('.price_slider, .price_label').show();

        // Price slider uses jquery ui
        var min_price = $('.price_slider_amount #min_price').data('min'),
            max_price = $('.price_slider_amount #max_price').data('max'),
            current_min_price = parseInt(min_price, 10),
            current_max_price = parseInt(max_price, 10);

        if ($('.price_slider_amount #min_price').val() != '') {
            current_min_price = parseInt($('.price_slider_amount #min_price').val(), 10);
        }
        if ($('.price_slider_amount #max_price').val() != '') {
            current_max_price = parseInt($('.price_slider_amount #max_price').val(), 10);
        }

        $(document.body).bind('price_slider_create price_slider_slide', function(event, min, max) {
            if (woocommerce_price_slider_params.currency_pos === 'left') {

                $('.price_slider_amount span.from').html(woocommerce_price_slider_params.currency_symbol + min);
                $('.price_slider_amount span.to').html(woocommerce_price_slider_params.currency_symbol + max);

            } else if (woocommerce_price_slider_params.currency_pos === 'left_space') {

                $('.price_slider_amount span.from').html(woocommerce_price_slider_params.currency_symbol + ' ' + min);
                $('.price_slider_amount span.to').html(woocommerce_price_slider_params.currency_symbol + ' ' + max);

            } else if (woocommerce_price_slider_params.currency_pos === 'right') {

                $('.price_slider_amount span.from').html(min + woocommerce_price_slider_params.currency_symbol);
                $('.price_slider_amount span.to').html(max + woocommerce_price_slider_params.currency_symbol);

            } else if (woocommerce_price_slider_params.currency_pos === 'right_space') {

                $('.price_slider_amount span.from').html(min + ' ' + woocommerce_price_slider_params.currency_symbol);
                $('.price_slider_amount span.to').html(max + ' ' + woocommerce_price_slider_params.currency_symbol);

            }

            $(document.body).trigger('price_slider_updated', [min, max]);
        });
        if (typeof $.fn.slider !== 'undefined') {
            $('.price_slider').slider({
                range: true,
                animate: true,
                min: min_price,
                max: max_price,
                values: [current_min_price, current_max_price],
                create: function() {

                    $('.price_slider_amount #min_price').val(current_min_price);
                    $('.price_slider_amount #max_price').val(current_max_price);

                    $(document.body).trigger('price_slider_create', [current_min_price, current_max_price]);
                },
                slide: function(event, ui) {

                    $('input#min_price').val(ui.values[0]);
                    $('input#max_price').val(ui.values[1]);

                    $(document.body).trigger('price_slider_slide', [ui.values[0], ui.values[1]]);
                },
                change: function(event, ui) {

                    $(document.body).trigger('price_slider_change', [ui.values[0], ui.values[1]]);
                }
            });
        }
    };
    // Show Filter widget
    function showFilterContent() {
        var $shopToolbar = $('#jws-shop-toolbar'),
            $shopTopbar = $('#jws-shop-topbar'),
            $catsFilter = $('#jws-categories-filter'),
            $ordering = $shopToolbar.find('.woocommerce-ordering'),
            $catalogSideBar = $('.catalog-sidebar');

        $(window).on('resize', function() {
            if ($(window).width() < 991) {

                $catalogSideBar.addClass('on-mobile');
            } else {
                $catsFilter.removeAttr('style');
                $('#jws-toggle-cats-filter').removeClass('active');
                $shopToolbar.removeClass('on-mobile');
                $shopTopbar.removeClass('on-mobile');
                $catalogSideBar.removeClass('on-mobile');
                $shopTopbar.find('.widget-title').next().removeAttr('style');
                $catalogSideBar.find('.widget-title').next().removeAttr('style');
            }
        }).trigger('resize');

        $(document.body).find('.shop-toolbar, .shop-bottombar').on('click', '.jws-filter', function(e) {
            e.preventDefault();

            if ($(this).closest('.shop-toolbar').hasClass('on-mobile')) {
                $catsFilter.slideUp(200);
                $ordering.slideUp(200);
                $('#jws-toggle-cats-filter').removeClass('active');
                $('#jws-ordering').removeClass('active');
                setTimeout(function() {
                    $shopTopbar.slideToggle(200);
                }, 200);
            } else {
                $shopTopbar.slideToggle();
            }

            $shopTopbar.toggleClass('active');
            $(this).toggleClass('active');
            $shopTopbar.closest('.shop-bottombar').toggleClass('show');
            $('#jws-filter-overlay').toggleClass('show');

            $(document.body).toggleClass('show-filters-content');
        });

        $(document.body).on('click', '#jws-filter-overlay', function(e) {
            e.preventDefault();
            $shopTopbar.slideToggle();
            $('.jws-filter').removeClass('active');
            $shopTopbar.closest('.shop-bottombar').toggleClass('show');
            $('#jws-filter-overlay').toggleClass('show');
            $shopTopbar.removeClass('active');

            $(document.body).removeClass('show-filters-content');
        });

        $(document.body).on('click', '#jws-toggle-cats-filter', function(e) {
            e.preventDefault();
            if ($(this).closest('.shop-toolbar').hasClass('on-mobile')) {

                $shopTopbar.slideUp(200);
                setTimeout(function() {
                    $catsFilter.slideToggle(200);
                }, 200);

                $(this).toggleClass('active');
                $('.jws-filter').removeClass('active');
                $shopTopbar.removeClass('active');
            }
        });

        $(document.body).on('click', '#jws-ordering', function(e) {
            e.preventDefault();
            if ($(this).closest('.shop-toolbar').hasClass('on-mobile')) {

                $shopTopbar.slideUp(200);
                setTimeout(function() {
                    $ordering.slideToggle(200);
                }, 200);

                $(this).toggleClass('active');
                $('.jws-filter').removeClass('active');
                $shopTopbar.removeClass('active');
            }
        });

        $shopTopbar.on('click', '.widget-title', function(e) {
            if ($(this).closest('.shop-topbar').hasClass('on-mobile')) {
                e.preventDefault();

                $(this).closest('.widget').siblings().find('.widget-title').next().slideUp('slow');
                $(this).closest('.widget').siblings().removeClass('active');

                $(this).next().slideToggle('slow');
                $(this).closest('.widget').toggleClass('active');


            }
        });

        $catalogSideBar.on('click', '.widget-title', function(e) {
            if ($(this).closest('.catalog-sidebar').hasClass('on-mobile')) {
                e.preventDefault();

                $(this).closest('.widget').siblings().find('.widget-title').next().slideUp(200);
                $(this).closest('.widget').siblings().removeClass('active');

                $(this).next().slideToggle(200);
                $(this).closest('.widget').toggleClass('active');


            };
        });

    };
    showFilterContent();
    // Filter Ajax
    function filterAjax() {



        $(document.body).on('price_slider_change', function(event, ui) {
            var form = $('.price_slider').closest('form').get(0),
                $form = $(form),
                url = $form.attr('action') + '?' + $form.serialize();

            $(document.body).trigger('kitgreen_catelog_filter_ajax', url, $(this));
        });


        $(document.body).on('click', ' #remove-filter-actived', function(e) {
            e.preventDefault();
            var url = $(this).attr('href');
            $(document.body).trigger('kitgreen_catelog_filter_ajax', url, $(this));
        });

        $(document.body).find('#jws-shop-product-cats').on('click', '.cat-link', function(e) {
            e.preventDefault();
            var url = $(this).attr('href');
            $(document.body).trigger('kitgreen_catelog_filter_ajax', url, $(this));
        });

        $(document.body).find('#jws-shop-toolbar').find('.woocommerce-ordering').on('click', 'a', function(e) {
            e.preventDefault();
            $(this).addClass('active');
            var url = $(this).attr('href');
            $(document.body).trigger('kitgreen_catelog_filter_ajax', url, $(this));
        });

        $(document.body).find('#jws-categories-filter').on('click', 'a', function(e) {
            e.preventDefault();
            $(this).addClass('selected');
            var url = $(this).attr('href');
            $(document.body).trigger('kitgreen_catelog_filter_ajax', url, $(this));

        });


        $(document.body).find('#jws-shop-topbar, .catalog-sidebar').on('click', 'a', function(e) {
            var $widget = $(this).closest('.widget');
            if ($widget.hasClass('widget_product_tag_cloud') ||
                $widget.hasClass('widget_product_categories') ||
                $widget.hasClass('widget_layered_nav_filters') ||
                $widget.hasClass('widget_layered_nav') ||
                $widget.hasClass('product-sort-by') ||
                $widget.hasClass('kitgreen-price-filter-list')) {
                e.preventDefault();
                $(this).closest('li').addClass('chosen');
                var url = $(this).attr('href');
                $(document.body).trigger('kitgreen_catelog_filter_ajax', url, $(this));
            }

            if ($widget.hasClass('widget_product_tag_cloud')) {
                $(this).addClass('selected');
            }

            if ($widget.hasClass('product-sort-by')) {
                $(this).addClass('active');
            }
        });

        $(document.body).on('kitgreen_catelog_filter_ajax', function(e, url, element) {

            var $container = $('.bt-product-items'),
                $container_nav = $('.catalog-sidebar'),
                $categories = $('#jws-categories-filter'),
                $shopTopbar = $('#jws-shop-topbar'),
                $titlebar = $('.page-breadcrumbs'),
                $ordering = $('.shop-toolbar .woocommerce-ordering');
            if ($('#jws-shop-toolbar').length > 0) {
                var position = $('#jws-shop-toolbar').offset().top - 200;
                $('html, body').stop().animate({
                        scrollTop: position
                    },
                    1200
                );
            }

            $('.kitgreen-products-loaders').addClass('show');
            if ('?' == url.slice(-1)) {
                url = url.slice(0, -1);
            }

            url = url.replace(/%2C/g, ',');

            history.pushState(null, null, url);

            $(document.body).trigger('kitgreen_ajax_filter_before_send_request', [url, element]);



            $.get(url, function(res) {

                $container.replaceWith($(res).find('.bt-product-items'));
                $container_nav.html($(res).find('.catalog-sidebar').html());
                $categories.html($(res).find('#jws-categories-filter').html());
                $shopTopbar.html($(res).find('#jws-shop-topbar').html());
                $ordering.html($(res).find('.shop-toolbar .woocommerce-ordering').html());
                $titlebar.html($(res).find('.page-breadcrumbs').html());
                $('.kitgreen-products-loaders').removeClass('show');
                masonryaction();
                priceSlider();
                selectoption();
                instanceSearch();
                countDownTimer();
                $('#jws-shop-loading').removeClass('show');
                $(document.body).trigger('kitgreen_ajax_filter_request_success', [res, url]);

            }, 'html');


        });

        $(document.body).on('kitgreen_ajax_filter_before_send_request', function() {
            if ($('#jws-shop-toolbar').hasClass('on-mobile') || $('#jws-shop-topbar').hasClass('on-mobile')) {
                $('#jws-categories-filter').slideUp();
                $('#jws-shop-topbar').slideUp();
                $('#jws-toggle-cats-filter').removeClass('active');
                $('.jws-filter').removeClass('active');
            }
        });

    };
    filterAjax();
    /*------------------------
       Swacth Color
    -------------------------*/
    // Product Attribute
    function kitgreenproductAttribute() {
        $(document.body).on('click', '.jws-swatch-variation-image', function(e) {
            e.preventDefault();
            $(this).siblings('.jws-swatch-variation-image').removeClass('selected');
            $(this).addClass('selected');
            var imgSrc = $(this).data('src'),
                $mainImages = $(this).parents('.tb-products-grid').find('article > .product-thumb'),
                $image = $mainImages.find('img').first(),
                imgWidth = $image.first().width(),
                imgHeight = $image.first().height();

            $mainImages.addClass('image-loading');
            $mainImages.css({
                width: imgWidth,
                height: imgHeight,
                display: 'block'
            });

            $image.attr('src', imgSrc);

            $image.load(function() {
                $mainImages.removeClass('image-loading');
                $mainImages.removeAttr('style');
            });
        });
    }
    $('.jws-carousel').slick({
        prevArrow: '<span class="ion-ios-arrow-left"></span>',
        nextArrow: '<span class="ion-ios-arrow-right"></span>'

    });
    kitgreenproductAttribute();
    // Product Thumbail Slick
    function productThumbnailSlick() {

        var $thumbnails = $('#product-thumbnails').find('.thumbnails'),
            $images = $('#product-images');

        // Product thumnails and featured image slider
        $images.not('.slick-initialized').slick({
            slidesToScroll: 1,
            fade: true,
            prevArrow: '<span class="ion-ios-arrow-left"></span>',
            nextArrow: '<span class="ion-ios-arrow-right"></span>'
        });

        $thumbnails.not('.slick-initialized').slick({

        });


    };
    if ($('.product-images-content').hasClass("no_galley") === false) {
        productThumbnailSlick();
    }

    function wcInitImageZoom() {
        if ($('.jws-image-zoom').length > 0) {
            var img = $('.jws-image-zoom');
            img.zoom({
                touch: false
            });
        }
    };
    wcInitImageZoom();

    //Product swatch
    // Style Variation
    function productVatiation() {
        // soopas_variation_swatches_form
        $('body').on('tawcvs_initialized', function() {
            $('.variations_form').unbind('tawcvs_no_matching_variations');
            $('.variations_form').on('tawcvs_no_matching_variations', function(event, $el) {
                event.preventDefault();
                $el.addClass('selected');

                $('.variations_form').find('.woocommerce-variation.single_variation').show();
                if (typeof wc_add_to_cart_variation_params !== 'undefined') {
                    $('.variations_form').find('.single_variation').slideDown(200).html('<p>' + wc_add_to_cart_variation_params.i18n_no_matching_variations_text + '</p>');
                }
            });

        });
        if (($('.woocommerce-product-gallery__wrapper .slick-slide').length > 1)) {
            $(document).on('found_variation', 'form.variations_form', function(event, variation) {
                event.preventDefault();
                $('#product-images').slick('slickGoTo', 0, true);
            }).on('reset_image', function() {
                $('#product-images').slick('slickGoTo', 0, true);
            });
        };
        $('.variations_form').find('td.value').each(function() {
            if (!$(this).find('.variation-selector').hasClass('hidden')) {
                $(this).addClass('show-select');
            } else {
                $(this).prev().addClass('show-label');
            }
        });
    };
    productVatiation();
    // Loading Ajax
    function kitgreenloadingAjax() {



        // Shop Page
        $(document.body).on('click', '#kitgreen-shop-infinite-loading a.next', function(e) {
            e.preventDefault();

            if ($(this).data('requestRunning')) {
                return;
            }

            $(this).data('requestRunning', true);
            $('.dots-loading').addClass('show');
            var $products = $(this).closest('.woocommerce-pagination').prev('.product-list'),
                $pagination = $(this).closest('.woocommerce-pagination');

            $.get(
                $(this).attr('href'),
                function(response) {
                    var content = $(response).find('.product-list').children('.tb-products-grid'),
                        $pagination_html = $(response).find('.woocommerce-pagination').html();


                    $pagination.html($pagination_html);
                    if ($(document.body).hasClass('catalog-board-content')) {
                        content.imagesLoaded(function() {
                            $products.isotope('insert', content);
                            $pagination.find('.page-numbers.next').data('requestRunning', false);
                            $(document.body).trigger('kitgreen_shop_ajax_loading_success');

                        });
                    } else {
                        $products.append(content);
                        $pagination.find('.page-numbers.next').data('requestRunning', false);
                        $(document.body).trigger('kitgreen_shop_ajax_loading_success');
                        $products.isotope('insert', content);
                    }

                    if (!$pagination.find('li .page-numbers').hasClass('next')) {
                        $pagination.addClass('loaded');
                    }
                }
            );
        });

        // Shop loading suceess
        $(document.body).on('kitgreen_shop_ajax_loading_success', function() {
            //	animationProduct();
            $('.kitgreen-products-loader').removeClass('show');
            masonryaction();
            countDownTimer();

        });
    };
    kitgreenloadingAjax();
    /*---------------------
        QickView Product
    ----------------------*/
    /**
     * Toggle product quick view
     */
    // Style Variation

    /**
     * Open modal
     *
     * @param $modal
     * @param tab
     */
    function openModal($modal) {
        $(document.body).addClass('modal-open');
        $modal.fadeIn("slow");
        $modal.addClass('open');
    };

    /**
     * Close modal
     */
    function closeModal() {
        $(document.body).removeClass('modal-open');
        $('#quick-view-modal').removeClass('open');
    };
    $(document.body).on('click', '.close-modal', function(e) {
        e.preventDefault();
        closeModal();
    });

    function productQuickView() {
        $(document.body).on('click', '.product-quick-view', function(e) {
            e.preventDefault();

            var $a = $(this),
                url = $a.attr('href'),
                $modal = $('#quick-view-modal'),
                $product = $modal.find('.product'),
                $button = $modal.find('.close-modal').first().clone();


            $product.hide().html('').addClass('invisible');
            $modal.addClass('loading');
            openModal($modal);

            $.get(url, function(response) {
                var $html = $(response),
                    $summary = $html.find('#content').find('.product-top '),
                    $social = $summary.find('.info-product'),
                    $script = $summary.find('script'),
                    $product_thumbnails = $summary.find('.product-thumbnails'),
                    $variations = $summary.find('.variations_form'),
                    $carousel = $summary.find('.woocommerce-product-gallery__wrapper'),
                    $advenced = $summary.find('.product-advanced'),
                    productClasses = $html.find('.product').attr('class');


                // Remove unused elements
                $product_thumbnails.remove();
                $advenced.remove();
                $product.addClass(productClasses);
                $product.show().html($summary).prepend($button);

                //Force height for images
                $carousel.not('.slick-initialized').slick({
                    slidesToShow: 1,
                    slidesToScroll: 1,
                    infinite: false,
                    prevArrow: '<span class="ion-ios-arrow-left"></span>',
                    nextArrow: '<span class="ion-ios-arrow-right"></span>'
                });

                $modal.removeClass('loading');
                $product.removeClass('invisible');
                $carousel.find('.photoswipe').on('click', function(e) {
                    e.preventDefault();
                });


            
                $carousel.find('.woocommerce-product-gallery__image a').on('click', function(e) {
                    e.preventDefault();
                });

                if (typeof wc_add_to_cart_variation_params !== 'undefined') {
                    $variations.wc_variation_form();
                    $variations.find('.variations select').change();
                }

                if (typeof $.fn.tawcvs_variation_swatches_form !== 'undefined') {
                    $variations.tawcvs_variation_swatches_form();
                }
                $carousel.imagesLoaded(function() {
                    $carousel.addClass('loaded');
                });
                productVatiation();
                $(".yith-wfbt-item input").removeAttr('type');
                $(".yith-wfbt-item input").attr("type", "checkbox");
            }, 'html');
        });

        $('#quick-view-modal').on('click', function(e) {
            var target = e.target;
            if ($(target).closest('div.product').length <= 0) {
                closeModal();
            }

        });
    };
    productQuickView();
    /*----------------------------
        SERVICE AND PORTFOLIO SLIDER
    ----------------------------*/
    $('.service_slider').slick();
   	function portfolioSlider() {   
        $('.portfolio-content-container').slick();
        $('.portfolio-thumbnail-container').slick({
            nextArrow: '<span class="lnr lnr-chevron-right"></span>',
            prevArrow: '<span class="lnr lnr-chevron-left"></span>',
        });
    }
   	portfolioSlider();
    function imageSlider() {   
        $('.image_active').slick(
        {
            nextArrow: '<span class="lnr lnr-chevron-right"></span>',
            prevArrow: '<span class="lnr lnr-chevron-left"></span>',
        }
        );
        $('.image_thumbnail').slick();
    }
   	imageSlider();
    /*----------------------------
        OPEN SEARCH FORM
    ----------------------------*/

    $(".action-search a ").click(function() {
        $(".content-search").addClass('active');
        $(".dgwt-wcas-search-input").focus();
    })
    $(".content-search .close i , .background-search").click(function() {
        $(".content-search").removeClass('active');
    })
    /*---------------------------
        SMOOTH SCROLL
    -----------------------------*/
    $('a.scrolltotop').on('click', function(event) {
        var id = $(this).attr("href");
        var offset = 40;
        var target = $(id).offset().top - offset;
        $('html, body').animate({
            scrollTop: target
        }, 1500, "easeInOutExpo");
        event.preventDefault();
    });
    /**
     *-------------------------------------------------------------------------------------------------------------------------------------------
     * Sale final date countdown
     *-------------------------------------------------------------------------------------------------------------------------------------------
     */
    function countDownTimer() {
        $('.kitgreen-timer').each(function() {
            $(this).countdown($(this).data('end-date'), function(event) {
                $(this).html(event.strftime('' +
                    '<h4 class="countdown-days">%-D <span>days</span></h4> ' +
                    '<h4 class="countdown-hours">%H <span>hours</span></h4> ' +
                    '<h4 class="countdown-min">%M <span>minutes</span></h4> ' +
                    '<h4 class="countdown-sec">%S <span>seconds</span></h4>'));
            });
        });

    };
    countDownTimer();
}(jQuery));