/* ----------------------------------------------------------------
 [Table of contents]
 
 - CountTo
 - Slider
 - MenuMobile
 - InputFile
 - MegaMenu
 - ScrollToTop
 - LightBox
 - CustomTheme
 - MediaPlayer
 - PriceRange
 - CalcQuantity

 ------------------------------------------------------------------*/

'use strict';

var myVideo = document.getElementById("video-demo");
function playPause() {
    if (myVideo.paused)
        myVideo.play();
    else
        myVideo.pause();
}
function enableMute() {
    myVideo.muted = false;
}

function disableMute() {
    myVideo.muted = true;
}

var mainMenuOpen = false;
function clearMenu () {
    jQuery('#menu_container').trigger('mouseleave');
    jQuery('.menu_section .macro p,.menu_section .macro a').addClass('top_hidden');
    jQuery('.menu_side_button').addClass('top_single');
    jQuery('#menu_book p._1').addClass('top_hidden');
    jQuery('#menu_book p._2').addClass('bottom_hidden');
    jQuery('#menu_book .white_button_separator').addClass('no_width');
    jQuery('.menu_trail').addClass('no_height');
    jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._1').addClass('top_single');
    jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._2').addClass('top_single');
    jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._3').addClass('top_single');
    jQuery('#sparta-menu .panel_logo .logo_square .border.top,  #sparta-menu .panel_logo .logo_square .border.bottom').addClass('no_width');
    jQuery('#sparta-menu .panel_logo .logo_square .border.left, #sparta-menu .panel_logo .logo_square .border.right').addClass('no_height');
    jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._4').addClass('top_single');
    jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._5').addClass('top_single');
    jQuery('#sparta-menu .panel_logo .star').addClass('hidden_by_scaling_full');

}
function openMenu() {
    jQuery('#sparta-menu').removeClass('hidden');
    mainMenuOpen = true;
    setTimeout(function(){
        jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._1').removeClass('top_single');
    },450)
    setTimeout(function(){
        jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._2').removeClass('top_single');
    },550)
    setTimeout(function(){
        jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._3').removeClass('top_single');
    },650);

    setTimeout(function(){
        jQuery('#sparta-menu .panel_logo .logo_square .border').removeClass('no_width').removeClass('no_height');

    },1000)

    setTimeout(function(){
        jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._4').removeClass('top_single');

    },900)
    setTimeout(function(){
        jQuery('#sparta-menu .panel_logo .logo_pieces .logo_p._5').removeClass('top_single');

    },1000);

    jQuery('#sparta-menu .panel_logo .star').each(function(s){
        setTimeout(function(){
            jQuery('#sparta-menu .panel_logo .star:eq('+s+')').removeClass('hidden_by_scaling_full');
        },1100+(100*s));
    });


    jQuery('.menu_section').each(function(i){
        setTimeout(function(){
            jQuery('.menu_section:eq('+i+') .macro p,.menu_section:eq('+i+') .macro a').removeClass('top_hidden');
        },500+(100*i))
    });

    jQuery('.menu_side_button').each(function(i){
        setTimeout(function(){
            jQuery('.menu_side_button:eq('+i+')').removeClass('top_single')
        },1000+(50*i));
    })

    setTimeout(function(){	jQuery('.menu_trail').removeClass('no_height');},400)

}

function close_menu(){
    mainMenuOpen = false;
    clearMenu();

    setTimeout(function(){
        jQuery('#sparta-menu').addClass('hidden');
    },400)

}
/*page loader*/

var pageloader = jQuery(".pageloader");

jQuery(window).on("pageshow", function(aa) {
    if (aa.originalEvent != undefined && aa.originalEvent.persisted) {
        pageloader.hide();
        pageloader.children().hide()
    }
});
jQuery(window).on("beforeunload", function() {
    pageloader.fadeIn(300, function() {
        pageloader.children().fadeIn(300)
    })
});
pageloader.fadeOut(800);
pageloader.children().fadeOut("slow");

jQuery(document).ready(function () {
    var navItems = jQuery('.header-fullwidth .navbar-nav > li');
    var navItemWidth=1;
    var wis = jQuery(window).width(),
    wlogo = jQuery('.header-fullwidth .logo-header').width(), wfh = jQuery('.header-fullwidth .vk-function-header').width();

    if (wis > 991) {
        var menuw = wis - wlogo - wfh;

        navItems.each(function () {
            navItemWidth += jQuery(this).width();
        });

        if (navItemWidth > menuw) {
            jQuery('.header-fullwidth .vk-menu-box').css('max-width', menuw - 40);
            jQuery('.header-fullwidth .vk-menu-box').addClass('sline');
        }
    }

    jQuery('.tckt-slctr-tkt-details-total-tickets-sold-th .smaller-text br').replaceWith(' ');
    jQuery('.tckt-slctr-tkt-details-total-tickets-left-th .smaller-text br').replaceWith(' ');
    jQuery(".lastword").html(function(){
        var text= jQuery(this).text().trim().split(" ");
        var last = text.pop();
        return text.join(" ") + (text.length > 0 ? " <span class='vk-lastword'>" + last + "</span>" : last);
    });

    jQuery(".firstword").html(function(){
        var text= jQuery(this).text().trim().split(" ");
        var first = text.shift();
        return (text.length > 0 ? "<span class='vk-firstword'>"+ first + "</span> " : first) + text.join(" ");
    });

    jQuery(document).click(function (event) {
        var target = jQuery(event.target);
        var _mobileMenuOpen = jQuery(".vk-bar-search").hasClass("show");

        if (_mobileMenuOpen === true && !target.hasClass("form-control")) {
            jQuery(".h-search").click();
        }

    });
    jQuery(".vertical-menu .icon-has-children").on('click',function () {
        var e = jQuery(this);
        var a = e.parent();
        var i = e.parent().find(" > ul:first");
        a.hasClass("active-submenu") ? (i.stop(!0, !0).slideUp(),
            a.removeClass("active-submenu")) : (i.stop(!0, !0).slideDown(),
            a.addClass("active-submenu"))
    });

    /*play and pause*/
    jQuery('button.vk-play').on('click', function (e) {
        if(jQuery(e.target).is(this)){
            jQuery('button.vk-pause').show();
            jQuery('button.vk-play').hide();
        }
    });
    jQuery('button.vk-pause').on('click', function (e) {
        if(jQuery(e.target).is(this)){
            jQuery('button.vk-play').show();
            jQuery('button.vk-pause').hide();
        }
    });

    /*mute and sound*/
    jQuery('button.vk-enablemute').on('click', function (e) {
        if(jQuery(e.target).is(this)){
            jQuery('button.vk-mutesound').show();
            jQuery('button.vk-enablemute').hide();
        }
    });
    jQuery('button.vk-mutesound').on('click', function (e) {
        jQuery(this).hide();
        if(jQuery(e.target).is(this)){
            jQuery('button.vk-enablemute').show();
            jQuery('button.vk-mutesound').hide();
        }
    });

    jQuery('.univer-element.vk-rooms-grid-content.list .room-lst-service').each(function () {
        var $child = jQuery(this).find('.mphb-room-type-children-capacity').html();
        jQuery(this).find('.mphb-room-type-adults-capacity').append($child);
        jQuery(this).find('.mphb-room-type-children-capacity').remove();
    });

    jQuery('.mphb_sc_checkout-success-reservation-message').each(function () {
        jQuery(this).parents('.entry-content').find('.vk-select-room-breakcrumb li').addClass('completed');
    });

    /*menu*/
    /* Open Menu */
    jQuery('body').on('click','#click_trigger.open', function() {
        jQuery(this).removeClass('open').addClass('close').toggleClass('box_shadowed');
        jQuery('.menu_overlay, .box_sticks').addClass('menu_open');
    });

    /* Close Menu */
    jQuery('body').on('click','#click_trigger.close', function(e) {
        jQuery(this).removeClass('open').addClass('close').toggleClass('box_shadowed');
        jQuery(this).removeClass('close').addClass('open');
        jQuery('.menu_overlay, .box_sticks').removeClass('menu_open');
        jQuery('.menu_overlay ul.sub-menu').removeClass('is-open');

    });
    jQuery('body').on('click','#click_trigger.p-left.close', function(e) {
        close_menu();
    });
    jQuery('body').on('click','.menu_overlay.menu_open .menu-opacity', function() {
        jQuery('#click_trigger').removeClass('close').addClass('open');
        jQuery('.menu_overlay, .box_sticks').removeClass('menu_open');
    });

    /*Light Gallery*/
    lightGallery(document.getElementById('lightgallery'));
    CountDown.init();
    Slider.init();
    InputFile.init();
    ScrollToTop.init();
    LightBox.init();
    CustomTheme.init();
    PriceRange.init();
    CalcQuantity.init();
    Tooltip.init();
    QtyMinusPlus.init();
    LoadMoreItem.init();
    jQuery('.menu_controller').bind('click',openMenu);
    jQuery('.m-icon-menu').on('click', function () {
        jQuery('.m-mobile').slideToggle();
        jQuery(this).toggleClass('open');
    });

    ( function() {
        jQuery(window).scroll(function() {

            if (jQuery(window).scrollTop() >= 250) {
                jQuery('.vk-header-fixed').addClass('fixed-header', 1000);

            }
            else {
                jQuery('.vk-header-fixed').removeClass('fixed-header');

            }

            if (jQuery(window).scrollTop() >= 100) {
                jQuery('.sticky-wrapper').addClass('fixed-header', 1000);

            }
            else {
                jQuery('.sticky-wrapper').removeClass('fixed-header');

            }


        });
    })();
    jQuery('.sparta-slider').each(function () {
        jQuery(this).slick();
    });
    jQuery('.woocommerce-product-gallery .flex-control-thumbs').each(function(){
        jQuery(this).slick({
            nextArrow: '<button  class="vk-btn-gallery next"><i class="fa fa-chevron-right"></i></button>',
            prevArrow: '<button  class="vk-btn-gallery prev"><i class="fa fa-chevron-left"></i></button>',
            infinite: false,
            speed: 300,
            slidesToShow: 4,
            slidesToScroll: 4,
            centerPadding: '10px',
            arrows: true,
            dots: false,
            responsive: [
                {
                    breakpoint: 1024,
                    settings: {
                        slidesToShow: 3,
                        slidesToScroll: 3,
                        infinite: true,

                    }
                },
                {
                    breakpoint: 480,
                    settings: {
                        slidesToShow: 2,
                        slidesToScroll: 2,
                    }
                }

            ]
        });
    });
    jQuery(".vk-nav .icon-has-children").on('click',function () {
        var e = jQuery(this);
        var a = e.parent();
        var i = e.parent().find(" > ul:first");
        a.hasClass("active-submenu") ? (i.stop(!0, !0).slideUp(),
            a.removeClass("active-submenu")) : (i.stop(!0, !0).slideDown(),
            a.addClass("active-submenu"))
    });
    jQuery(".widget.widget_nav_menu .icon-has-children").on('click',function () {
        var e = jQuery(this);
        var a = e.parent();
        var i = e.parent().find(" > ul:first");
        a.hasClass("active-submenu") ? (i.stop(!0, !0).slideUp(),
            a.removeClass("active-submenu")) : (i.stop(!0, !0).slideDown(),
            a.addClass("active-submenu"))
    });

    jQuery('.box-number').each(function(){
        statsCounterAnimation(this);
    });

    function statsCounterAnimation(element) {
        var inView = false;

        if (isScrolledIntoView(element)) {
            if (inView) {
                return;
            }
            inView = true;
            jQuery(element).each(function() {
                jQuery(this).animateNumber({ number: jQuery(this).data('value'), easing: 'easeOutExpo'}, 1500);
            });
        }

        jQuery(window).scroll(function() {
            if (isScrolledIntoView(element)) {
                if (inView) {
                    return;
                }
                inView = true;
                jQuery(element).each(function() {
                    jQuery(this).animateNumber({ number: jQuery(this).data('value'), easing: 'easeOutExpo'}, 1500);
                });
            }
        });
    }
    function isScrolledIntoView(elem) {
        var docViewTop = jQuery(window).scrollTop();
        var docViewBottom = docViewTop + jQuery(window).height();

        var elemTop = jQuery(elem).offset().top;
        var elemBottom = elemTop + jQuery(elem).height();

        return ((elemTop <= docViewBottom) && (elemBottom >= docViewTop));
    }

});

var LoadMoreItem = function () {
    var _initInstances = function () {
        var btn_txt = jQuery('.uni-element.vk-home-portfolio-list .vk-button-box .load-more-txt').html();
        jQuery(".uni-element.vk-home-portfolio-list .vk-button-box").append('<a href="#" class="vk-btn vk-btn-view-more" id="loadMore">'+btn_txt+' <i class="vk-icon fa fa-long-arrow-down"></i></a>');

        jQuery(".uni-element.vk-home-portfolio-list .vk-list-project li").slice(0, 8).show();
        jQuery("#loadMore").on('click', function (e) {
            e.preventDefault();
            jQuery(".uni-element.vk-home-portfolio-list .vk-list-project li:hidden").slice(0, 4).slideDown();
            if (jQuery(".uni-element.vk-home-portfolio-list .vk-list-project li:hidden").length == 0) {
                jQuery("#loadMore").fadeOut('slow');
            }
        });


    };
    return {
        init: function () {
            _initInstances();
        }
    };
}();


jQuery(window).resize(function () {
    MasonryItem.responsive();
    CustomTheme.responsive();

});

jQuery(window).on('load', function () {
    MasonryItem.init();
});

var QtyMinusPlus = function () {
    var _initInstances = function () {
    var i = jQuery('.quantity');
    i.on("click", ".plus, .minus", function() {
        var t = jQuery(this),
            e = t.closest(".quantity").find(".qty"),
            i = parseFloat(e.val()),
            o = parseFloat(e.attr("max")),
            r = parseFloat(e.attr("min")),
            a = e.attr("step");
        i && "" !== i && "NaN" !== i || (i = 0), "" !== o && "NaN" !== o || (o = ""), "" !== r && "NaN" !== r || (r = 0), "any" !== a && "" !== a && void 0 !== a && "NaN" !== parseFloat(a) || (a = 1), t.is(".plus") ? o && (o === i || i > o) ? e.val(o) : e.val(i + parseFloat(a)) : r && (r === i || i < r) ? e.val(r) : i > 0 && e.val(i - parseFloat(a)), e.trigger("change")
    });
    };
    return {
        init: function () {
            _initInstances();
        }
    };
}();

var CountDown = function() {
    var _initInstances = function () {
        jQuery('[data-countdown]').each(function () {
            var $this = jQuery(this), finalDate = jQuery(this).data('countdown');
            $this.countdown(finalDate, function (event) {
                $this.find('.sparta-days > span').html(event.strftime('%D'));
                $this.find('.sparta-hours > span').html(event.strftime('%H'));
                $this.find('.sparta-mins > span').html(event.strftime('%M'));
                $this.find('.sparta-secs > span').html(event.strftime('%S'));
            });
        });
    }

    return {
        init: function () {
            _initInstances();
        }
    };
}();


/*slider*/
var Slider = function () {

    var singlePortfolio = function(){
        jQuery('.vk-slider[data-slider-name="single-portfolio"]').slick({
            nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-arrow-right"></i></button>',
            prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-arrow-left"></i></button>',
            adaptiveHeight: true,
            arrows:false,
            dots:true,
            dotsClass:'vk-dots-nav vk-list vk-list-inline',
            autoplay:true,
            centerMode: true,
            centerPadding: '355px',
            responsive: [
                {
                    breakpoint: 1200,
                    settings: {
                        centerPadding: '100px',
                    }

                },
                {
                    breakpoint: 992,
                    settings: {
                        centerPadding: '0px',
                    }

                }]
        });
    }

    var singleProjectSlider = function () {
        jQuery("[data-slider-name = 'project']").slick({
            nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-arrow-right"></i></button>',
            prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-arrow-left"></i></button>',
            adaptiveHeight: true,
            centerMode: true,
             centerPadding: '150px',
            responsive: [
                {
                    breakpoint: 992,
                    settings: {
                        centerPadding: '0px',
                    }

                }]

        });

        jQuery("[data-slider-name = 'home-onepage-project']").slick({
            nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-arrow-right"></i></button>',
            prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-arrow-left"></i></button>',
            adaptiveHeight: true,
            centerMode: true,
            centerPadding: '235px',
            arrows:false,
            responsive: [
                {
                    breakpoint: 992,
                    settings: {
                        centerPadding: '0px',
                        arrows:true,
                    }

                }]

        });

        jQuery("[data-slider-name = 'left-menu-project']").slick({
            nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-arrow-right"></i></button>',
            prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-arrow-left"></i></button>',
            adaptiveHeight: true,
            centerMode: true,
            centerPadding: '260px',
            arrows:true,
            responsive: [
                {
                    breakpoint: 1500,
                    settings: {
                        centerPadding: '150px',
                    }
                },
                {
                    breakpoint: 1200,
                    settings: {
                        centerPadding: '0px',
                    }

                }]
        });
    };

    var singleProductSlider = function () {
        jQuery('.vk-slider-shop .slider-for').slick({
            slidesToShow: 1,
            slidesToScroll: 1,
            fade: true,
            arrows: false,
            asNavFor: '.slider-nav',
            adaptiveHeight: true,
        });
        jQuery('.vk-slider-shop .slider-nav').slick({
            slidesToShow: 4,
            slidesToScroll: 1,
            asNavFor: '.slider-for',
            focusOnSelect: true,
            arrows: false,
        });
    };

    var homepageSlider = function () {

        jQuery('.vk-slider[data-slider-name="home-slider"]').slick({
            nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-chevron-right"></i></button>',
            prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-chevron-left"></i></button>',
            dots: true,
            arrows:false,
            fade:true,
            autoplay:true,
            dotsClass: 'vk-list vk-list-inline vk-dots-nav',

        });

        jQuery('.vk-slider[data-slider-name="home-slider-shop"]').slick({
            nextArrow: '<button  class="vk-btn vk-arrow next"><i class="ti-angle-right"></i></button>',
            prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="ti-angle-left"></i></button>',
            dots: true,
            dotsClass: 'vk-list vk-list-inline vk-dots-nav',
            autoplay:true,
            fade:true,
            responsive:[
                {
                    breakpoint: 1200,
                    settings: {
                        arrows:false,
                    }
                }
            ]

        });
    };

    var homeShopSlider = function () {

        jQuery('.vk-slider[data-slider-name="client-slider"]').slick({
            slidesToShow: 6,
            arrows:false,
            responsive: [{
                breakpoint: 992,
                settings: {
                    slidesToShow: 3,
                }

            },
                {
                    breakpoint: 768,
                    settings: 'unslick'

                }]
        });
    };

    var homeOnePageExtra = function () {

        jQuery(".slide-for").slick({
            nextArrow: '<button  class="vk-btn vk-arrow next"><i class="ti-angle-right"></i></button>',
            prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="ti-angle-left"></i></button>',
            adaptiveHeight: true,
            asNavFor: '.slide-nav'
        });

        jQuery(".slide-nav").slick({
            slidesToShow: 5,
            slidesToScroll: 1,
            asNavFor: '.slide-for',
            dots: false,
            centerMode: false,
            focusOnSelect: true

        });

       jQuery('[data-slider-name="testimonial"]').slick({
           nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-arrow-right"></i></button>',
           prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-arrow-left"></i></button>',
           slidesToShow: 3,
           responsive: [
               {
                   breakpoint: 992,
                   settings: {
                       slidesToShow:2,
                   }
               },
               {
                   breakpoint: 768,
                   settings: {
                       slidesToShow: 1,
                   }
               }],
       });

        jQuery('[data-slider-name="testimonial-left-menu"]').slick({
            nextArrow: '<button  class="vk-btn vk-arrow next"><i class="fa fa-arrow-right"></i></button>',
            prevArrow: '<button  class="vk-btn vk-arrow prev"><i class="fa fa-arrow-left"></i></button>',
            slidesToShow: 3,
            responsive: [
                {
                    breakpoint: 1200,
                    settings: {
                        slidesToShow:2,
                    }
                },
                {
                    breakpoint: 768,
                    settings: {
                        slidesToShow:1,
                    }
                }],
        });
    }

    var _initInstances = function () {

        homepageSlider();
        singleProjectSlider();
        homeShopSlider();
        singleProductSlider();
        homeOnePageExtra();
        singlePortfolio();
    };

    return {
        init: function () {
            _initInstances();
        },
        responsive: function () {

        }
    };
}();


var MasonryItem = function () {
    var masonry = '[data-layout="masonry"]';
    var masonryItem = '[data-layout="masonry-item"]'
    var masonryFix = '[data-layout="masonry-fix"]';

    var buttonFilterDefault = '[data-filter-button="default"]';
    var buttonFilterFix = '[data-filter-button="filter-fix"]';

    var filterFix = function () {

      var delayFilter = function(){
          jQuery(masonryFix).isotope({
              filter: '.first',
          })
      }

        setTimeout(delayFilter ,100);
        jQuery(buttonFilterFix)

            .on('click', 'li', function () {
                var filterValue = jQuery(this).attr('data-filter');
                console.log(filterValue)
                jQuery(masonryFix).isotope({
                    filter: filterValue,
                });

                return false;
            })
            .on('change', function () {
                var filterValue = this.value;
                jQuery(masonryFix).isotope({
                    filter: filterValue,

                });

                return false;
            });

    }

    var masonryLayout = function () {
        jQuery(masonry).isotope({

            itemSelector: masonryItem,
            masonry: {
                columnWidth: masonryItem,
            }
        });


        jQuery(buttonFilterDefault)
            .on('click', 'li', function () {
                var filterValue = jQuery(this).attr('data-filter');
                console.log(filterValue);
                jQuery(masonry).isotope({
                    filter: filterValue,
                });
                return false;
            })
            .on('change', function () {
                var filterValue = this.value;
                jQuery(masonry).isotope({
                    filter: filterValue,

                });

                return false;
            });
    };

    var _initInstances = function () {
        masonryLayout();
        filterFix();

    };

    return {
        init: function () {
            _initInstances();
        },

        responsive: function () {

        }
    };
}();



var InputFile = function () {
    var _initInstances = function () {
        var inputs = document.querySelectorAll('.vk-input-file');
        Array.prototype.forEach.call(inputs, function (input) {
            var label = input.nextElementSibling,
                labelVal = label.innerHTML;

            input.addEventListener('change', function (e) {
                var fileName = '';
                if (this.files && this.files.length > 1)
                    fileName = ( this.getAttribute('data-multiple-caption') || '' ).replace('{count}', this.files.length);
                else
                    fileName = e.target.value.split('\\').pop();

                if (fileName)
                    label.querySelector('span').innerHTML = fileName;
                else
                    label.innerHTML = labelVal;
            });


            input.addEventListener('focus', function () {
                input.classList.add('has-focus');
            });
            input.addEventListener('blur', function () {
                input.classList.remove('has-focus');
            });
        });
    }
    return {
        init: function () {
            _initInstances();
        }
    };
}();




var ScrollToTop = function () {

    var _initInstances = function () {
        jQuery('#btnscrollup').fadeOut();
        jQuery(window).scroll(function() {
            if(jQuery(this).scrollTop() != 0) {
                jQuery('#btnscrollup').fadeIn();
            } else {
                jQuery('#btnscrollup').fadeOut();
            }
        });
        jQuery('#btnscrollup').on('click', function(){
            jQuery('body,html').animate({scrollTop:0},800);
        });

    };

    return {
        init: function () {
            _initInstances();
        }
    };
}();


var LightBox = function () {

    var _initInstances = function () {
        lightbox.option({
            disableScrolling: true,
            showImageNumberLabel: false,
            wrapAround: true,
            alwaysShowNavOnTouchDevices: true
        })
    };

    return {
        init: function () {
            _initInstances();
        }
    };
}();



var PriceRange = function () {
    var _initInstances = function () {
        var slider_range = '#slider-range';
        var amount1 = '#amount1';
        var amount2 = '#amount2';
        jQuery(slider_range).slider({
            range: true,
            min: 0,
            max: 1000,
            values: [59, 799],
            slide: function (event, ui) {
                jQuery(amount1).val(ui.values[0]);
                jQuery(amount2).val(ui.values[1]);
            }
        });
        jQuery(amount1).val(jQuery(slider_range).slider("values", 0));
        jQuery(amount2).val(jQuery(slider_range).slider("values", 1));
    };

    return {
        init: function () {
            _initInstances();
        }
    };
}();


var CalcQuantity = function () {
    var _initInstances = function () {
        jQuery(".vk-quantity-calulator button").on("click", function () {
            var $button = jQuery(this);
            var oldValue = $button.parent().siblings().find("input").val();

            if ($button.attr('data-index') == "plus") {
                var newVal = parseFloat(oldValue) + 1;
            } else {
                // Don't allow decrementing below zero
                if (oldValue > 0) {
                    var newVal = parseFloat(oldValue) - 1;
                } else {
                    newVal = 0;
                }
            }

            $button.parent().siblings().find("input").val(newVal);

            return false;
        });
    };

    return {
        init: function () {
            _initInstances();
        }
    };
}();


var Tooltip = function () {
    var _initInstances = function () {
        jQuery('[data-toggle="tooltip"]').tooltip();
    }

    return {
        init: function () {
            _initInstances();
        }
    };
}();



var CustomTheme = function () {

    var custom = function () {

        var wi = jQuery(window).width();

        if (jQuery('.vk-home.dark').length) {
            jQuery('body').addClass('vk-home-dark');
        }

      if (wi > 991){
          if (jQuery('.vk-header-left-menu').length) {

              jQuery('body').addClass('vk-left-menu');

              jQuery('#menu .vk-navbar-child').prepend('<li class="back"> <a href="#"><span class="fa fa-angle-double-left"></span></a></li>');
              jQuery('#menu .vk-navbar-child').addClass('vk-navbar-nav');
              jQuery('#menu .vk-navbar-child ').fadeOut();
              jQuery('#menu .vk-navbar-nav:not(.vk-navbar-child)').on('click', 'li', function () {
                  console.log(jQuery(this).find('.vk-navbar-child'));
                  jQuery(this).find('.vk-navbar-child').fadeIn();
                  jQuery('#menu').css('transform', 'translateX(-100%)');


                  jQuery('.back').on('click', function () {
                      jQuery('#menu').css('transform', 'translateX(0%)');
                      jQuery(this).parent().fadeOut();
                      return false;
                  });

              });

          }
      }

        if (jQuery('.vk-home.onepage').length) {
            jQuery('body').addClass('vk-one-page');
        }

        if (jQuery('.onepage-service').length) {
            jQuery('body').addClass('vk-one-page vk-onepage-service');
        }

        if (jQuery('.page-service-2').length) {
            jQuery('body').addClass('vk-page-service-2');
        }
        jQuery("#navScroll2Id a").mPageScroll2id();
    }


    var customByDevice = function () {
        jQuery('.vk-one-page .section').css('min-height', jQuery(window).height());
        jQuery('.vk-page-service-2 .vk-content').css('min-height', jQuery(window).height());
    }

    var clickActive = function () {
        var buttonActive = '[data-list-active = "true"]';
        jQuery(buttonActive).find('li:first-child').addClass('active');
        jQuery(buttonActive).on('click', 'li', function (e) {

            jQuery(this).siblings('.active').removeClass('active');

            jQuery(this).addClass('active');

            return false;
        });
    };

    var _initInstances = function () {
        custom();
        clickActive();
    };

    return {
        init: function () {
            _initInstances();
            customByDevice();
        },
        responsive: function () {
            customByDevice();
            _initInstances();
        }
    };
}();
