/* Select JS */ $(document).ready(function(){"use strict";function e(e){if(!e.id)return e.text;var t=$("<span>"+e.text+"</span>");return t}$(".select2").select2({minimumResultsForSearch:1/0}),$("#select-Categories1").select2({minimumResultsForSearch:""}),$("#select-Categories2").select2({minimumResultsForSearch:""}),$("#select-Categories3").select2({minimumResultsForSearch:""}),$("#select-Categories4").select2({minimumResultsForSearch:""}),$("#select-Categories5").select2({minimumResultsForSearch:""}),$("#select-Categories6").select2({minimumResultsForSearch:""}),$("#select-Categories7").select2({minimumResultsForSearch:""}),$("#select-Categories8").select2({minimumResultsForSearch:""}),$("#select-Categories9").select2({minimumResultsForSearch:""}),$("#select-Categories10").select2({minimumResultsForSearch:""}),$(".select2-show-search").select2({minimumResultsForSearch:"",placeholder:"Search"}),$(".select2-no-search").select2({minimumResultsForSearch:1/0,placeholder:"Choose one"}),$(".select2-flag-search").select2({templateResult:e,templateSelection:e,escapeMarkup:function(e){return e}})});
/* Sticky JS */ !function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery")):e(jQuery),$(".horizontal-main").sticky({topSpacing:0})}(function(e){var t=Array.prototype.slice,s=Array.prototype.splice,i={topSpacing:0,bottomSpacing:0,className:"is-sticky",wrapperClassName:"sticky-wrapper",center:!1,getWidthFrom:"",widthFromWrapper:!0,responsiveWidth:!1,zIndex:"inherit"},o=e(window),n=e(document),a=[],r=o.height(),l=function(){for(var t=o.scrollTop(),s=n.height(),i=s-r,l=t>i?i-t:0,c=0,p=a.length;p>c;c++){var m=a[c],u=m.stickyWrapper.offset().top,d=u-m.topSpacing-l;if(m.stickyWrapper.css("height",m.stickyElement.outerHeight()),d>=t)null!==m.currentTop&&(m.stickyElement.css({width:"",position:"",top:"","z-index":""}),m.stickyElement.parent().removeClass(m.className),m.stickyElement.trigger("sticky-end",[m]),m.currentTop=null);else{var v=s-m.stickyElement.outerHeight()-m.topSpacing-m.bottomSpacing-t-l;if(0>v?v+=m.topSpacing:v=m.topSpacing,m.currentTop!==v){var h;m.getWidthFrom?(padding=m.stickyElement.innerWidth()-m.stickyElement.width(),h=e(m.getWidthFrom).width()-padding||null):m.widthFromWrapper&&(h=m.stickyWrapper.width()),null==h&&(h=m.stickyElement.width()),m.stickyElement.css("width",h).css("position","fixed").css("top",v).css("z-index",m.zIndex),m.stickyElement.parent().addClass(m.className),null===m.currentTop?m.stickyElement.trigger("sticky-start",[m]):m.stickyElement.trigger("sticky-update",[m]),m.currentTop===m.topSpacing&&m.currentTop>v||null===m.currentTop&&v<m.topSpacing?m.stickyElement.trigger("sticky-bottom-reached",[m]):null!==m.currentTop&&v===m.topSpacing&&m.currentTop<v&&m.stickyElement.trigger("sticky-bottom-unreached",[m]),m.currentTop=v}var g=m.stickyWrapper.parent(),w=m.stickyElement.offset().top+m.stickyElement.outerHeight()>=g.offset().top+g.outerHeight()&&m.stickyElement.offset().top<=m.topSpacing;w?m.stickyElement.css("position","absolute").css("top","").css("bottom",0).css("z-index",""):m.stickyElement.css("position","fixed").css("top",v).css("bottom","").css("z-index",m.zIndex)}}},c=function(){r=o.height();for(var t=0,s=a.length;s>t;t++){var i=a[t],n=null;i.getWidthFrom?i.responsiveWidth&&(n=e(i.getWidthFrom).width()):i.widthFromWrapper&&(n=i.stickyWrapper.width()),null!=n&&i.stickyElement.css("width",n)}},p={init:function(t){return this.each(function(){var s=e.extend({},i,t),o=e(this),n=o.attr("id"),r=n?n+"-"+i.wrapperClassName:i.wrapperClassName,l=e("<div></div>").attr("id",r).addClass(s.wrapperClassName);o.wrapAll(function(){return 0==e(this).parent("#"+r).length?l:void 0});var c=o.parent();s.center&&c.css({width:o.outerWidth(),marginLeft:"auto",marginRight:"auto"}),"right"===o.css("float")&&o.css({"float":"none"}).parent().css({"float":"right"}),s.stickyElement=o,s.stickyWrapper=c,s.currentTop=null,a.push(s),p.setWrapperHeight(this),p.setupChangeListeners(this)})},setWrapperHeight:function(t){var s=e(t),i=s.parent();i&&i.css("height",s.outerHeight())},setupChangeListeners:function(e){if(window.MutationObserver){var t=new window.MutationObserver(function(t){(t[0].addedNodes.length||t[0].removedNodes.length)&&p.setWrapperHeight(e)});t.observe(e,{subtree:!0,childList:!0})}else window.addEventListener?(e.addEventListener("DOMNodeInserted",function(){p.setWrapperHeight(e)},!1),e.addEventListener("DOMNodeRemoved",function(){p.setWrapperHeight(e)},!1)):window.attachEvent&&(e.attachEvent("onDOMNodeInserted",function(){p.setWrapperHeight(e)}),e.attachEvent("onDOMNodeRemoved",function(){p.setWrapperHeight(e)}))},update:l,unstick:function(t){return this.each(function(){for(var t=this,i=e(t),o=-1,n=a.length;n-->0;)a[n].stickyElement.get(0)===t&&(s.call(a,n,1),o=n);-1!==o&&(i.unwrap(),i.css({width:"",position:"",top:"","float":"","z-index":""}))})}};window.addEventListener?(window.addEventListener("scroll",l,!1),window.addEventListener("resize",c,!1)):window.attachEvent&&(window.attachEvent("onscroll",l),window.attachEvent("onresize",c)),e.fn.sticky=function(s){return p[s]?p[s].apply(this,t.call(arguments,1)):"object"!=typeof s&&s?void e.error("Method "+s+" does not exist on jQuery.sticky"):p.init.apply(this,arguments)},e.fn.unstick=function(s){return p[s]?p[s].apply(this,t.call(arguments,1)):"object"!=typeof s&&s?void e.error("Method "+s+" does not exist on jQuery.sticky"):p.unstick.apply(this,arguments)},e(function(){setTimeout(l,0)})}),$(document).ready(function(){function e(){s=i.innerHeight(),i.css({"margin-bottom":"-"+s+"px"}),i.next().css({"padding-top":+s+"px"})}function t(){var e=$(this).scrollTop();e>=n?i.addClass(o):i.removeClass(o)}var s,i=$(".sticky"),o="sticky-pin",n=i.offset().top;i.after('<div class="jumps-prevent"></div>'),e(),$(window).resize(function(){e()}),t(),$(window).scroll(function(){t()})});
/* OWl Carousel JS */ !function(a){"use strict";var o=a(".owl-carousel-icons");o.owlCarousel({margin:25,loop:!0,nav:!0,autoplay:!0,dots:!1,responsive:{0:{items:1},600:{items:2},1300:{items:3}}});var o=a(".owl-carousel-icons-banner");o.owlCarousel({margin:0,loop:!0,nav:!0,autoplay:!0,dots:!1,responsiveClass:!0,responsive:{0:{items:1},600:{items:2},900:{items:4}}});var o=a("#ServicesSlider");o.owlCarousel({loop:!0,rewind:!1,margin:25,animateIn:"fadeInDowm",animateOut:"fadeOutDown",autoplay:!0,autoplayTimeout:5e3,autoplayHoverPause:!0,dots:!1,nav:!0,responsiveClass:!0,responsive:{0:{items:2,margin:5,nav:!0},600:{items:2,margin:15,nav:!0},1300:{items:4,nav:!0}}});var o=a(".owl-carousel-icons3");o.owlCarousel({margin:25,loop:!0,nav:!1,dots:!1,responsive:{0:{items:1},600:{items:2},1e3:{items:2}}});var o=a(".owl-carousel-icons4");o.owlCarousel({margin:25,loop:!0,nav:!1,dots:!1,responsive:{0:{items:1},600:{items:3},1e3:{items:6}}});var o=a(".owl-carousel-icons5");o.owlCarousel({loop:!0,rewind:!1,margin:25,animateIn:"fadeInDowm",animateOut:"fadeOutDown",autoplay:!1,autoplayTimeout:5e3,autoplayHoverPause:!0,dots:!0,nav:!1,responsiveClass:!0,responsive:{0:{items:1,nav:!0},600:{items:2,nav:!0},1300:{items:4,nav:!0}}});var o=a(".owl-carousel-icons51");o.owlCarousel({loop:!0,rewind:!1,margin:25,animateIn:"fadeInDowm",animateOut:"fadeOutDown",autoplay:!1,autoplayTimeout:5e3,autoplayHoverPause:!0,dots:!1,nav:!1,responsiveClass:!0,responsive:{0:{items:1,nav:!0},600:{items:2,nav:!0},1300:{items:4,nav:!0}}});var o=a(".owl-carousel-icons6");o.owlCarousel({margin:25,loop:!0,nav:!1,dots:!1,responsive:{0:{items:1},600:{items:2},1e3:{items:3}}});var o=a("#HomeBanner");o.owlCarousel({margin:0,loop:!0,nav:!1,dots:!1,animateOut:"fadeout",smartSpeed:450,responsive:{0:{items:1.1,margin:10,dots:!0},768:{items:2.2,margin:20,dots:!0},900:{items:1}}});var o=a(".testimonial-owl-carousel-slide");o.owlCarousel({margin:0,loop:!0,nav:!1,dots:!1,animateOut:"fadeout",smartSpeed:450,responsive:{0:{items:1}}});var o=a(".testimonial-owl-carousel3");o.owlCarousel({margin:25,loop:!0,nav:!1,dots:!0,responsive:{0:{items:1}}});var o=a(".testimonial-owl-carousel31");o.owlCarousel({margin:0,loop:!0,nav:!1,dots:!0,responsive:{0:{items:1}}});var o=a(".testimonial-owl-carousel4");o.owlCarousel({margin:25,loop:!0,nav:!1,dots:!0,responsive:{0:{items:1}}});var o=a(".testimonial-owl-carousel");o.owlCarousel({loop:!0,rewind:!1,margin:25,autoplay:!0,animateIn:"fadeInDowm",animateOut:"fadeOutDown",autoplayTimeout:5e3,autoplayHoverPause:!0,dots:!1,nav:!0,responsiveClass:!0,responsive:{0:{items:1.1,margin:5,nav:!1},600:{items:2,margin:5,nav:!1},900:{items:3,margin:10,nav:!1},1300:{items:3,nav:!1}}})}(jQuery);
/* orderlist acordian */ jQuery(document).ready((function(e){var i=e(".orderlist-body").hide();i.first().show(),e(".orderlist-head").click((function(){var n=e(this);i.slideUp(),n.next().slideDown()}))}));
/* Custom JS */
(function($) {
	"use strict";
	
	// When the user scrolls the page, execute myFunction 
	window.onscroll = function() {myFunction()};
	function myFunction() {
		var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
		var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
		var scrolled = (winScroll / height) * 100;
		document.getElementById("myBar").style.width = scrolled + "%";
	}
	
	// ______________Active Class
	$(document).ready(function() {
		$(".horizontalMenu-list li a").each(function() {
			var pageUrl = window.location.href.split(/[?#]/)[0];
			if (this.href == pageUrl) {
				$(this).addClass("active");
				$(this).parent().addClass("active"); // add active to li of the current link
				$(this).parent().parent().prev().addClass("active"); // add active class to an anchor
				$(this).parent().parent().prev().click(); // click the item to make it drop
			}
		});
		$(".horizontal-megamenu li a").each(function() {
			var pageUrl = window.location.href.split(/[?#]/)[0];
			if (this.href == pageUrl) {
				$(this).addClass("active");
				$(this).parent().addClass("active"); // add active to li of the current link
				$(this).parent().parent().parent().parent().parent().parent().prev().addClass("active"); // add active class to an anchor
				$(this).parent().parent().prev().click(); // click the item to make it drop
			}
		});
		$(".horizontalMenu-list .sub-menu .sub-menu li a").each(function() {
			var pageUrl = window.location.href.split(/[?#]/)[0];
			if (this.href == pageUrl) {
				$(this).addClass("active");
				$(this).parent().addClass("active"); // add active to li of the current link
				$(this).parent().parent().parent().parent().prev().addClass("active"); // add active class to an anchor
				$(this).parent().parent().prev().click(); // click the item to make it drop
			}
		});
	});
	
	// ______________ Back to Top
	$(window).on("scroll", function(e) {
		if ($(this).scrollTop() > 0) {
			$('#back-to-top').fadeIn('slow');
		} else {
			$('#back-to-top').fadeOut('slow');
		}
	});
	$("#back-to-top").on("click", function(e) {
		$("html, body").animate({
			scrollTop: 0
		}, 600);
		return false;
	});
	
	
	
	// ______________Quantity-right-plus
	var quantitiy = 0;
	$('.quantity-right-plus').on('click', function(e) {
		e.preventDefault();
		var quantity = parseInt($('#quantity').val()); 
		$('#quantity').val(quantity + 1); 
	});
	$('.quantity-left-minus').on('click', function(e) {
		e.preventDefault();
		var quantity = parseInt($('#quantity').val());
		if (quantity > 0) {
			$('#quantity').val(quantity - 1);
		}
	});		
	
	// ______________Chart-circle
	if ($('.chart-circle').length) {
		$('.chart-circle').each(function() {
			let $this = $(this);
			$this.circleProgress({
				fill: {
					color: $this.attr('data-color')
				},
				size: $this.height(),
				startAngle: -Math.PI / 4 * 2,
				emptyFill: '#f9faff',
				lineCap: ''
			});
		});
	}
	
	const DIV_CARD = 'div.card';	
	
	// ______________Tooltip
	$('[data-toggle="tooltip"]').tooltip();
	
	// ______________Popover
	$('[data-toggle="popover"]').popover({
		html: true
	});
	
	// ______________Card Remove
	$('[data-toggle="card-remove"]').on('click', function(e) {
		let $card = $(this).closest(DIV_CARD);
		$card.remove();
		e.preventDefault();
		return false;
	});
	
	// ______________Card Collapse
	$('[data-toggle="card-collapse"]').on('click', function(e) {
		let $card = $(this).closest(DIV_CARD);
		$card.toggleClass('card-collapsed');
		e.preventDefault();
		return false;
	});
	
	// ______________Card Full Screen
	$('[data-toggle="card-fullscreen"]').on('click', function(e) {
		let $card = $(this).closest(DIV_CARD);
		$card.toggleClass('card-fullscreen').removeClass('card-collapsed');
		e.preventDefault();
		return false;
	});
})(jQuery);

/* Script2 JS */
(function($) {
	"use strict";
		
	// ______________ Cover-image
	$(".cover-image").each(function() {
		var attr = $(this).attr('data-image-src');
		if (typeof attr !== typeof undefined && attr !== false) {
			$(this).css('background', 'url(' + attr + ') center center');
		}
	});
	
	// ______________ Global Loader
	$(window).on("load", function(e) {
		$("#global-loader").fadeOut("slow");
	})
	
	// ______________ Color-skin
	$(document).ready(function() {
      $("a[data-theme]").click(function() {
        $("head link#theme").attr("href", $(this).data("theme"));
        $(this).toggleClass('active').siblings().removeClass('active');
      });
      $("a[data-effect]").click(function() {
        $("head link#effect").attr("href", $(this).data("effect"));
        $(this).toggleClass('active').siblings().removeClass('active');
      });
    });
	
	
	// ______________ Modal
	$("#myModal").modal('show');
	
	
	// ______________Rating Stars
	var ratingOptions = {
		selectors: {
			starsSelector: '.rating-stars',
			starSelector: '.rating-star',
			starActiveClass: 'is--active',
			starHoverClass: 'is--hover',
			starNoHoverClass: 'is--no-hover',
			targetFormElementSelector: '.rating-value'
		}
	};
	$(".rating-stars").ratingStars(ratingOptions);
	
	//________Banner Slider Media Query
	$(document).ready(function(){
	    if (window.matchMedia('(max-width: 991px)').matches) {
            $("#HomeBanner").removeClass("slider slider-header");
            $("#HomeBanner").parent().addClass("container");
        } else {
            $("#HomeBanner").addClass("slider slider-header");
            $("#HomeBanner").parent().removeClass("container");
        }
	});
	
	$(document).ready(function() {
	    $(".mapModal").click(function(){
            $("#setLocation").css('display','flex');
	    });
	});
	
	// lazload progressively
    let imagesToLoad = document.querySelectorAll('img[data-src]');
    let loadImages = (image) => {
    	image.setAttribute('src', image.getAttribute('data-src'));
    	image.onload = () => {
    		image.removeAttribute('data-src');
    	};
    };
    if('IntersectionObserver' in window) {
    	let observer = new IntersectionObserver((items, observer) => {
    		items.forEach((item) => {
    			if(item.isIntersecting) {
    				loadImages(item.target);
    				observer.unobserve(item.target);
    			}
    		});
    	});
    	imagesToLoad.forEach((img) => {
    		observer.observe(img);
    	});
    } else {
    	imagesToLoad.forEach((img) => {
    		loadImages(img);
    	});
    }
    
    // :: Internet Connection Detect
    var internetStatus = $("#internetStatus"),
        onlineText = "Your internet connection is back",
        offlineText = "No Internet Connection!";

    if (window.navigator.onLine) {
        internetStatus.css("display", "none").text(onlineText).addClass("internet-is-back").removeClass("internet-is-lost");
    } else {
        internetStatus.css("display", "block").text(offlineText).addClass("internet-is-lost").removeClass("internet-is-back");
    }

    window.addEventListener('offline', function () {
        internetStatus.text(offlineText).addClass("internet-is-lost").removeClass("internet-is-back").fadeIn(500);
    });

    window.addEventListener('online', function () {
        internetStatus.text(onlineText).addClass("internet-is-back").removeClass("internet-is-lost").delay("5000").fadeOut(500);
    });

    $(".offline-detection").on("click", function () {
        internetStatus.text(offlineText).addClass("internet-is-lost").removeClass("internet-is-back").fadeIn(500).delay("3000").fadeOut(500);
    });

    $(".online-detection").on("click", function () {
        internetStatus.text(onlineText).addClass("internet-is-back").removeClass("internet-is-lost").fadeIn(500).delay("3000").fadeOut(500);
    });
	
		
})(jQuery);	