jQuery(document).ready(function () {
  'use strict'

  // Initialize tooltip component
  $('[data-toggle="tooltip"]').tooltip();

  // Initialize popover component
  $('[data-toggle="popover"]').popover();

  // dropdown
  $('.dropdown a.dropdown-toggle').click(function () {
    location.href = $(this).attr('href')
  });

	$("a[href='#callback']").click(function() {
		var dataForm = $(this).data("form");
		var dataText = $(this).data("text");
		$(".form-callback h4").text(dataText);
		$(".form-callback [name=admin-data]").val(dataForm);
	});

	$(".mfp-gallery").each(function() {
		$(this).magnificPopup({
			delegate: 'a',
			mainClass: 'mfp-zoom-in',
			type: 'image',
			tLoading: '',
      image: {
			verticalFit: true,
			titleSrc: function(item) {
        var caption = item.el.attr('title');
        return caption;
			}
		},
			gallery:{
				enabled: true,
			},
			removalDelay: 300,
			callbacks: {
				beforeChange: function() {
					this.items[0].src = this.items[0].src + '?=' + Math.random(); 
				},
				open: function() {
					$.magnificPopup.instance.next = function() {
						var self = this;
						self.wrap.removeClass('mfp-image-loaded');
						setTimeout(function() { $.magnificPopup.proto.next.call(self); }, 120);
					}
					$.magnificPopup.instance.prev = function() {
						var self = this;
						self.wrap.removeClass('mfp-image-loaded');
						setTimeout(function() { $.magnificPopup.proto.prev.call(self); }, 120);
					}
				},
				imageLoadComplete: function() { 
					var self = this;
					setTimeout(function() { self.wrap.addClass('mfp-image-loaded'); }, 16);
				}
			}
		});
	}); 
	
	$(".about-fact-item").waypoint(function() {
		
		$({blurRadius: 5}).animate({blurRadius: 0}, {
			duration: 1200,
			easing: 'swing',
			step: function() {
				$(".about-fact-item span").css({
					"-webkit-filter": "blur("+this.blurRadius+"px)",
					"filter": "blur("+this.blurRadius+"px)"
				});
			}
		});
		var comma_separator_number_step = $.animateNumber.numberStepFactories.separator(' ');
		$(".about-fact-item  span").each(function() {
			var tcount = $(this).data("count");
			$(this).animateNumber({ number: tcount,
				easing: 'easeInQuad',
				"font-size": "1.8125em",
				numberStep: comma_separator_number_step},
				1200);
		});
		this.destroy();

	}, {
		offset: '70%'
	});
	
	$("body").on("click", ".top", function() {
		$("html, body").animate({scrollTop: 0}, "slow");
	});
	
	$("body").append('<div class="top"><i class="fa fa-angle-double-up">');

}())
	    
$(window).scroll(function() {
	if($(this).scrollTop() > $(this).height()) {
		$(".top").addClass("active");
	} else {
		$(".top").removeClass("active");
	}
})

/* wow -------------------------------*/
new WOW({ mobile: false }).init();