$(window).load(function () {

	'use strict';

	$("#pageloader").delay(1200).fadeOut("slow");
	$(".loader-item").delay(700).fadeOut();

	$('.animated').appear(function () {

		var elem = $(this);
		var animation = elem.data('animation');

		if (!elem.hasClass('visible')) {
			var animationDelay = elem.data('animation-delay');
			if (animationDelay) {
				setTimeout(function () {
					elem.addClass(animation + " visible");
				}, animationDelay);

			} else {
				elem.addClass(animation + " visible");
			}
		}

	});

});

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


	// Dropdown Menu For Mobile
	$('.dropdown-menu a.dropdown-toggle-mob').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-submenu .show').removeClass("show");
		});

		return false;
	});

	// Smooth scrolling using jQuery easing
	$('a.js-scroll-trigger[href*="#"]:not([href="#"])').on('click', function () {
		if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
			var target = $(this.hash);
			target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
			if (target.length) {
				$('html, body').animate({
					scrollTop: (target.offset().top - 54)
				}, 1000, "easeInOutExpo");
				return false;
			}
		}
	});

	// Closes responsive menu when a scroll trigger link is clicked
	$('.js-scroll-trigger').on('click', function () {
		$('.navbar-collapse').collapse('hide');
	});

	$('.jarallax').jarallax({
		speed: 0.2
	});

	// Activate scrollspy to add active class to navbar items on scroll
	$('body').scrollspy({
		target: '#navbarCollapse',
		offset: 30
	});





	// On Scroll Header Style One
	$(window).scroll(function () {
		if ($(this).scrollTop() > 100) {
			$('.header-fullpage').addClass('fixed');
		} else {
			$('.header-fullpage').removeClass('fixed');
		}
	});

	// On Scroll Back To Top Arrow
	$(window).scroll(function () {
		if ($(this).scrollTop() > 100) {
			$('#mkdf-back-to-top').addClass('on');
		} else {
			$('#mkdf-back-to-top').removeClass('on');
		}
	});

	$('#mkdf-back-to-top').click(function () {
		$("html, body").animate({
			scrollTop: 0
		}, 600);
		return false;
	});


	$("#partner-brands").owlCarousel({
		items: 5,
		margin: 30,
		loop: true,
		nav: false,
		slideBy: 1,
		dots: false,
		center: false,
		autoplay: true,
		autoheight: true,
		navText: ['<i class="icofont-thin-left"></i>', '<i class="icofont-thin-right"></i>'],
		responsive: {
			320: {
				items: 2,
			},
			480: {
				items: 3,
			},
			600: {
				items: 3,
			},
			1000: {
				items: 5,
				loop: true,
			},
			1200: {
				items: 5,
				loop: true,
			}
		}
	});

	$("#client-reviews").owlCarousel({
		items: 3,
		margin: 10,
		loop: true,
		nav: false,
		slideBy: 1,
		dots: true,
		center: true,
		autoplay: true,
		autoheight: true,
		navText: ['<i class="icofont-thin-left"></i>', '<i class="icofont-thin-right"></i>'],
		responsive: {
			320: {
				items: 1,
			},
			480: {
				items: 1,
			},
			600: {
				items: 2,
			},
			1000: {
				items: 4,
				loop: true,
			},
			1200: {
				items: 3,
				loop: true,
			}
		}
	});

	$('#bookinForm').submit(function (e) {
		var form = $(this);
		var url = form.attr('action');
		$.ajax({
			type: "POST",
			url: url,
			data: form.serialize(),
			success: function () {
			    var redirectUrl = $("#redirect-url").val();
				window.location.href = redirectUrl;
			}
		});
		e.preventDefault();
	})

	$('#contactForm').submit(function (e) {
	    console.log(e);
		var form = $(this);
		var url = form.attr('action');
		$.ajax({
			type: "POST",
			url: url,
			data: form.serialize(),
			success: function () {
				var redirectUrl = $("#redirect-url").val();
				window.location.href = redirectUrl;
			}
		});
		e.preventDefault();
	})
});
