var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

$(document).ready(function(){
	
	//formularios
	$("#cerrar_sesion").click(function(){
		window.location.href = "/portal-clientes/?accion=logout";
	})
	
	$("form#form_contacto").validate();
	$("form#postulante_form").validate();
	$("form#distribuidor_form").validate();
	$("form#buscar_nota_tecnica").validate({
	     submitHandler: function(form) { 
            $.ajax({ 
                    type: 'POST', 
                    url: 'buscar', 
                   	data: $('#buscar_nota_tecnica').serialize(), 
                   	dataType: "html",
                    success: function(html) { 
						console.log(html);
						$(".menucito").hide();
						$("#despliegue-resultado ul").empty().append(html);
						$("#despliegue-resultado").show("fast")
                    	
                	}	 
            });
         } 
	});
	
	
	
	
	$("#contactenos_header").click(function(){
		window.location = "/contacto";
	}).css("cursor","pointer");

 
});


$(document).ready(function($) {


	

	
	// ACORDEON NUEVO 1
	//$("#accordion dt:first").addClass("active");
	//$("#accordion dd:not(:first)").hide();
	$("#accordion dd").hide();

	$("#accordion dt").click(function(){
		
		if($(this).attr("id")!=""){
			window.location.href="#"+$(this).attr("id");
		}
	
		$(this).next("dd").slideToggle("slow")
	 	.siblings("dd:visible").slideUp("slow");
	$(this).toggleClass("active");
		$(this).siblings("dt").removeClass("active");
	 });
	
	// ACORDEON NUEVO 2
	//$("#accordion dt:first").addClass("active");
	//$("#accordion dd:not(:first)").hide();
	$("#accordion2 dd").hide();

	$("#accordion2 dt").click(function(){
		$(this).next("dd").slideToggle("slow")
	 	//.siblings("dd:visible").slideUp("slow");
	$(this).toggleClass("active");
		$(this).siblings("dt").removeClass("active");
	 });


	
	/*//Set default open/close settings
	$('#accordion dd').hide(); //Hide/close all containers
	//$('#accordion dt:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

	//On Click
	$('#accordion dt').click(function(){
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('#accordion dt').removeClass('active').next().slideUp("fast"); //Remove all "active" state and slide up the immediate next container
			$(this).toggleClass('active').next().slideDown("fast"); //Add "active" state to clicked trigger and slide down the immediate next container
		}
		return false; //Prevent the browser jump to the link anchor
	});
	
	//acordeon 2
	
	//Set default open/close settings
	$('#accordion2 dd').hide(); //Hide/close all containers
	//$('#accordion2 dt:first').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

	//On Click
	$('#accordion2 dt').click(function(){
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('#accordion2 dt').removeClass('active').next().slideUp("fast"); //Remove all "active" state and slide up the immediate next container
			$(this).toggleClass('active').next().slideDown("fast"); //Add "active" state to clicked trigger and slide down the immediate next container
		}
		return false; //Prevent the browser jump to the link anchor
	});*/
	
	
	
	// TABS EMPRESA
	
	//$("#nuestro-equipo ul").idTabs();
	
	$("#distribuidor_form").hide();
	var form_seleccionado_trabaja = "postulante";
	$("#distribuidor").css("background-image","url('/wp-content/themes/v2/medios/img/btn_inactivo-formulario.jpg')").click(function(){
		$("#postulante").css("background-image","url('/wp-content/themes/v2/medios/img/btn_inactivo-formulario.jpg')");
		$("#postulante_form").hide();
		$("#distribuidor_form").show();
		$("#distribuidor").css("background-image","url('/wp-content/themes/v2/medios/img/btn_activo-formulario.jpg')");
		return false;
	});
	
	
	
	
	$("#postulante").css("background-image","url('/wp-content/themes/v2/medios/img/btn_activo-formulario.jpg')").click(function(){
		$("#postulante").css("background-image","url('/wp-content/themes/v2/medios/img/btn_activo-formulario.jpg')");
		$("#postulante_form").show();
		$("#distribuidor_form").hide();
		$("#distribuidor").css("background-image","url('/wp-content/themes/v2/medios/img/btn_inactivo-formulario.jpg')"); 
		return false;
	});
	
	if (document.location.hash != "") 
	{    
	 var elemento = document.location.hash.replace("#",""); 
		$("#"+elemento).click();
	} 
	
	

});
