$( window ).load(function() {
	$(document).on('click', '.navbar .dropdown-menu', function(e) {e.stopPropagation();});

	//Tabs
	$(function() {
		var mobile = "";
		if (mobile == "") {
			//$('#myshow').cycle({
			//	swipe: "true",
			//	slides: "> div.slide",
			//	fx: 'fade',
			//	timeout: 6000,
			//	speed: 2000,
			//	log: false
			//});
		} else {
			console.log(mobile);
		}
		var wh = window.innerHeight;
		var navH = $(".navbar").height();
		wh-=navH;
		console.log(navH);
		$(".slide").height(wh);


		$(".slide").height(wh);
		$(".slide").each(function () {
			var img = $(this).attr("data-slide-image");
			var me = $(this);
			//if (mobile) {
			//	img = "assets/images/mobile/" + img;
			//} else {
			//	img = "assets/images/" + img;
			//}
			img = "assets/images/inner/" + img;
			me.css('background', 'url("' + img + '")');
			me.css('background-repeat', 'no-repeat');
			me.css('background-position', 'center');
			me.css('background-size', 'cover');
		});

		$('#myshow').on('cycle-before', function (e, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
			var active = $(incomingSlideEl);
			//console.log(forwardFlag);
			//NEXT SLIDE
			$(incomingSlideEl).children().find(".slide_content").addClass("fadeInRight animated");
			$(incomingSlideEl).find(".img1").addClass("fadeInLeft animated");

			//CURRENT SLIDE
			$(outgoingSlideEl).children().find(".slide_content").addClass("fadeOutLeft animated");

			//$(incomingSlideEl).children().find(".slide_head1").velocity("transition:slideUpIn");
			//$(incomingSlideEl).find(".slide_content").addClass("fadeInUp animated");
			if (active.is('#slide1')) {
				$(incomingSlideEl).find(".slide_content").addClass("fadeInDown animated");
			} else {
				$(incomingSlideEl).find(".slide_content").addClass("fadeInUp animated");
			}
		});
		$('#myshow').on('cycle-after', function (e, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
			var active = $(incomingSlideEl);
			$(outgoingSlideEl).children().find(".slide_content").removeClass("fadeInRight fadeOutLeft animated");
			$(outgoingSlideEl).find(".slide_content, .img1").removeClass("fadeInUp fadeInDown zoomIn  fadeInLeft fadeInRight bounce animated");

			if (active.is('#slide2')) {
				//
			}
		});



//        var preload = ["<?php //if(is_array($img_main)){echo $img_path.$img_main[0]; }else{ echo $img_path.$img_main;} ?>//"];
//        var promises = [];
//        for (var i = 0; i < preload.length; i++) {
//            (function (url, promise) {
//                var img = new Image();
//                img.onload = function () {
//                    promise.resolve();
//                };
//                img.src = url;
//            })(preload[i], promises[i] = $.Deferred());
//        }
//        $.when.apply($, promises).done(function () {
//            //alert("All images ready sir!");
//            $(".preloader_div").hide();
//            var $cat_head = $(".product_name"),
//                $cat_tag = $(".product_tagline"),
//                $img_main = $(".img_main"),
//            //$icon = $(".icon"),
//                $element3 = $(".img_0");
//            var animationSequence =
//                [
//                    {e: $img_main, p: {scale: 0.9}, o: {easing: "easeOutCubic"}},
//                    {
//                        e: $img_main,
//                        p: {opacity: 1, scale: 1},
//                        o: {easing: "easeOutCubic", stagger: 800, delay: 500, duration: 2000}
//                    },
////                            { e: $element1,  p: { translateY: 10, opacity: 1}, o: {easing:"easeInCubic", stagger:800, delay:200 }},
//                {e: $cat_head, p: {translateY: 10, opacity: 1}, o: {easing: "easeOutElastic", duration: 600}},
//                {e: $cat_tag, p: {translateY: 10, opacity: 1}, o: {easing: "easeOutElastic", duration: 600}},
//            ];
//
//            $.Velocity.RunSequence(animationSequence);
//        });

		var active = $('a[data-toggle="tab"]').parents('.active').length;
		var tabClicked = false;

		// Closes current active tab (toggle and pane):
		var close = function() {
			$('a[data-toggle="tab"]').parent().removeClass('active');
			$('.tab-pane.active').removeClass('active');
			active = false;
		}

		// Closing active tab on clicking on toggle:
		$('[data-toggle=tab]').click(function(){
			if ($(this).parent().hasClass('active')){$($(this).attr("href")).toggleClass('active'); active = false;}
			else {tabClicked = true; active = this;}
		});

		// Closing active tab on clicking outside tab context (toggle and pane):
		$(document).on('click.bs.tab.data-api', function(event) {
			if(active && !tabClicked && !$(event.target).closest('.tab-pane.active').length) {close();}
			tabClicked = false;
		});

		// Closing active tab on ESC key release:
		$(document).keyup(function(e){
			if(active && e.keyCode === 27) {close();}
		});
	});
});

$(window).scroll(function() {
	if ($(document).scrollTop() > 50) {
		$('nav').addClass('shrink');
	} else {
		$('nav').removeClass('shrink');
	}
});
$(document).ready(function(){
	'use strict';
	//var slider=new Swiper('#hero',{
	//	pagination:'.swiper-pagination',
	//	paginationClickable:true,
	//	nextButton:'.swiper-button-next',
	//	prevButton:'.swiper-button-prev',
	//	//slidesPerView:1,
	//	parallax:true,
	//	speed:1500,
	//	effect:'fade'
     //   }
	//);
	//var testimonials_slider=new Swiper('#testimonials_slider',{
	//	pagination:'.swiper-pagination',
	//	paginationClickable:true,
	//	nextButton:'.swiper-button-next',
	//	prevButton:'.swiper-button-prev',
	//	parallax:true,speed:1000
	//	}
	//);

//	$('[data-pages="search"]').search({
//		searchField:'#overlay-search',
//		closeButton:'.overlay-close',
//		suggestions:'#overlay-suggestions',
//		brand:'.brand',
//		onSearchSubmit:function(searchString){console.log("Search for: "+ searchString);},
//		onKeyEnter:function(searchString){console.log("Live search for: "+ searchString);
//		var searchField=$('#overlay-search');
//		var searchResults=$('.search-results');
//		clearTimeout($.data(this,'timer'));
//		searchResults.fadeOut("fast");
//		var wait=setTimeout(function(){
//			searchResults.find('.result-name').each(function(){
//				if(searchField.val().length!=0){$(this).html(searchField.val());
//				searchResults.fadeIn("fast");
//				}
//			}
//		);
//		},500);
//		$(this).data('timer',wait);
//		}
//	}
//	);
}
);
		
		
		