 strimg=""+('');
 // Variable que contiene el nodo del árbol al desplegar
	var id_menu_actual = '';
	// Arrays con la información necesaria para mostrar el menú
	var nivel = new Array();
	var id_menu = new Array();
	var id_menu_sup = new Array();
	var orden = new Array();
	var descripcion = new Array();
	var enlace = new Array();	
	var nivelAux = new Array();
	var id_menuAux = new Array();
	var id_menu_supAux = new Array();
	var ordenAux = new Array();
	var descripcionAux = new Array();
	var enlaceAux = new Array();				

	orden[0]="3";
	nivel[0]="1";
	id_menu[0]="130";
	id_menu_sup[0]="";
	descripcion[0]="Menu Campus Como Usar";
	
	   enlace[0]="/Vodafone/Campus/Campus/0,1463,2224,00.html";		
	 
	orden[1]="1";
	nivel[1]="2";
	id_menu[1]="122";
	id_menu_sup[1]="130";
	descripcion[1]="Encuéntrelo en Campus";
	
	   enlace[1]="/Vodafone/Campus/Campus/0,1463,2222,00.html";		
	 
	orden[2]="2";
	nivel[2]="2";
	id_menu[2]="123";
	id_menu_sup[2]="130";
	descripcion[2]="Mapa de cursos";
	
	   enlace[2]="/Vodafone/Campus/MapaCampus/0,1467,9458,00.html";		
	 
	orden[3]="3";
	nivel[3]="2";
	id_menu[3]="124";
	id_menu_sup[3]="130";
	descripcion[3]="Metodología";
	
	   enlace[3]="/Vodafone/Campus/Campus/0,1463,2233,00.html";		
	 
	orden[4]="4";
	nivel[4]="2";
	id_menu[4]="125";
	id_menu_sup[4]="130";
	descripcion[4]="At@jos";
	
	   enlace[4]="/Vodafone/Campus/Campus/0,1463,4900,00.html";		
	 
	orden[5]="5";
	nivel[5]="2";
	id_menu[5]="126";
	id_menu_sup[5]="130";
	descripcion[5]="Nuestra Visión";
	
	   enlace[5]="/Vodafone/Campus/Campus/0,1463,2235,00.html";		
	 function muestraArrayPath(array) {
	var str = new String("");
	for (i=array.length-1; i >= 0; i--) {
		str=str+id_menu[array[i]]+" ";
	}
	return str;
}

function muestraArrayStringArbol(array) {
	var str = new String("");
	var strBasura;
	var id_nodo=document.frmmenucda.nodo.value;
	if (id_nodo!="") {
		var indice_nodo=generaIndiceNodo(id_nodo);
		var id_hijo=obtieneHijo(id_nodo);
		var indice_hijo=generaIndiceNodo(id_hijo);
		var indice_padre=generaPadreIndice(indice_nodo);
		var indice_abuelo=generaPadreIndice(indice_padre);
	} else {
		var indice_nodo="";
	}
	str='<TABLE WIDTH="142" CELLSPACING="0" CELLPADDING="0" BORDER="0"><TR><TD VALIGN="TOP">';
	if (strimg!="")	str+= '<IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" border=0 WIDTH="142" HEIGHT="10">';
	var level="";
	for (i=0; i < array.length; i++) {
		var levelant=level;
		level = "" + nivel[array[i]];
		if (level == "2") {
				/* Aqui toco primer nivel */ strBasura='<TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_lines.gif" WIDTH="142" HEIGHT="1"></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR><TR><TD VALIGN="TOP"><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" onmouseover="window.status=\'Abrir opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_arrow2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT></A>'
		} else if (level == "3") {
				strBasura='<TR><TD VALIGN="TOP"><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" onmouseover="window.status=\'Abrir opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_arrow2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT></A>'
		} else {
				strBasura='<TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="5" HEIGHT="1" ALIGN=LEFT><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_arrow2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT>'
		}
		var tienehijos="si";
		var rojo="no";
		var cerrar="no";
		if (level == "2") {

			if ((parseInt(level)==parseInt(levelant)-1)||(parseInt(level)==parseInt(levelant)-2)) {str = str+'</table></td></tr>'}
			if (indice_nodo!="") {
				if ((document.frmmenucda.lista_path.value.indexOf(id_hijo)!=-1)&&(array[i]==indice_nodo)) {
					if (document.frmmenucda.lista_path.value.indexOf(id_hijo)==0) { //SIN HIJOS
						tienehijos="no";
						rojo="si";
						strBasura='<TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_lines.gif" WIDTH="142" HEIGHT="1"></TD></TR><TR><TD VALIGN="TOP" ><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/red_arrowfilled2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT>'
					} else { // CON HIJOS
						rojo="si";
						strBasura='<TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_lines.gif" WIDTH="142" HEIGHT="1"></TD></TR><TR><TD VALIGN="TOP" BACKGROUND="/Vodafone/Componentes/Imagenes/sub_nav_bak.gif"><TABLE BORDER="0"  WIDTH="142" CELLSPACING="0" CELLPADDING="0"><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR><TR><TD VALIGN="TOP"><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" onmouseover="window.status=\'Cerrar opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_redarrow2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT></A>'
					}
				} else if (indice_padre==array[i]) {
						rojo="si";
						strBasura='<TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_lines.gif" WIDTH="142" HEIGHT="1"></TD></TR><TR><TD VALIGN="TOP" BACKGROUND="/Vodafone/Componentes/Imagenes/sub_nav_bak.gif"><TABLE  BORDER="0" WIDTH="142" CELLSPACING="0" CELLPADDING="0"><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR><TR><TD VALIGN="TOP"><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" onmouseover="window.status=\'Cerrar opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_redarrow2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT></A>';
				} else if (indice_abuelo==array[i]) {
						rojo="si";
						strBasura='<TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_lines.gif" WIDTH="142" HEIGHT="1"></TD></TR><TR><TD VALIGN="TOP" BACKGROUND="/Vodafone/Componentes/Imagenes/sub_nav_bak.gif"><TABLE BORDER="0" WIDTH="142" CELLSPACING="0" CELLPADDING="0"><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR><TR><TD VALIGN="TOP"><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" onmouseover="window.status=\'Cerrar opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_redarrow2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT></A>';
				}
			}
			if (enlace[array[i]]=="") {
				if (tienehijos=="si") {
					if (rojo=="si") {
						/* Aqui toco 2º nivel */ str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" CLASS="headingred" onmouseover="window.status=\'Cerrar opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;">'+descripcion[array[i]]+' </A></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>'																				
					} else {
						/* AQUI toco primer nivel */str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" CLASS="submenu" onmouseover="window.status=\'Abrir opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;">'+descripcion[array[i]]+' </A></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>'															
					}
				} else {
						str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><span class="headingred">'+descripcion[array[i]]+'</span></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>'																						
				}
			} else {

				if (rojo=="si") {
					/* Aqui toco 2º nivel */str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><A HREF="'+enlace[array[i]]+'" CLASS="headingred">'+descripcion[array[i]]+' </A></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>'								
				} else {
					/* Aqui toco el primer nivel */ str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><A HREF="'+enlace[array[i]]+'" CLASS="submenu">'+descripcion[array[i]]+' </A></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>'								
				}
			}

		} else if (level == "3") {		
				if (indice_nodo!="") {
					if ((document.frmmenucda.lista_path.value.indexOf(id_hijo)!=-1)&&(array[i]==indice_nodo)) {
						if (document.frmmenucda.lista_path.value.indexOf(id_hijo)==0) {
							tienehijos="no";
							cerrar="si";
							strBasura='<TR><TD VALIGN="TOP"><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" onmouseover="window.status=\'Cerrar opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;"><IMG SRC="/Vodafone/Componentes/Imagenes/red_arrowfilled2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT></A>';
						} else {
						cerrar="si";
						strBasura='<TR><TD VALIGN="TOP"><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" onmouseover="window.status=\'Cerrar opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_redarrow2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT></A>';
						}
					} else if (indice_padre==array[i]) {
						cerrar="si";
						strBasura='<TR><TD VALIGN="TOP"><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" onmouseover="window.status=\'Cerrar opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_redarrow2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT></A>';
					}
				}
				if (enlace[array[i]]=="") {
					if (tienehijos=="si") {
						if (cerrar=="si") {
							str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" class="submenu2" onmouseover="window.status=\'Cerrar opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;">'+descripcion[array[i]]+' </A></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>'																
						} else {
							/* Aqui toco 2º nivel */str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><A HREF="javascript:document.frmmenucda.nodo.value='+id_menu[array[i]] +'; despliegaArbolPrueba();" class="submenu2" onmouseover="window.status=\'Abrir opciones de '+descripcion[array[i]]+'\';return true;" onmouseout="window.status=\'\';return true;">'+descripcion[array[i]]+' </A></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>'																
						}
					} else {
						str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD>'+descripcion[array[i]]+' </TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>'																	
					}
				} else {
					/* Aqui toco 2º nivel */ str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><A HREF="'+enlace[array[i]]+'" CLASS="submenu2">'+descripcion[array[i]]+' </A></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>'				
				}

		} else if (level == "4") {
			if ((document.frmmenucda.lista_path.value.indexOf(id_hijo)!=-1)&&(array[i]==indice_nodo)) {
				strBasura='<TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="5" HEIGHT="1" ALIGN=LEFT><IMG SRC="/Vodafone/Componentes/Imagenes/red_arrowfilled2.gif" WIDTH="5" HEIGHT="9" BORDER="0" ALIGN=LEFT>';
			}
			if (enlace[array[i]]=="") {
					/* Aqui toco en el 3er nivel */ str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><SPAN CLASS="submenu3">'+descripcion[array[i]]+'</SPAN></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>';		
			} else {
					/* Aqui toco en el 3er nivel */ str=str+strBasura+'<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD><A HREF="'+enlace[array[i]]+'" CLASS="submenu3">'+descripcion[array[i]]+'</A></TD></TR></TABLE></TD></TR><TR><TD VALIGN="TOP"><IMG SRC="/Vodafone/Componentes/Imagenes/pixel.gif" WIDTH="142" HEIGHT="3"></TD></TR>';					
			}
		}
	}
	if ((levelant=="3") || (levelant=="4")) {str = str+'</table></td></tr>'}
	str=str+'<TR><TD VALIGN="BOTTOM"><IMG SRC="/Vodafone/Componentes/Imagenes/sub_nav_lines.gif" WIDTH="142" HEIGHT="1"></TD></TR></TABLE>';
	return str;
}

function generaIndiceNodo(id_nodo) {for (i=0; i < id_menu.length; i++) {if (id_menu[i]==id_nodo) {return i;}}}

function generaIndiceNodoSup(id_nodo) {
for (a=0; a < id_menu_sup.length; a++) {
	if (id_menu_sup[a]==id_nodo) {
		return a;
	}
}
return ""
}

function generaPadreIndice(j) {return  generaIndiceNodo(id_menu_sup[j]);}

function obtieneHijo(id) {
	if (generaIndiceNodoSup(id)=="") {return ""} else {return (id_menu[generaIndiceNodoSup(id)]);}
}

function generaPathIndice(i) {
	var arrayPath =new Array();
	var indiceAuxiliar = i;
	// Bucle en el que calculamos el padre en cada nivel
	for (cont=0; cont < nivel[i]; cont++) {	
		arrayPath[cont]=indiceAuxiliar;
		//alert('indice'+arrayPath[cont]+' || id_menu : '+id_menu[indiceAuxiliar])
		indiceAuxiliar=generaPadreIndice(indiceAuxiliar);
	}
	return arrayPath;
}

// Recorre todo el arbol, crea una array con los nodos que se van a desplegar
function despliegaArbol(id_nodo) {
	//Arrays resultado con los indices de los nodos ordenados según se muestran al desplegar el arbol 	 
	var indicesIzq = new Array();
	var indicesDra = new Array();

	//Variables auxiliares
	
	var indice=generaIndiceNodo(id_nodo);
	var arrayBuscado = generaPathIndice(indice);
	var arrayAuxiliar = new Array();	
	var ordenBuscado = orden[indice];
	var nivelBucle;	
	var nivelBucleAnterior=0;		
	var ordenBucle;
	var id_padreBuscado = '';
	for (i=0; i < id_menu.length; i++) {
		nivelBucle = nivel[i];
		id_padreBucle = id_menu_sup[i];
		ordenBucle = orden[i];
		ordenBuscado = orden[arrayBuscado[arrayBuscado.length-nivelBucle]];
		id_padreBuscado = id_menu_sup[arrayBuscado[arrayBuscado.length-nivelBucle]];
		if (nivelBucle!=nivelBucleAnterior) {
			// Reseteo el array dentro de un nivel para comenzar a ordenar
			indicesDra=arrayAuxiliar.concat(indicesDra);			
			arrayAuxiliar = new Array();
		}		
		if (id_padreBucle==id_padreBuscado || id_padreBucle=='') {
			if (parseInt(ordenBucle)<=parseInt(ordenBuscado)) {
				indicesIzq[indicesIzq.length]=i
//				indicesIzq.push(i);
			} else {
				arrayAuxiliar[arrayAuxiliar.length]=i			
//				arrayAuxiliar.push(i);
			}
		}
		nivelBucleAnterior=nivelBucle;
	}
	indicesDra=arrayAuxiliar.concat(indicesDra);
	return indicesIzq.concat(indicesDra);
}

function despliegaArbolPrueba() {
	var n4 = (document.layers)? true:false;
	var ie = (document.all)? true:false;
	var n6 = (document.getElementById)? true:false;
	var id_nodo=document.frmmenucda.nodo.value;
	if (id_nodo=="") {
		id_nodo=122 } else {
		var id_alt=obtieneHijo(id_nodo)
		if (document.frmmenucda.lista_path.value.indexOf(id_alt)==-1) {
			if (id_alt!="") {id_nodo=id_alt}
		}
	};
	arrResultadoArbol=despliegaArbol(id_nodo);
	arrResultadoArbol=arrResultadoArbol.slice(1,arrResultadoArbol.length);
	indiceAux=generaIndiceNodo(id_nodo);
	arrResultadoPath=generaPathIndice(indiceAux);
	arrResultadoPath=arrResultadoPath.slice(0,arrResultadoPath.length-1);
	document.frmmenucda.lista_path_ant.value=document.frmmenucda.lista_path.value;
	document.frmmenucda.lista_path.value=muestraArrayPath(arrResultadoPath);
	strMenu=muestraArrayStringArbol(arrResultadoArbol);
	if (ie) {document.all['padre'].innerHTML=strimg+""+strMenu;
	} else if (n4) {
//	  document.frmmenucda.codigo.value=strMenu;
	  document.capans.document.Layer1.document.write(strimg+strMenu);
	  document.capans.document.Layer1.document.close();
	} else if (n6) {
		document.getElementById('padre').innerHTML=""+strimg+strMenu;
	}
}

