(function ($) {
    'use strict';
    $(document).ready(function () {
		
//number countdown
$('.counter-count').each(function () {
        $(this).prop('Counter',0).animate({
            Counter: $(this).text()
        }, {
            duration: 5000,
            easing: 'swing',
            step: function (now) {
                $(this).text(Math.ceil(now));
            }
        });
    });

    $('.dropdown-menu a.dropdown-toggle').on('click', function(e) {
  if (!$(this).next().hasClass('show')) {
    $(this).parents('.dropdown-menu').first().find('.show').removeClass("show");
  }
  var $subMenu = $(this).next(".dropdown-menu");
  $subMenu.toggleClass('show');


  $(this).parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function(e) {
    $('.dropdown-menu .show').removeClass("show");
  });


  return false;
});
    
 

// blog-slider
 var swiper = new Swiper('.blog_post .blog-slider', {
            slidesPerView: 3,
            spaceBetween: 30,
            // init: false,
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
            },
			 navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                },
            breakpoints: {
                1024: {
                    slidesPerView: 3,
                    spaceBetween: 40,
                },
                768: {
                    slidesPerView: 2,
                    spaceBetween: 10,
                },
                640: {
                    slidesPerView: 1,
                    spaceBetween: 0,
                },
                320: {
                    slidesPerView: 1,
                    spaceBetween: 0,
                }
            }
        });
	
// blog-slider 2
	var swiper = new Swiper('.blog_post .blog-slider2', {
            slidesPerView: 2,
            spaceBetween: 30,
            // init: false,
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
            },
			 navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                },
        });
	
	// Page loader js
		$('#page-anim-preloader').delay('10').fadeOut(2000);
		setTimeout(page_anim_remove_preloader, '11000');

		function page_anim_remove_preloader() {
			$('#page-anim-preloader').remove();
		}

        // gallery animate grid
		
		$(window).on("load", function() {
			var $container = $('.gallary-thumbs');
			try {
				$container.isotope({
					filter: '*',
					animationOptions: {
						duration: 750,
						easing: 'linear',
						queue: false
					}
				});
			} catch(e) {}
			$('.categories').on("click", 'a', function() {
				$('.categories .active').removeClass('active');
				$(this).addClass('active');
				var selector = $(this).attr('data-filter');
				try {
					$container.isotope({
						filter: selector,
						animationOptions: {
							duration: 750,
							easing: 'linear',
							queue: false
						}
					});
				} catch(e) {}
				return false;
			});
		});

		// Scroll to Top =
		$(window).on("scroll", function() {
            if ($(this).scrollTop() >= 50) {
                $('#return-to-top').fadeIn(200);
            } else {
                $('#return-to-top').fadeOut(200);
            }
        });
        $('#return-to-top').click("scroll", function() {
            $('body,html').animate({
                scrollTop: 0
            }, 500);
        });
	
	// swiper testimonials
     var galleryTop = new Swiper('.swiper-testimonials', {
      spaceBetween: 10,
      loop:true,
      loopedSlides: 5, //looped slides should be the same
      navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
      },
    });
    var galleryThumbs = new Swiper('.testimonials-thumbs', {
    
	  centeredSlides: true,
       slidesPerView: 'auto',
      touchRatio: 0.2,
      loop: true,
      loopedSlides: 5, //looped slides should be the same
      slideToClickedSlide: true,
    });
	try {
    galleryTop.controller.control = galleryThumbs;
    galleryThumbs.controller.control = galleryTop;
} catch(e) {}

	// light box
	try{
	lc_lightbox('.elem', {
		wrap_class: 'lcl_fade_oc',
		gallery : true,	
		thumb_attr: 'data-lcl-thumb', 
		
		skin: 'minimal',
		radius: 0,
		padding	: 0,
		border_w: 0,
	});	
	} catch(e) {}
	
	// client slider
        var swiper = new Swiper('.logo-slider', {
            slidesPerView: 5,
            spaceBetween: 50,
            // init: false,
            pagination: {
                el: '.swiper-pagination',
                clickable: true,
            },
            breakpoints: {
                1024: {
                    slidesPerView: 4,
                    spaceBetween: 40,
                },
                768: {
                    slidesPerView: 3,
                    spaceBetween: 30,
                },
                640: {
                    slidesPerView: 2,
                    spaceBetween: 20,
                },
                320: {
                    slidesPerView: 1,
                    spaceBetween: 10,
                }
            }
        });
		
 // home slider
try {
var slider = new MasterSlider();
 
    slider.control('arrows' ,{insertTo:'#masterslider'});  
    slider.control('bullets'); 
 
			var masterslider = new MasterSlider();

			// slider controls
			masterslider.control({ autohide:false, overVideo:true, dir:'v', align:'right', space:6 , margin:10  });
			// slider setup
			
			
			// slider controls
			masterslider.control('arrows'     ,{ autohide:true, overVideo:true  });
			masterslider.control('bullets'    ,{ autohide:true, overVideo:true, dir:'h', align:'bottom', space:6 , margin:10  });
			masterslider.control('timebar'    ,{ autohide:false, overVideo:true, align:'bottom', color:'#FFFFFF'  , width:4 });
			// slider setup
			masterslider.setup("masterslider", {
				width           : 960,
				height          : 720,
				minHeight       : 0,
				space           : 0,
				start           : 1,
				grabCursor      : false,
				swipe           : true,
				mouse           : true,
				keyboard        : false,
				layout          : "fullscreen",
				wheel           : false,
				autoplay        : false,
				instantStartLayers:true,
				loop            : true,
				shuffle         : false,
				preload         : 0,
				heightLimit     : true,
				autoHeight      : false,
				smoothHeight    : true,
				endPause        : false,
				overPause       : true,
				fillMode        : "fill",
				centerControls  : false,
				startOnAppear   : false,
				layersMode      : "center",
				autofillTarget  : "",
				hideLayers      : false,
				fullscreenMargin: 0,
				speed           : 16,
				dir             : "v",
				view            : "box"
			});

} catch(e) {}
    });	
}(jQuery));
