jQuery(function()
{

	// EL BUSCADOR
	jQuery("#tx_indexedsearch_boton").click(function(){jQuery("#tx_indexedsearch2").submit()});
	jQuery("#tx_indexedsearch_caja").focus(function(){jQuery(this).val("")});
	
	jQuery("#tx_indexedsearch2").submit(function() {
		var car = jQuery("#tx_indexedsearch_caja").val().length;
		if (car<2||car>200)
		{
			alert ("Sólo son aceptadas palabras con 2 o más caracteres.\nMáximo 200 caracteres.");
			return false;
		}
		else
		{
			return true;
		}
	});
	
	
	// Menu categorias tt_news en agenda
	// Ocultamos nivel2
	jQuery("div.level1:has(div.level2)").hide();
	
});


// Menu Areas Temáticas (se llama en el template main)
function menu_areas()
{
	var output = '<select name="areas-tematicas" id="areas-tematicas">';
	output += '<option value="0">Seleccione un tema</option>';
	jQuery("#areas ul li").each(function()
	{
		$this = jQuery(this);
		var url = $this.children("a").attr("href");
		var selected = $this.hasClass("current") ? ' selected="selected"' : '';
		output += '<option value="'+url+'"'+selected+'>' + $this.text() + '</option>';
	});
	output += '</select>';
	
	jQuery("#areas").append(output).children("ul").remove();
	jQuery("select#areas-tematicas").change(function()
	{
		if (this.selectedIndex > 0)
		{
			$this = jQuery(this);
			document.location.href = "/"+$this.val();
		}
	});	
}
