//Pato Doldan- 24/06/2019//

//FOOTER//
$(".titulo-footer").append('<div class="chevron-footer despliega"></div>');	

$(".titulo-footer").click(function(){
	if($(window).innerWidth() >= 767) {
		//
	} else {
		$(this).siblings("ul").slideToggle();
		$(this).find(".chevron-footer").toggleClass("rotado");
	}		
});		

//TITLES//
$('#postFooter').find(".btn-footer").each(function() {
	var text = $(this).text();	
	$(this).attr("title" , text);
});	

//VER MAS
$(document).ready(function(){
	$("#solapaVerMas").text("Ver m\u00E1s");
	$("#postFooter").hide();
	$("#solapaVerMas").click(function(){
		$("#postFooter").slideToggle("fast");
		$('html, body').animate({
			scrollTop: $("#postFooter").offset().top
		}, 800);		
		if ($(this).text() === "Ver m\u00E1s")
		{
			$(this).text("Ver menos");
		}else{
			$(this).text("Ver m\u00E1s");			
		}
	});
});

$("#subcategorias").click(function(){
	if($(window).innerWidth() >= 767) {
		//
	} else {
		$(this).siblings(".columna-subcategorias").slideToggle();
		$(this).siblings(".chevron-footer").toggleClass("rotado");
		$('html, body').animate({
			scrollTop: $(this).offset().top
		}, 800);		
	}		
});

//LIMPIAR SESION//
$("#limpiarSesion").click(function(){
	//$("#limpiarSesion").trigger("#footer .footer-navigation.wrapper .links-wrapper .clear-cookies");
	$(".clear-cookies").click();
});

//BOTON SUBIR//
$(document).ready(function(){
	$(".btn-subir").hide();
	$(window).scroll(function(){
		if($(this).scrollTop() > 300){
			$(".btn-subir").show();
		}else{
			$(".btn-subir").hide();	
		}
	});

	$(".btn-subir").on('click', function (e) { 
	  e.preventDefault();
	  $("body,html").animate({ 
		scrollTop: 0
	  },800);
	  return false;
	});
});

//CHATBOT//
$(document).ready(function(){
	$(window).scroll(function(){
		if($(this).scrollTop() > 300){
			$(".chat-widget-sofia #ChatAvatarDiv").css("display","none");
		}else{ // si no
			$(".chat-widget-sofia #ChatAvatarDiv").css("display","inherit");			
		}
	});	
});