

(function(){

	// ----------- Menu 2024

	let btn_menu = document.getElementById('btn-menu');
	let desplegable_menu = document.getElementById('desplegable-menu');
	let btn_submenu = document.getElementById('btn-submenu');
	let desplegable_submenu = document.getElementById('desplegable-submenu');
	let img_flecha_submenu = document.getElementById('flecha-submenu');
	let menu_cerrar = document.getElementById('menu-cerrar');

	if(btn_menu)
	{

		btn_menu.addEventListener("click", function(e) {

			if(desplegable_menu.style.display == "none")
			{
				desplegable_menu.style.display = "block";
			}
			else {
				desplegable_menu.style.display = "none";
			}

		});

		if(desplegable_menu)
		{
			desplegable_menu.addEventListener('click', function(e){
				
				if(e.target.id == 'desplegable-menu')
				{
					desplegable_menu.style.display = "none";
				}
			});
		}

		if(menu_cerrar)
		{
			menu_cerrar.addEventListener('click', function(e){
				desplegable_menu.style.display = "none";
			});
		}
	}

	if(btn_submenu)
	{
		
		btn_submenu.addEventListener("click", function(e) {

			if(desplegable_submenu.style.display == "none")
			{
				desplegable_submenu.style.display = "block";
				img_flecha_submenu.src = '/img/ico_arriba_black.png';
			}
			else {
				desplegable_submenu.style.display = "none";
				img_flecha_submenu.src = '/img/ico_abajo_black.png';
			}

		});
	}


	// ----------- FIN Menu 2024

})();



// var _otmenu_ipad = false;
// var _otmenu_iphone = false;

// var _otmenu_ipad = true;
// var _otmenu_iphone = true;

var _otmenu_ipad = (typeof _otmenu_ipad != 'undefined')?_otmenu_ipad:true;
var _otmenu_iphone = (typeof _otmenu_iphone != 'undefined')?_otmenu_iphone:true;


(function( $ ) {
	"use strict";




	/*$( "#menu-btn, #btn-menu-market" ).click(function() {

		if($(this).find("i").hasClass("fa-bars")){
			$(this).html('<i class="fa fa-close fa-2x"></i>');
		}else{
			$(this).html('<i class="fa fa-bars fa-2x"></i>');
		}

		$("#btn-lupa-market").html('<i class="fa fa-search"></i>');

		$( "#desplegable-login" ).hide();
		$('.contenedor-desplegables-market').hide();

		$( "#menu-movil" ).animate({
			top: 0,
			right: 0,
			height: 'toggle'
		},10);
	});*/

	$( "#menu-btn-sabores" ).click(function() {

		$( "#menu-movil" ).animate({
			top: 0,
			right: 0,
			height: 'toggle'
		},10);
	});

	$( "#btn-menu-header" ).click(function() {

		if($(this).find("i").hasClass("fa-bars")){
			$(this).html('<i class="fa fa-close fa-2x"></i>');
		}else{
			$(this).html('<i class="fa fa-bars fa-2x"></i>');
		}

		//$("#btn-lupa-market").html('<i class="fa fa-search"></i>');

		//$( "#desplegable-login" ).hide();
		//$('.contenedor-desplegables-market').hide();

		$( "#menu-header" ).animate({
			top: 48,
			right: 0,
			height: 'toggle'
		},10);
	});

	// Menu de suplementos paginas internas

	$( "#rubros-market-btn" ).click(function() {

		if($(this).find("i").hasClass("fa-chevron-down")){
			$(this).html('<i class="fa fa-chevron-up fa-1x"></i>');
		}else{
			$(this).html('<i class="fa fa-chevron-down fa-1x"></i>'); 
		}
		
		$( "#rubros-market" ).animate({
			top: 0,
			right: 0,
			height: 'toggle'
		},10);
	});

	$( "#btn-lupa-market" ).click(function() {

		if($(this).find("i").hasClass("fa-search")){
			$(this).html('<i class="fa fa-close"></i>');
		}else{
			$(this).html('<i class="fa fa-search"></i>');
		}

		$("#btn-menu-market").html('<i class="fa fa-bars"></i>');
		$("#menu-movil").hide();

		$('.contenedor-desplegables-market').toggle();

	});

	$( "#rubros-market-titulo" ).click(function() {

		if($('#rubros-market-btn').find("i").hasClass("fa-chevron-down")){
			$('#rubros-market-btn').html('<i class="fa fa-chevron-up fa-1x"></i>');
		}else{
			$('#rubros-market-btn').html('<i class="fa fa-chevron-down fa-1x"></i>'); 
		}
		
		$( "#rubros-market" ).animate({
			top: 0,
			right: 0,
			height: 'toggle'
		},10);
	});


	$( "#menu-suple-btn" ).click(function() {

		/*if($(this).find("i").hasClass("fa-chevron-down")){
			$(this).html('<i class="fa fa-chevron-up fa-1x"></i>');
		}else{
			$(this).html('<i class="fa fa-chevron-down fa-1x"></i>'); 
		}*/

		if($(this).find("img").hasClass("flecha-activa")){
			$(this).html('<img src="/img/flecha-abajo.svg">');
		}else{
			$(this).html('<img class="flecha-activa" src="/img/flecha-arriba.svg">'); 
		}
		
		$( "#menu-suplementos" ).animate({
			top: 0,
			right: 0,
			height: 'toggle'
		},10);
	});


	$( "#btn-rubros" ).click(function() {

		$( "#toggle-tienda" ).attr('style','display:none');
		$("#btn-tienda").find("button").html('<i class="fa fa-chevron-down fa-1x"></i>');

		if($(this).find("i").hasClass("fa-chevron-down")){
			$(this).find("button").html('<i class="fa fa-chevron-up fa-1x"></i>');
		}else{
			$(this).find("button").html('<i class="fa fa-chevron-down fa-1x"></i>'); 
		}

		$( "#toggle-rubros" ).animate({
			top: 0,
			right: 0,
			height: 'toggle'
		},10);
	});

	$( "#btn-tienda" ).click(function() {

		$( "#toggle-rubros" ).attr('style','display:none');
		$("#btn-rubros").find("button").html('<i class="fa fa-chevron-down fa-1x"></i>');

		if($(this).find("i").hasClass("fa-chevron-down")){
			$(this).find("button").html('<i class="fa fa-chevron-up fa-1x"></i>');
		}else{
			$(this).find("button").html('<i class="fa fa-chevron-down fa-1x"></i>'); 
		}

		

		$( "#toggle-tienda" ).animate({
			top: 0,
			right: 0,
			height: 'toggle'
		},10);
	});


	$( "#desplegable-login-btn, #btn-usuario-market" ).click(function() {

		if($("#menu-btn").find("i").hasClass("fa-bars fa-2x")){
			
		}else{
			$("#menu-btn").html('<i class="fa fa-bars fa-2x"></i>');
		}

		$("#menu-movil").hide();
		
	  $("#desplegable-login").animate({
		  top: 0,
		  right: 0,
		  height: 'toggle'
		},10);
	});

	/*$( "#menu-btn" ).click(function() {

		var collapse_content_selector = $(this).attr('href');

		var toggle_switch = $(this);

		$(collapse_content_selector).toggle(function(){
		  if($(this).css('display')=='none'){
                            //change the button label to be 'Show'
			
		  }else{
                            //change the button label to be 'Hide'
			
		  }
		});
	});*/

	/*if(_otmenu_ipad) jQuery("body").addClass("ot-menu-ipad-enable");
	if(_otmenu_iphone) jQuery("body").addClass("ot-menu-iphone-enable");

	var _ot_menulist = "";

	jQuery(".ot-menu-add").each(function(){
		var thisel = jQuery(this);
		_ot_menulist = _ot_menulist+"<li><h3>"+thisel.attr('rel')+"<i class='fa fa-bars right'></i></h3></li>"+thisel.html()+"<li><br /></li>";
	});*/

	//jQuery("body").prepend("<a href='/?wall_altauser=1' class='ot-entrar'>Entrar</a><a href='#' class='ot-menu-toggle'><i class='fa fa-bars'></i>Men&uacute;</a>").prepend("<ul id='ot-menu-list' class='ot-menu-list'></ul>").find("#ot-menu-list").html(_ot_menulist);

	/*jQuery(".ot-menu-toggle").click(function(){
		jQuery("body").toggleClass("ot-menu-active");
		return false;
	});*/


})(jQuery);
