/* MENUS CARPETA SEPIN *************************************************************/	 
function MostrarMenuConCarpetas(IdElementos, IdContenedor){

	var Todos = "#" + IdElementos + ">li";
	var Primero = "#" + IdElementos + ">li:first";
	var Resto = "#" + IdElementos + ">li:not(:first)";	//Incluye el texto en un div	$(Primero + "," + Resto).each(function(){		$(this).html("<div>" + $(this).html() + "</div>");
	});	
	$("#" + IdElementos).addClass("conenedor_elementos_carpeta_sepin");
	$(Primero).addClass("elemento_carpeta_sepin_seleccionado");
	$(Resto).addClass("elemento_carpeta_sepin");
	
	MostrarMenuConCarpetasCargarContenido($(Primero).attr("ref"), IdContenedor);
	
	$(Todos).click(function(){
		if($(this).hasClass("elemento_carpeta_sepin")){
			MostrarMenuConCarpetasCargarContenido($(this).attr("ref"), IdContenedor);
			$(".elemento_carpeta_sepin_seleccionado").addClass("elemento_carpeta_sepin");
			$(".elemento_carpeta_sepin_seleccionado").removeClass("elemento_carpeta_sepin_seleccionado");
			$(this).addClass("elemento_carpeta_sepin_seleccionado");
			$(this).removeClass("elemento_carpeta_sepin");
		}	});
}
function MostrarMenuConCarpetasCargarContenido(URL, IdContenedor){

	if(URL != ""){
		$.ajax({
			type: "GET", 
			url: URL,
			cache: false,
			async: true,
			success: function(html){
				$("#" + IdContenedor).html(html);
			},
			error:	function(){				
				alert("Error en la operación");
			}
		});
	}
}
/***********************************************************************************/	 
/* MENU ROMBOS *********************************************************************/function MostrarMenuRombos(IdElementos, IndiceSeleccionado){
	var html;
	var Todos = "#" + IdElementos + ">li";
	var Seleccionado = "#" + IdElementos + ">li:eq(" + IndiceSeleccionado + ")";
	var Resto = "#" + IdElementos + ">li:not(:eq(" + IndiceSeleccionado + "))";	$("#" + IdElementos).attr("class", "conenedor_elementos_rombos");

	$(Todos).attr("class", "elemento_rombo");
	
	//monta el rombo completo con 3 divs	$(Seleccionado).each(function(){
		var html;
		html = "<div class='elemento_rombo_izquierda'><img src='/comunes/imagenes/menus/rombos/negro/izquierda.png' /></div>";
		html = html + "<div class='elemento_rombo_centro_negro'>" + $(this).html() + "</div>";		html = html + "<div class='elemento_rombo_derecha'><img src='/comunes/imagenes/menus/rombos/negro/derecha.png' /></div>";
		$(this).html(html);
	});	$(Resto).each(function(){
		var html;		html = "<div class='elemento_rombo_izquierda'><img src='/comunes/imagenes/menus/rombos/verde/izquierda.png' /></div>";
		html = html + "<div class='elemento_rombo_centro_verde'>" + $(this).html() + "</div>";		html = html + "<div class='elemento_rombo_derecha'><img src='/comunes/imagenes/menus/rombos/verde/derecha.png' /></div>";
		$(this).html(html);
	});	//Ajusta el margen para que se monten por la izquierda los rombos que nos son el primero	$(Todos + "").css("margin-left", "-12px");		html = "<li class='elemento_rombo_izquierda_fijo'></li>";	$("#" + IdElementos).prepend(html);	//AnimarMenuRombos(IdElementos);	$("#" + IdElementos).show();
}

function AnimarMenuRombos(IdElemento){

	var obj = $("#" + IdElemento)

	var ancho_final = $(obj).width();

	$(obj).width(0);
	
	$(obj).css({
		opacity:		0
	});
	//$(obj).animate({opacity: 0}, 600);
	$(obj).animate({
		width:		ancho_final,
		opacity:	1
	}, 300);
}
/***********************************************************************************/	 
/* MENU BBDD ***********************************************************************/function MostrarMenuBBDD(IdElementos, IndiceSeleccionado){

	var Seleccionado = "#" + IdElementos + ">li:eq(" + IndiceSeleccionado + ")";
	
	$(Seleccionado).html($(Seleccionado).text());
	$(Seleccionado).css("font-weight", "bold");
	$("#" + IdElementos).show();
}
/***********************************************************************************/	 
/* MENU TITULOS CON DESPLEGABLE ***********************************************/
function MenuTituloConDesplegable(IdElementos){

	var Todos = "#" + IdElementos + ">li";			$(Todos).each(function(){
		var Opciones = eval("(" + $(this).attr("ref") + ")");		if(Opciones){			var ElementoOculto = "#" + Opciones.idDestino;			var ContenedorOculto = $(ElementoOculto).clone();
						$(ElementoOculto).remove();
						$(this).attr("class", "ElementoMenuTituloConDesplegable"); 			$(this).html("<div class='TituloElementoMenuTituloConDesplegable'>" + Opciones.Titulo + "</div><div>" + $(this).html() + "</div>");
			$(this).children("div:eq(0)").append("<img src='/comunes/imagenes/flecha_down.png'>");
			$(ContenedorOculto).insertAfter($(this).children("div:eq(1)"));						$(this).css({
				clear:		"both"			});
			$(this).children("div:eq(0)").css({				float:		"left"
			});			$(this).children("div:eq(1)").css({				float:		"left",				paddingTop:	"11px"
			});			$(this).children("div:eq(2)").css({				clear:		"both"			});						if(Opciones.Seleccionado != true)
				$(this).children("div:eq(2)").css("display", "none");			else		
				if(Opciones.Funcion)
					eval(Opciones.Funcion);					

			$(this).children("div:eq(0)").click(function(){				
				//if($(this).next().next().css("display") == "none"){
									//$(this).parent().parent().children("li").each(function(){						//$(this).children("div:eq(2):visible").slideToggle();
					//});													$(this).next().next().slideToggle();	//Muestra el div destino
									//Ejecuta la función indicada en el parámetro Funcion, si la hubiera.					if(Opciones.Funcion){
						eval(Opciones.Funcion);					}
									//}				
			});			
		}
	});	}
/***********************************************************************************/	 
