"use strict";
/****** ANIMATION *****/
var wow = new WOW(
  {
    animateClass: 'animated',
    offset:       100,
    callback:     function(box) {
      //console.log("WOW: animating <" + box.tagName.toLowerCase() + ">")
    }
  }
);
wow.init();

/****** BACK TO TOP *****/
$(window).scroll(function() {
    if ($(document).scrollTop() > 500) {
        $('.t-back_to_top').fadeIn();
    } else {
        $('.t-back_to_top').fadeOut();
    }
});

$(document).ready(function(){
    $('.t-back_to_top').on('click', function(){
       $('html, body').animate({scrollTop : 0},800);
		return false;
    }); 

    $('.t-header_mobile_nav').on('click', function(){
        $('#header_nav').slideToggle('slow');
    }); 

     
    $('#t-back_to_top').on('click', function(){
     $('html, body').animate({scrollTop : 0},800);
       return false;
    }); 
  
});  

$(window).resize(function(){
  var width = $(window).width();
  if(width > 767)
  {
    $('#header_nav').css('display','block');
  }
  else
  {
    $('#header_nav').css('display','none');
  }
});

$(window).load(function() {
  $("body").css('visibility',"visible");
  setTimeout(
    function() 
    {
      $("body").removeClass('t-overlay');
    }, 1500);
});

$(document).on("click","a[href^=#]",function(e){
  var str = document.URL;
      var i = str.lastIndexOf('/');
      if (i != -1) {
          str = str.substr(0, i) + "/";
      }

  e.preventDefault();
  var hashtag = jQuery(this).attr("href");
  if(hashtag.length>1){
    window.location.href = str+hashtag;
  }
}); 

/****** BACK TO TOP *****/
$(window).scroll(function() {
    if ($(document).scrollTop() > 500) {
        $('#t-back_to_top').fadeIn();
    } else {
        $('#t-back_to_top').fadeOut();
    }
});