$(document).ready(function(){
  $("#banner ul").owlCarousel({
	  autoplay: true,
	  animateIn: 'fadeIn',
	  animateOut: 'fadeOut',
	  items:1,
	  loop:true,
	  nav:true,
  });  
	
	$("#depoimentos ul").owlCarousel({
	  autoplay: true,
	  animateIn: 'fadeIn',
	  animateOut: 'fadeOut',
	  items:1,
	  loop:true,
	  nav:true,
  });  
	
	$("#sobre_flex ul").owlCarousel({
	  autoplay: true,
	  animateIn: 'fadeIn',
	  animateOut: 'fadeOut',
	  items:1,
	  loop:true,
	  nav:true,
  });  
	
	 var owl = $('#categoria_home ul');
    owl.owlCarousel({
        loop: true,
        autoplay: true,
		slideSpeed:100,
        autoplayTimeout: 1000,
        autoplayHoverPause: false,
		 responsive: {
                    0: {
                        items: 2
                    },
                    600: {
                        items: 2
                    },
                    1000: {
                        items: 4
                    }
                }
		
    });

});

$(window).load(function(){
	$(".input-effect .effect-21").val("");
		
	$(".input-effect .effect-21").focusout(function(){
		if($(this).val() != ""){
			$(this).addClass("has-content");
		}else{
			$(this).removeClass("has-content");
		}
	})
});	

function abre_menu(){
    var c = document.getElementById("nav");
    
    if(c.classList.contains('menu_fechado')){
        close_all();
        c.classList.add('menu_aberto');
        c.classList.remove('menu_fechado');
		document.getElementById("menu_mobile").classList.remove('closed');
        document.getElementById("menu_mobile").classList.add('open');
    } else {
        c.classList.remove('menu_aberto');
        c.classList.add('menu_fechado');
        document.getElementById("menu_mobile").classList.remove('open');
        document.getElementById("menu_mobile").classList.add('closed');
    }
}

function close_all(){
    var i = 1;
    while (i <= 4) {   
        var id = 'sub'+i;
        var e = document.getElementById(id);
        if(e){ e.classList.remove('menu_aberto'); e.classList.add('menu_fechado'); }    
        i++;
    }
    
    document.getElementById("nav").classList.add('menu_fechado');
    document.getElementById("nav").classList.remove('menu_aberto');
    document.getElementById("menu_mobile").classList.remove('open');
    document.getElementById("menu_mobile").classList.add('closed');
}

function abre_sub(sub){
    var c = document.getElementById(sub);
    if(c.classList.contains('menu_fechado')){
        close_all();
        c.classList.add('menu_aberto');
        c.classList.remove('menu_fechado');
    } else {
        c.classList.remove('menu_aberto');
        c.classList.add('menu_fechado');
    } 
}

function goFurther(elem){
	if (elem.checked == true){
		document.getElementById("enviar").disabled = false;
		document.getElementById("aceitar").style.display = "none";
	}else{
		document.getElementById("enviar").disabled = true;
	}
}


$(window).scroll(function() {    
    var scroll = $(window).scrollTop();
    var windowWidth = $(window).width();
    var threshold = 80;

    if (scroll >= threshold && windowWidth > 1000) {
        $("header").addClass("fixed");

    } else {
        $("header").removeClass("fixed");

    }
});

 function toggleDropdown() {
            var content = document.getElementById("dropdown-content");
            if (content.style.display === "none" || content.style.display === "") {
                content.style.display = "block";
            } else {
                content.style.display = "none";
            }
        }

$(function(){

  //Scroll event
  $(window).scroll(function(){
    var scrolled = $(window).scrollTop();
    if (scrolled > 200) $('.go-top').fadeIn('slow');
    if (scrolled < 200) $('.go-top').fadeOut('slow');
  });
  
  //Click event
  $('.go-top').click(function () {
    $("html, body").animate({ scrollTop: "0" },  500);
  });

});
