(function($) {
  "use strict"; // Start of use strict

  // Smooth scrolling using jQuery easing
  $('a.js-scroll-trigger[href*="#"]:not([href="#"])').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 - 56)
        }, 1000, "easeInOutExpo");
        return false;
      }
    }
  });

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

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

})(jQuery); // End of use strict

$(function() {

  $(".progress").each(function() {

    var value = $(this).attr('data-value');
    var left = $(this).find('.progress-left .progress-bar');
    var right = $(this).find('.progress-right .progress-bar');

    if (value > 0) {
      if (value <= 50) {
        right.css('transform', 'rotate(' + percentageToDegrees(value) + 'deg)')
      } else {
        right.css('transform', 'rotate(180deg)')
        left.css('transform', 'rotate(' + percentageToDegrees(value - 50) + 'deg)')
      }
    }

  })

  function percentageToDegrees(percentage) {

    return percentage / 100 * 360

  }

});


$( document ).ready(function() {
    var w = window.innerWidth;
   
    if(w > 767){
        $('#menu-jk').scrollToFixed();
    }else{
        $('#menu-jk').scrollToFixed();
    }
    
})

/*

console.log('ff');
$(document).ready(function () {
  $('submit').click(function (event) {
      event.preventDefault()
      console.log('clicked button')

      var name = $('.name').val()
      var email = $('.email').val()
      var message = $('.message').val()
      var statusElm = $('status')
      statusElm.empty()

      if(email.length > 5 && email.includes('@') & email.includes('.')) {
          statusElm.append('<div>Email is valid</div>');
      } else {
          statusElm.append('<div>Email is not valid</div>');
      }

      if(message.length > 50){
          statusElm.append('<div>Message words are under 50<div>')
      } else {
          statusElm.append('<div>Message words are more than 50<div>')
      }
  })
})

*/

$(document).ready(function(){
  $(".dropdown").hover(            
      function() {
          $('.dropdown-menu', this).not('.in .dropdown-menu').stop( true, true ).slideDown("fast");
          $(this).toggleClass('open');        
      },
      function() {
          $('.dropdown-menu', this).not('.in .dropdown-menu').stop( true, true ).slideUp("fast");
          $(this).toggleClass('open');       
      }
  );
});

$(document).ready(function(){
  $(".subdropdown").hover(            
      function() {
          $('.subdropdown-menu', this).not('.in .subdropdown-menu').stop( true, true ).slideDown("fast");
          $(this).toggleClass('close');        
      },
      function() {
          $('.subdropdown-menu', this).not('.in .subdropdown-menu').stop( true, true ).slideUp("fast");
          $(this).toggleClass('open');       
      }
  );
});

