// Overlay Navigation
$('#toggle').click(function() {
   $(this).toggleClass('active');
   $('#overlay').toggleClass('open');
   $('.nav-clouds').animate({bottom: "0px"}, 1200);
});

// On Active State Removal 
$('.navlines .active').click(function() {
  $('.nav-clouds').animate({bottom: "-330px"}, 1200);
});

// Expanding Search Function
$('#search-expand .fa').click(function() {$('input').toggleClass('se');});

// Add smooth scrolling to all links
$(document).ready(function(){
  $('a[href*="#section-1"]:not([href="#myCarousel"])').on('click', function(event) {
    if (this.hash !== "") {
      event.preventDefault();
      var hash = this.hash;
      $('html, body').animate({
        scrollTop: $(hash).offset().top
      }, 800, function(){});} 
  });
});

// Flight Widget Active State
$('.controls .button-group a').click(function() {
  $('.controls .button-group a').removeClass('tab-active');
  $(this).toggleClass('tab-active');
});

// Nav BG on scroll
$(window).scroll(function() {    
  var scroll = $(window).scrollTop();
  if (scroll >= 200) {$(".overhead-nav").addClass("nav-bg-onscroll");} else {$(".overhead-nav").removeClass("nav-bg-onscroll").fadeIn(700);}
});

// Adds a class to header links
$(document).ready(function(){
  $('.main-bg .jumbotron a').addClass('btn');
})

// FAQ Blocks
var acc = document.getElementsByClassName("faq");
var i;

for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function() {
    this.classList.toggle("active");
    var panel = this.nextElementSibling;
    if (panel.style.maxHeight){
      panel.style.maxHeight = null;
    } else {
      panel.style.maxHeight = panel.scrollHeight + "px";
    } 
  });
}

$(document).ready(function() {
  $(".faq").click(function() {$(this).find('i').toggleClass('rotate-45');});
});

$('.section-blue-bg:empty').addClass('no-padding');


$('.subpage table').addClass('table');