jQuery(document).ready(function($){
	'use strict';
	
	$(window).scroll(function(){
		'use strict';
		
		if($(window).scrollTop() < 120 ){
			$('.home .navbar').css({
				'margin-top': '-100px',
				'opacity': '0'
			});
			
			$('.home .navbar-default').css({
				'background': 'rgba(0,0,0,0)'
			});
		}else{
			$('.home .navbar').css({
				'margin-top': '0px',
				'opacity': '1'
			});
			
			$('.home .navbar-default').css({
				'background': 'rgba(27, 29, 40,0.7)'
			});
		}
	});
	
	// Select all links with hashes
	$('a[href*="#"]')
	  // Remove links that don't actually link to anything
	  .not('[href="#"]')
	  .not('[href="#0"]')
	  .click(function(event) {
		// On-page links
		if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
			// Figure out element to scroll to
			var target = $(this.hash);
			target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
			// Does a scroll target exist?
			if (target.length) {
			// Only prevent default if animation is actually gonna happen
			event.preventDefault();
			$('html, body').animate({
			  scrollTop: target.offset().top
			}, 1000, function() {
			  // Callback after animation
			  // Must change focus!
			  var $target = $(target);
			  $target.focus();
			  if ($target.is(":focus")) { // Checking if the target was focused
				return false;
			  } else {
				$target.attr('tabindex','-1'); // Adding tabindex for elements not focusable
				$target.focus(); // Set focus again
			  };
			});
			}
		}
	});
	
	// active menu
	$('.navbar li a').click(function(){
		
		$('.navbar li a').parent().removeClass('active');
		
		$(this).parent().addClass('active');		
		
	});
	
	// $('.menu-item-has-children').click( function () {
			// $('.menu-item-has-children').toggleClass("active");			
		// }		
	// );
	
	//section active nav
	$(window).scroll(function(){
		$('section').each(function(){
			var getid = $(this).attr('id');
			var height = $(this).outerHeight();
			var top = $(this).offset().top - 70;
			
			if($(window).scrollTop() > top && $(window).scrollTop() < top + height){
				$(".navbar-nav li a[href='#" + getid + "']").parent().addClass('active');
			}else{
				$(".navbar-nav li a[href='#" + getid + "']").parent().removeClass('active');
			}
		});
	});
	
	//screenviews slider
	$('.bxslider').bxSlider({
		slideWidth: 280,
		auto: true,
		minSlides: 1,
		maxSlides: 3,
		slideMargin: 50
	});
	
	$('.carousel-testimonial').carousel();
	
	$('.counter-number').counterUp({
		delay: 10,
		time: 1800
	});
	
	//animate
	function onScrollInit( items, trigger ) {
		items.each( function() {
			var osElement = $(this),
			osAnimationClass = osElement.attr('data-os-animation'),
			osAnimationDelay = osElement.attr('data-os-animation-delay');
			
			 osElement.css({
				'-webkit-animation-delay': osAnimationDelay,
				'-moz-animation-delay': osAnimationDelay,
				'animation-delay': osAnimationDelay
			});

			var osTrigger = ( trigger ) ? trigger : osElement;

			osTrigger.waypoint(function() {
			  osElement.addClass('animated').addClass(osAnimationClass);
			  },{
				  triggerOnce: true,
				 offset: '90%'
			});
		});
	}

	onScrollInit( $('.mw-animation') );
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
});