;(function($) {

   'use strict'
   
   var $window     = $(window);
   var $document = $(document);
     var herointerval = parseInt( business_idea_settings.hero_slider_speed );
	//$.fn.carousel.Constructor.TRANSITION_DURATION = interval + 2000;
	$('#hero_carousel').carousel({
		interval : herointerval
	});
   
   $(document).ready(function () {
	   
		if( business_idea_settings.disable_animation != true ){
			new WOW().init();
		}
		
		var window_width = $(window).width();
		if ( window_width >= 768 ) {
		    $('.nav li.dropdown').hover(function() {
			   $(this).addClass('open');
		   }, function() {
			   $(this).removeClass('open');
		   });
		}
	   
		//  Activate the Tooltips
		$( '[data-toggle="tooltip"], [rel="tooltip"]' ).tooltip(); 
		
		$(window).scroll(function () {
			if ($(this).scrollTop() > 100) {
				$('.scroll_top').fadeIn();
			} else {
				$('.scroll_top').fadeOut();
			}
		});
		
		$('.scroll_top').click(function () {
			$("html, body").animate({
				scrollTop: 0
			}, 600);
			return false;
		});
		
		if( $('.contact-area .wpcf7-form').length > 0 ){
			$('.contact-area .wpcf7-form').prepend('<div class="contact-section-header"><h3>GeT In Touch</h3></div>');
		}
		
		$('.rellax').parallax();
		
		$('li.dropdown').on('click', function() {
			var $el = $(this);
			if ($el.hasClass('open')) {
				var $a = $el.children('a.dropdown-toggle');
				if ($a.length && $a.attr('href')) {
					location.href = $a.attr('href');
				}
			}
		});
		
		$("html").easeScroll();
		
   });
	
	function news_slider(){
		if($(window).width() <= 768 ){
			return;
		}
		if($(window).width() > 768 && $(window).width() <= 1024 ){
		   var total = 0;
		}
		if($(window).width() > 1024  ){
			var total = 1;
		}

		$('#news_slider .item').each(function(){
			var next = $(this).next();
			if (!next.length) {
				next = $(this).siblings(':first');
			}
			next.children(':first-child').clone().appendTo($(this));
			for (var i=0;i<total;i++) {
				next=next.next();
				if (!next.length) {
					next = $(this).siblings(':first');
				}
				next.children(':first-child').clone().appendTo($(this));
			}
		});
	}
	
	function product_slider(){
		if($(window).width() <= 768 ){
			return;
		}
		if($(window).width() > 768 && $(window).width() <= 1024 ){
		   var total = 0;
		}
		if($(window).width() > 1024  ){
			var total = 2;
		}

		$('#product_slider .item').each(function(){
			var next = $(this).next();
			if (!next.length) {
				next = $(this).siblings(':first');
			}
			next.children(':first-child').clone().appendTo($(this));
			for (var i=0;i<total;i++) {
				next=next.next();
				if (!next.length) {
					next = $(this).siblings(':first');
				}
				next.children(':first-child').clone().appendTo($(this));
			}
		});
	}
	
	$(document).ready( function(){
		$( window ).resize(function(){
		});
		$( window ).load(function(){
			news_slider();
			product_slider();
		});
	});
	
	var adminbarheight = function(){
        var height = 0;
        if ( $( '#wpadminbar' ).length ) {
            if ( $( '#wpadminbar' ).css('position') == 'fixed' ) {
                height = $( '#wpadminbar' ).height();
            }
        }
        return height;
    };
	
	function fullscreenSlider( no_trigger ){
        if ( $( '.hero-fullwidth').length > 0 ) {
            var window_h = $window.height();
            var top = adminbarheight();
            var $header = jQuery( '.header');
            var is_transparent = $header.hasClass('is-t');
            var header_h;
            if ( is_transparent ) {
                header_h = 0;
            } else {
                header_h = $header.height();
            }
            header_h += top;
            jQuery('.slider .slide img').css('height', ( window_h - header_h + 1) + 'px');
            if (  typeof  no_trigger === "undefined" || ! no_trigger ) {
                $document.trigger( 'hero_init' );
            }

        }
    }

    $window.on('resize', function (){
        fullscreenSlider();
    });
    fullscreenSlider();
    $document.on( 'header_view_changed', function(){
        fullscreenSlider();
    } );
    $document.on( 'hero_init','load', function(){
        fullscreenSlider( true );
    } );
})(jQuery);