'use strict';
var window_w = $(window).innerWidth();
$('.carousel').carousel({
		interval: 6000, // in milliseconds
		pause: 'none' // set to 'true' to pause slider on mouse hover

	});

	/*------------------
		Popup
	--------------------*/
	$('.img-popup').magnificPopup({
		type: 'image',
		mainClass: 'img-popup-warp',
		removalDelay: 400,
	});
	/** open bootstrap modal on page load starts**/
	$('#ModalloadPopup').modal({keyboard: false,show:true,backdrop: 'static'})

	  // Init WOW.js and get instance
	  var wow = new WOW();
	  wow.init();

	// Start Header Animation
		//var height = $(window).height();
		var height = 142;
		$(window).scroll(function () {
			if (jQuery(document).scrollTop() > height- 1) {
				jQuery('.top-menu').addClass('tiny grow');
			} else {
				jQuery('.top-menu').removeClass('tiny shrink');
			}
		});
	/**back-to-top starts**/
		var offset = 200;
		var duration = 900;
		jQuery(window).scroll(function() {
			if (jQuery(this).scrollTop() > offset) {
				jQuery('.back-to-top').fadeIn(duration);
			} else {
				jQuery('.back-to-top').fadeOut(duration);
			}
		});

		jQuery('.back-to-top').click(function(event) {
			event.preventDefault();
			jQuery('html, body').animate({scrollTop: 0}, duration);
			return false;
		})
		/**back-to-top ends**/
		$('#horizontalTab').responsiveTabs({
			 startCollapsed: 'accordion',
			 collapsible: 'accordion',
			 rotate: false,
			 setHash: true,
		});

		jQuery("html").niceScroll({
			cursorcolor: '#565950',
			cursoropacitymin: '1',
			cursorborder: '0px',
			cursorborderradius: '5px',
			mousescrollstep: 40,
			cursorwidth: '4px',
			cursorminheight: 60,
			horizrailenabled: false,
			zindex: 1111
		});

	//magnific-popup

	//Multiple galleries
	$('.gallery').each(function() { // the containers for all your galleries
		$(this).magnificPopup({
			delegate: 'a', // the selector for gallery item
			type: 'image',
			gallery: {
				enabled:true
			}
		});
	});
	$('.popup-gallery').magnificPopup({
		delegate: 'a',
		type: 'image',
		tLoading: 'Loading image #%curr%...',
		mainClass: 'mfp-img-mobile',
		gallery: {
			enabled: true,
			navigateByImgClick: true,
			preload: [0,1] // Will preload 0 - before current, and 1 after the current image
		},
		image: {
			tError: '<a href="%url%">The image #%curr%</a> could not be loaded.',
			titleSrc: function(item) {
				return item.el.attr('title') + '<small></small>';
			}
		}
	});
	$('.popup-youtube, .popup-vimeo, .popup-gmaps').magnificPopup({
		disableOn: 700,
		type: 'iframe',
		mainClass: 'mfp-fade',
		removalDelay: 160,
		preloader: false,
		fixedContentPos: false
	});

	$('.popup-modal').magnificPopup({
		type: 'inline',
		preloader: false,
		focus: '#username',
		modal: true
	});
	$( ".popup-modal-dismiss" ).bind( "click", function(e) {
	e.preventDefault();
	jQuery.magnificPopup.close();
	});

// Counter
$('.counter').counterUp({
delay: 150,
time: 5000
});

$('#common-tariff').owlCarousel({
	loop: true,
	smartSpeed:450,
	margin: 10,
	autoplay: true,
	responsiveClass: true,
	responsive: {
		0: {
			items: 1,
			nav: true
		},
		600: {
			items: 2,
			nav: true
		},
		1000: {
			items: 3,
			nav: true,
			dots: true,
			loop: true,
			autoplay: true,
			margin: 30
		}
	}
})

$(document).ready(function() {

	jQuery(".down").click(function() {
	     jQuery('html, body').animate({
	         scrollTop: jQuery(".top-menu").offset().top
	     }, 1500);
	 });


});
/** change value here to adjust parallax level */
var parallax = -0.3;

var $bg_images = $(".wp-block-cover-image");
var offset_tops = [];
$bg_images.each(function(i, el) {
	offset_tops.push($(el).offset().top);
});

jQuery(window).scroll(function() {
	var dy = jQuery(this).scrollTop();
	$bg_images.each(function(i, el) {
		var ot = offset_tops[i];
		jQuery(el).css("background-position", "50% " + (dy - ot) * parallax + "px");
	});
});
