var idAnteriorPadre;  
anchoTabla = 150;
tamanoLetra = "";
nivelAnt = 1;
strBlancos = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
strBlanco = "&nbsp;";
strTexto = "";
muestraHijo = false;
bEstoyEnHijo = false;
ultId = "";
var imagen;
var imagenTrans;
var anchoCol1=10;		
var anchoCol2= anchoTabla - anchoCol1;
var posMascara=altura_y+1;
var primernivel=1;
tamanoFuente=10;


function hand(){}

function construirTabla(id,nivel)
	{	
		var cellpadding=(document.all)?2:0;				
		
		arrHijo = niveles[id].split("@");
		arrPadre = niveles[idPadre].split("@");                
        //Si la longitud de la cabecera es mayor de una cierta longitud y no tiene blancos le cambio el tamaño de la letra para que quepa
	if (cabecera.search(' ') == -1)
		{//sino tiene blancos pregunto por la longitud
			if (cabecera.length > 16)
			{tamanoFuente=9
			}
			else
			{tamanoFuente=10
			}
		}	

	strHTML='<table bgcolor='+ color1 +' border=0 style="border-color:'+ borde +';border-width:1px 1px 1px 1px;border-style:solid;" cellpadding=' + cellpadding + ' cellspacing=0 width=' + anchoTabla + '>';        
        //strHTML+= "<tr><td height=20 align=left></td><td><font face=\"arial\" size=\"2\" color=\"white\"><b>" + cabecera + "</b></font></td></tr>";
      	//strHTML+= "<tr><td height=20 align=left></td><td><font face=\"arial\" size=\"" + tamanoFuente + "\" color=\"white\"><b>" + cabecera + "</b></font></td></tr>";
	strHTML+= "<tr><td height=20 align=left></td><td><font face=\"arial\" color=\"white\" style=\"font-size:" + tamanoFuente + "pt\"><b>" + cabecera + "</b></font></td></tr>";

        rows = arrPadre.length;
        
        //Nuevo: Linea azul horizontal
        if(document.all)
			strHTML+= "<tr><td bgcolor="+ linea_principal +" height=1 colspan=2></td></tr>";
		else
		{									
			imagenlineaNTS="images/1pixelblue.gif";
			strHTML+= "<tr><td height=1 colspan=2 width=" + anchoTabla + "><img width=" + anchoTabla + " height=1px border=0 src='" + imagenlineaNTS + "'></td></tr>";				
		}
        
        for(j=0;j<rows;j++)
        
			{
				arrTxt = arrPadre[j].split("|");
				imagen = " src='images/mas.gif'";
				imagenTrans = " src='images/trans.gif'";				
				
								
				if(document.all){
					//explorer										
					
					if (!muestraHijo)
						{
							ultId = ""
							strHTML+= "<tr>";
							
							
							idImagen = "ima" + arrTxt[1];
							
							
							
							//Los departamentos que tengan tres caracteres de longitud no deben tener link en el menu.
							if (arrTxt[1].length == 3)
								{
									strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";'><img width=10px height=10px border=0 id=" + idImagen + imagenTrans + "></td>";
									strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";'><b>" + arrTxt[0].toLowerCase() + "</b></td>";
								
								}										
							else	
								{
									if (existeDept(arrTxt[1]))
										{
											strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verDpt('" + arrTxt[1] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";'><img width=10px height=10px border=0 style='cursor:hand;' id=" + idImagen + imagenTrans + "></td>";
											strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verDpt('" + arrTxt[1] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";'>" + arrTxt[0].toLowerCase() + "</td>";
										}
									else
										{
											strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verTercer('" + arrTxt[1] + "','" + 'sinHijos' + "','" + arrTxt[0] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";'><img width=10px height=10px border=0 id=" + idImagen + imagenTrans + " width=10px height=10px></td>";
											strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verTercer('" + arrTxt[1] + "','" + 'sinHijos' + "','" + arrTxt[0] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";'>" + arrTxt[0].toLowerCase() + "</td>";
										}							
								}
								
								
								
							strHTML+= "</tr>";
							//Nuevo: Linea separación horizontal azul; en nestscape genera un linea en blanco
							strHTML+= "<tr><td bgcolor="+ linea_secundaria +" height=1 colspan=2></td></tr>";						
						}
					else
						{							
							
							//Voy escribiendo los padres, pero controlo el momento en el que llega el hijo.
																			
							if (arrTxt[1] == id){imagen = " src='images/menos2.gif'";}
							else{imagen = " src='images/mas.gif'";}
							idImagen = "ima" + arrTxt[1];
							
							strHTML+= "<tr>";														
							
							
							//Controlo que el padre tiene 3 caracteres. Si tiene 3 caracteres no debe sacar link
							
							if (arrTxt[1].length == 3)
								{
									if (existeDept(arrTxt[1]))
										{
											if (arrTxt[1] == id)
												{
													//Se marca con una flecha hacia abajo
													strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";' bgcolor="+ seleccion +"><img width=10px height=10px border=0 style='cursor:hand;' name=ima" + arrTxt[1] + imagen + "></td>";
													strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";' bgcolor="+ seleccion +"><b>" + arrTxt[0].toLowerCase() + "</b></td>";																						
												}
											else	
												{
													strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";'><img width=10px height=10px border=0 style='cursor:hand;' name=ima" + arrTxt[1] + imagenTrans + "></td>";
													strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\"  height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";'><b>" + arrTxt[0].toLowerCase() + "</b></td>";											
												}
											
											strHTML+= "</tr>";
											strHTML+= "<tr><td bgcolor="+ linea_secundaria +" height=1 colspan=2></td></tr>";
										}								
									else
										{
											strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";'><img border=0 name=" + idImagen + imagenTrans + " width=10px height=10px></td>";
											strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";'><b>" + arrTxt[0].toLowerCase() + "</b></td>";
											strHTML+= "</tr>";
											strHTML+= "<tr><td bgcolor="+ linea_secundaria +" height=1 colspan=2></td></tr>";
										}					
																
								}
							else			
								{
									if (existeDept(arrTxt[1]))
										{
											if (arrTxt[1] == id)
												{
													//Se marca con una flecha hacia abajo
													strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verDpt('" + arrTxt[1] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";' bgcolor="+ seleccion +"><img width=10px height=10px border=0 style='cursor:hand;' name=ima" + arrTxt[1] + imagen + "></td>";
													strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verDpt('" + arrTxt[1] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";' bgcolor="+ seleccion +">" + arrTxt[0].toLowerCase() + "</td>";																						
												}
											else	
												{
													strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verDpt('" + arrTxt[1] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";'><img width=10px height=10px border=0 style='cursor:hand;' name=ima" + arrTxt[1] + imagenTrans + "></td>";
													strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verDpt('" + arrTxt[1] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";'>" + arrTxt[0].toLowerCase() + "</td>";											
												}
											
											strHTML+= "</tr>";
											strHTML+= "<tr><td bgcolor="+ linea_secundaria +" height=1 colspan=2></td></tr>";
										}								
									else
										{
											strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verTercer('" + arrTxt[1] + "','" + 'sinHijos' + "','" + arrTxt[0] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";'><img border=0 name=" + idImagen + imagenTrans + " width=10px height=10px></td>";
											strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" onClick=\"JavaScript:{verTercer('" + arrTxt[1] + "','" + 'sinHijos' + "','" + arrTxt[0] + "');}\" height=20 align=left style='cursor:hand;font-size:10pt;font-family: arial; color:"+ texto1 +";'>" + arrTxt[0].toLowerCase() + "</td>";
											strHTML+= "</tr>";
											strHTML+= "<tr><td bgcolor="+ linea_secundaria +" height=1 colspan=2></td></tr>";
										}																					
								}							
							
							//Hijos desplegados.
							if (arrTxt[1] == id)
								{		
									idAnteriorPadre = id;
									rowsHijo = arrHijo.length;
        								        						
        							for(i=0;i<rowsHijo;i++)
										{
											arrTxtHijo = arrHijo[i].split("|");
											strHTML+= "<tr>";
												
											//Si ya ha pulsado una opción de segundo nivel, hay que dejarla marcada										
																						
											
											if (idMarca == arrTxtHijo[1])
												{
													strHTML+= "<td id=celda1" + arrTxtHijo[1] + " onMouseOver=\"JavaScript:{cambiaOp('" + arrTxtHijo[1] + "');}\"  onMouseOut=\"JavaScript:{salirOp('" + arrTxtHijo[1] + "');}\" onClick=\"JavaScript:{verTercer('" + arrTxtHijo[1] + "','" + '' + "','" + arrTxtHijo[0] + "');}\" bgcolor=#59ACD5 height=20 style='cursor:hand;font-size:8pt;font-family: arial; color:"+ texto2+";'></td>";
													strHTML+= "<td id=celda" + arrTxtHijo[1] + " onMouseOver=\"JavaScript:{cambiaOp('" + arrTxtHijo[1] + "');}\"  onMouseOut=\"JavaScript:{salirOp('" + arrTxtHijo[1] + "');}\" onClick=\"JavaScript:{verTercer('" + arrTxtHijo[1] + "','" + '' + "','" + arrTxtHijo[0] + "');}\" bgcolor=#59ACD5 height=20 style='cursor:hand;font-size:8pt;font-family: arial; color:"+ texto2+";'>" + arrTxtHijo[0].toLowerCase() + "</td>";										
												}
											else	
												{
													strHTML+= "<td id=celda1" + arrTxtHijo[1] + " onMouseOver=\"JavaScript:{cambiaOp('" + arrTxtHijo[1] + "');}\"  onMouseOut=\"JavaScript:{salirOp('" + arrTxtHijo[1] + "');}\" onClick=\"JavaScript:{verTercer('" + arrTxtHijo[1] + "','" + '' + "','" + arrTxtHijo[0] + "');}\" bgcolor="+ color2 +" height=20 style='cursor:hand;font-size:8pt;font-family: arial; color:"+ texto2+";'></td>";
													strHTML+= "<td id=celda" + arrTxtHijo[1] + " onMouseOver=\"JavaScript:{cambiaOp('" + arrTxtHijo[1] + "');}\"  onMouseOut=\"JavaScript:{salirOp('" + arrTxtHijo[1] + "');}\" onClick=\"JavaScript:{verTercer('" + arrTxtHijo[1] + "','" + '' + "','" + arrTxtHijo[0] + "');}\" bgcolor="+ color2 +" height=20 style='cursor:hand;font-size:8pt;font-family: arial; color:"+ texto2+";'>" + arrTxtHijo[0].toLowerCase() + "</td>";
												}									

											strHTML+= "</tr>";
											strHTML+= "<tr><td bgcolor="+ linea_secundaria +" height=1 colspan=2></td></tr>"

										}
								}											
																				
						}
				}
				else{										
					//netscape																																																								
					if (!muestraHijo)
						{
							ultId = ""
							strHTML+= "<tr>";							
							
							idImagen = "ima" + arrTxt[1];
							
							//Los departamentos que tengan tres caracteres de longitud no deben tener link en el menu.
							if (arrTxt[1].length == 3)
								{
									strHTML+= "<td id=celda1" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";'><img width=10px height=10px border=0 id=" + idImagen + imagenTrans + "></td>";
									strHTML+= "<td id=celda" + arrTxt[1] + " onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "');}\"  onMouseOut=\"JavaScript:{salir('" + arrTxt[1] + "');}\" height=20 align=left style='font-size:10pt;font-family: arial; color:"+ texto1 +";'><b>" + arrTxt[0].toLowerCase() + "</b></td>";
								
								}										
							else	
								{
																
									if (existeDept(arrTxt[1]))
										{										
											strHTML+= "<td height=20 width=" + anchoCol1 + " align=left><img width=10px height=10px border=0 name=" + idImagen + " id=" + idImagen + imagenTrans + "></td>";
											strHTML+= "<td nowrap height=20 width=" + anchoCol2 + " align=left ><a style=\"text-decoration:none\" href=\"JavaScript:{hand();}\" onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "','" + arrTxt[0] + "',true,'#1084AF');}\"><img width=1px height=1px border=0 name=Marcador1" + idImagen + " id=Marcador1" + idImagen + imagenTrans + "><font face=\"arial\" size=\"2\" color="+ texto1 +">" + arrTxt[0].toLowerCase() + "</font></a><img width=1px height=1px border=0 name=Marcador2" + idImagen + " id=Marcador2" + idImagen + imagenTrans + "></td>";
										}
									else
										{									
											strHTML+= "<td height=20 width=" + anchoCol1 + " align=left><img width=10px height=10px border=0 name=" + idImagen + " id=" + idImagen + imagenTrans + "></td>";
											strHTML+= "<td nowrap height=20 width=" + anchoCol2 + " align=left><a style=\"text-decoration:none\" href=\"JavaScript:{hand();}\" onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "','" + arrTxt[0] + "',false,'#1084AF');}\"><img width=1px height=1px border=0 name=Marcador1" + idImagen + " id=Marcador1" + idImagen + imagenTrans + "><font face=\"arial\" size=\"2\" color="+ texto1 +">" + arrTxt[0].toLowerCase() + "</font></a><img width=1px height=1px border=0 name=Marcador2" + idImagen + " id=Marcador2" + idImagen + imagenTrans + "></td>";
										}
								}
							
							strHTML+= "</tr>";
							//Nuevo: Linea separación horizontal azul; en nestscape genera un linea en blanco
							strHTML+= "<tr><td height=1 colspan=2 width=" + anchoTabla + "><img width=" + anchoTabla + " height=1px border=0 src='" + imagenlineaNTS + "'></td></tr>";				
						}
					else
						{																												
							
							//Voy escribiendo los padres, pero controlo el momento en el que llega el hijo.
																			
							if (arrTxt[1] == id){imagen = " src='images/menos2.gif'";}
							else{imagen = " src='images/mas.gif'";}
							idImagen = "ima" + arrTxt[1];
							
							strHTML+= "<tr>";
														
							if (existeDept(arrTxt[1]))
								{
									if (arrTxt[1] == id)
										{													
											//Se marca con una flecha hacia abajo											
											strHTML+= "<td height=20 width=" + anchoCol1 + " align=left bgcolor="+ seleccion +"><img width=10px height=10px border=0 id=ima" + arrTxt[1] + " name=ima" + arrTxt[1] + imagen + "></td>";
											strHTML+= "<td nowrap height=20 width=" + anchoCol2 + " align=left bgcolor="+ seleccion +"><a href=\"JavaScript:{verDpt('" + arrTxt[1] + "');}\"><img width=1px height=1px border=0 name=Marcador1" + idImagen + " id=Marcador1" + idImagen + imagenTrans + "><font face=\"arial\" size=\"2\" color="+ texto1 +">" + arrTxt[0].toLowerCase() + "</font></a><img width=1px height=1px border=0 name=Marcador2" + idImagen + " id=Marcador2" + idImagen + imagenTrans + "></td>";																																	
											strHTML+= "</tr>";																																												
										}
									else	
										{											
											strHTML+= "<td height=20 width=" + anchoCol1 + " align=left><img width=10px height=10px border=0 id=ima" + arrTxt[1] + " name=ima" + arrTxt[1] + imagenTrans + "></td>";
											strHTML+= "<td nowrap height=20 width=" + anchoCol2 + " align=left><a style=\"text-decoration:none\" href=\"JavaScript:{hand();}\" onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "','" + arrTxt[0] + "',true,'#1084AF');}\"><img width=1px height=1px border=0 name=Marcador1" + idImagen + " id=Marcador1" + idImagen + imagenTrans + "><font face=\"arial\" size=\"2\" color="+ texto1 +">" + arrTxt[0].toLowerCase() + "</font></a><img width=1px height=1px border=0 name=Marcador2" + idImagen + " id=Marcador2" + idImagen + imagenTrans + "></td>";
											strHTML+= "</tr>";											
										}
									strHTML+= "<tr><td height=1 colspan=2 width=" + anchoTabla + "><img width=" + anchoTabla + " height=1px border=0 src='" + imagenlineaNTS + "'></td></tr>";												
																		
								}
								
							else
								{																		
									strHTML+= "<td height=20 width=" + anchoCol1 + " align=left><img border=0 id=" + idImagen + " name=" + idImagen + imagenTrans + " width=10px height=10px></td>";
									strHTML+= "<td nowrap height=20 width=" + anchoCol2 + " align=left><a style=\"text-decoration:none\" href=\"JavaScript:{hand();}\" onMouseOver=\"JavaScript:{cambia('" + arrTxt[1] + "','" + arrTxt[0] + "',false,'#1084AF');}\"><img width=1px height=1px border=0 name=Marcador1" + idImagen + " id=Marcador1" + idImagen + imagenTrans + "><font face=\"arial\" size=\"2\" color="+ texto1 +">" + arrTxt[0].toLowerCase() + "</font></a><img width=1px height=1px border=0 name=Marcador2" + idImagen + " id=Marcador2" + idImagen + imagenTrans + "></td>";
									strHTML+= "</tr>";
									strHTML+= "<tr><td height=1 colspan=2 width=" + anchoTabla + "><img width=" + anchoTabla + " height=1px border=0 src='" + imagenlineaNTS + "'></td></tr>";				
								}
						
								
				
							if (arrTxt[1] == id)							
								{											
									idAnteriorPadre = id;
										
										
									rowsHijo = arrHijo.length;
        								        						
        							for(i=0;i<rowsHijo;i++)
										{
											arrTxtHijo = arrHijo[i].split("|");
											strHTML+= "<tr>";																							
											
											//Si ya ha pulsado una opción de segundo nivel, hay que dejarla marcada										
											if (idMarca == arrTxtHijo[1])
												{													
													strHTML+= "<td bgcolor=#59ACD5 width=" + anchoCol1 + " height=20><img width=10px height=10px border=0 " + imagenTrans + "></td>";
													strHTML+= "<td nowrap bgcolor=#59ACD5 width=" + anchoCol2 + " height=20><a style=\"text-decoration:none\" href=\"javascript:hand();\" onMouseOver=\"JavaScript:{cambiaOp('" + arrTxtHijo[1] + "','" + arrTxtHijo[0] + "');}\"><img width=1px height=1px border=0 name=Marcador1ima" + arrTxtHijo[1] + " id=Marcador1ima" + arrTxtHijo[1] + " " + imagenTrans + "><font face=\"arial\" size=\"2\" color="+ texto2+">" + arrTxtHijo[0].toLowerCase() + "</font></a><img width=1px height=1px border=0 name=Marcador2ima" + arrTxtHijo[1] + " " + " id=Marcador2ima" + arrTxtHijo[1] + " " + imagenTrans + "></td>";										
												}
											else	
												{																										
													strHTML+= "<td bgcolor="+ color2 +" width=" + anchoCol1 + " height=20><img width=10px height=10px border=0 " + imagenTrans + "></td>";
													strHTML+= "<td nowrap bgcolor="+ color2 +" width=" + anchoCol2 + " height=20 ><a style=\"text-decoration:none\" href=\"javascript:hand();\" onMouseOver=\"JavaScript:{cambiaOp('" + arrTxtHijo[1] + "','" + arrTxtHijo[0] + "');}\"><img width=1px height=1px border=0 name=Marcador1ima" + arrTxtHijo[1] + " id=Marcador1ima" + arrTxtHijo[1] + " " + imagenTrans + "><font face=\"arial\" size=\"2\" color="+ texto2+">" + arrTxtHijo[0].toLowerCase() + "</font></a><img width=1px height=1px border=0 name=Marcador2ima" + arrTxtHijo[1] + " " + " id=Marcador2ima" + arrTxtHijo[1] + " " + imagenTrans + "></td>";
												}									

											strHTML+= "</tr>";
											strHTML+= "<tr><td height=1 colspan=2 width=" + anchoTabla + "><img width=" + anchoTabla + " height=1px border=0 src='"+ imagenlineaNTS + "'></td></tr>";				

										}
								}								
						}
				}							
		}

        strHTML+="</table>";        
		
		
		
		                  
        return strHTML;
	
	
	
	}


function verDpt(id)
	{		
		if (existeDept(id))
			{
				if(document.all){
					//primerNivel.document.images["ima" + id].src = "images/trans.gif";
					//txtImg = primerNivel.document.images["ima" + id].src;
				}
				else
				{
					//document.primerNivel.document.images["ima" + id].src = "images/trans.gif";
					//txtImg = document.primerNivel.document.images["ima" + id].src;
					
				}
				
				txtImg = "images/trans.gif";
				idMarca = "nada";
							
				if (ultId == id)
					{							
						if(document.all)
							primerNivel.innerHTML = construirTabla(idPadre,1);								
						else{														
							primernivel=1;						
							document.layers["Mascara"].document.open();				
							document.layers["Mascara"].document.write("");	
							document.layers["Mascara"].document.close();																				
							document.layers["Mascara"].top=-20;																																						
							document.primerNivel2.document.open();
							document.primerNivel2.document.write("");														
							document.primerNivel2.document.close();																												
							document.primerNivel2.zIndex=1;																					
							document.primerNivel.zIndex=2;							
						}
							
						bEstoyEnHijo = false;
						ultId = "";
							
					}
				else
					{						
						bEstoyEnHijo = true;
						muestraHijo = true;			
						if(document.all){
							//primerNivel.innerHTML = "";
							primerNivel.innerHTML = construirTabla(id,2);
						}
						else{																																							
							primernivel=2;														
							document.layers["Mascara"].document.open();				
							document.layers["Mascara"].document.write("");	
							document.layers["Mascara"].document.close();																				
							document.layers["Mascara"].top=-20;																							
							document.primerNivel.zIndex=1;														
							document.primerNivel2.document.open();
							document.primerNivel2.document.write(construirTabla(id,2));														
							document.primerNivel2.document.close();																												
							document.primerNivel2.zIndex=2;							
						}
						muestraHijo = false;				
						ultId = id;
					}
								
			}
	}


function existeDept(id)
	{
        var existe = false;
        for(nD in niveles)
			{
                if(id.toString() == nD)existe = true;
				
			}
        return existe
	}


function verTercer(idHijo,seccion,strTitulo)
	{
		//Reenvio a dept1.asp (antigua dept.asp)
		//Averiguo la seccion en la que estoy.
		
		var strSeccion;
		var strTituloProducto;
		var idPadreHijo;
		var strProducto;

		//Para saber el título de la sección.				
		arrPadre = niveles['0'].split("@");
		rows = arrPadre.length;

		for(j=0;j<rows;j++)
			{
				arrHijo = arrPadre[j].split("|");
								
				if (arrHijo[1] == idPadre)
				{
					strSeccion = arrHijo[0];
				}
			}
		
		
		if (seccion == 'sinHijos')
			{
				//No tiene más niveles. Le mandanos a dept1.asp para que saque todos los productos.								
				//document.location.href = "dept1.asp?id=" + idPadre + '&idPadre=' + idPadre + '&dept_id=' + idHijo + cadenasrcbanner;
			         document.location.href = idHijo;
	
			}	
		else
			{
				
				//Tiene hijos. Hay que mostrarlos. Tambien hay que ver si tiene un cuarto nivel.
				
								
				if (existeDept(idHijo))				
					{
						bNivel4 = 'si';
					}
				else
					{
						bNivel4 = 'no';
					}
				
				//document.location.href = "dept1.asp?id=" + idAnteriorPadre + '&idPadre=' + idPadre + '&nivel4=' + bNivel4 + '&dept_id=' + idHijo + cadenasrcbanner;
				document.location.href = idHijo;		
			
			}
	}



function cambia(id, texto, subnivel,color)
	{				
		var incremento;
		if (ultId != id)
			{				
				if(document.all){
					document.all["celda" + id].bgColor = cambio1;
					document.all["celda" + id].style.color = texto1
					document.all["celda1" + id].bgColor = cambio1;
					document.all["celda1" + id].style.color = texto1
					if (existeDept(id)){primerNivel.document.images["ima" + id].src = "images/mas2.gif";}
				}
				else{	
					if(primernivel==1)
						{															
							if(document.primerNivel.document.images["Marcador1ima" + id].y!=document.primerNivel.document.images["Marcador2ima" + id].y)
								incremento=13
							else
								incremento=15		
							document.Mascara.top = (document.primerNivel.document.images["Marcador1ima" + id].y - incremento) + posMascara;												
						}
					else
						{
							if(document.primerNivel2.document.images["Marcador1ima" + id].y!=document.primerNivel2.document.images["Marcador2ima" + id].y)
								incremento=13
							else
								incremento=15		
							document.Mascara.top = (document.primerNivel2.document.images["Marcador1ima" + id].y - incremento) + posMascara;												
						}
					document.Mascara.document.open();									
					document.Mascara.document.write(cargarMascara1(id,texto,color,subnivel));					
					document.Mascara.document.close();															
																
				}												
			
			}
	}
	

function salir(id)
	{
		if (ultId != id)
			{				
				if(document.all){
					document.all["celda" + id].bgColor = color1;		
					document.all["celda" + id].style.color = texto1;
					document.all["celda1" + id].bgColor = color1;		
					document.all["celda1" + id].style.color = texto1		
					primerNivel.document.images["ima" + id].src = "images/trans.gif";
				}
				else{				
					
					document.Mascara.document.open();				
					document.Mascara.document.write("");	
					document.Mascara.document.close();				
					document.Mascara.top=-20;																						
				}				
			}
	
	}
	


function cambiaOp(id, texto)
	{		
		var incremento;				
		
		if(document.all){
			document.all["celda" + id].bgColor = cambio2;
			document.all["celda1" + id].bgColor = cambio2;
		}
		else{											
			if(primernivel==1)
				{
					if(document.primerNivel.document.images["Marcador1ima" + id].y!=document.primerNivel.document.images["Marcador2ima" + id].y)
						incremento=13
					else
						incremento=15					
					document.Mascara.top = (document.primerNivel.document.images["Marcador1ima" + id].y - incremento) + posMascara;					
				}
			else
				{
					if(document.primerNivel2.document.images["Marcador1ima" + id].y!=document.primerNivel2.document.images["Marcador2ima" + id].y)
						incremento=13
					else
						incremento=15					
					document.Mascara.top = (document.primerNivel2.document.images["Marcador1ima" + id].y - incremento) + posMascara;					
				}
							
			document.Mascara.document.open();				
			document.Mascara.document.write(cargarMascara2(id,texto,'#59ACD5'));			
			document.Mascara.document.close();
		}
	}
	
	
function salirOp(id)
	{
		
		if (idMarca != id)
			{	
				if(document.all){			
					document.all["celda" + id].bgColor = color2;		
					document.all["celda1" + id].bgColor = color2;	
				}
				else{																				
					document.Mascara.document.open();				
					document.Mascara.document.write("");	
					document.Mascara.document.close();																				
					document.Mascara.top=-20;					
				}
			}
	}
	
		
function cargarMascara1(id, texto, color, subnivel){		
	var strHTMLmascara1="";
	var cellpadding=(document.all)?2:0;

	strHTMLmascara1= "<table bgcolor=\"" + color + "\" border=0 style=\"border-color:#7793D6;border-width:1px 1px 1px 1px;border-style:solid;\" cellpadding=" + cellpadding + " cellspacing=0 width=" + anchoTabla + ">";	
	strHTMLmascara1+= "<tr><td height=1 colspan=2></td></tr>";        				
	strHTMLmascara1+= "<tr>";									
	//esta diferenciacion la hacemos para cargar en el href o en el onclick
	//es decir si es un elemento superior con hijos o hijo con enlace a una pagina 
	if(subnivel)
	{
		strHTMLmascara1+= "<td height=20 width=" + anchoCol1 + " align=left><img width=10px height=10px border=0 src=\"images/mas2.gif\"></td>";	
		strHTMLmascara1+= "<td nowrap height=20 align=left width=" + anchoCol2 + "><a href=\"JavaScript:{verDpt('" + id + "');}\" onMouseOut=\"JavaScript:{salir('" + id + "');}\"><img width=1px height=1px border=0 " + imagenTrans + "><font face=\"arial\" size=\"2\" color="+ texto1 +">" + texto.toLowerCase() + "</font></a></td>";	
	}
	else
	{
		strHTMLmascara1+= "<td height=20 width=" + anchoCol1 + " align=left>&nbsp;</td>";	
		strHTMLmascara1+= "<td nowrap height=20 align=left width=" + anchoCol2 + "><a href=\"JavaScript:{verTercer('" + id + "','" + 'sinHijos' + "','" + texto + "');}\" onMouseOut=\"JavaScript:{salir('" + id + "');}\"><img width=1px height=1px border=0 " + imagenTrans + "><font face=\"arial\" size=\"2\" color="+ texto1 +">" + texto.toLowerCase() + "</font></a></td>";				
	}
	strHTMLmascara1+= "</tr>";								
	strHTMLmascara1+= "</table>";					
	
	return strHTMLmascara1;
	
}

function cargarMascara2(id, texto, color){				
	var strHTMLmascara2="";	
	var cellpadding=(document.all)?2:0;
	
	strHTMLmascara2= "<div><table bgcolor=\"" + color + "\" border=0 style=\"border-color:#7793D6;border-width:1px 1px 1px 1px;border-style:solid;\" cellpadding=" + cellpadding + " cellspacing=0 width=" + anchoTabla + ">";	
	strHTMLmascara2+= "<tr><td height=1 colspan=2></td></tr>";        				
	strHTMLmascara2+= "<tr>";								
	strHTMLmascara2+= "<td height=20 width=" + anchoCol1 + " align=left><img width=10px height=10px border=0 " + imagenTrans + "></td>";
	strHTMLmascara2+= "<td nowrap height=20 width=" + anchoCol2 + " align=left><img width=1px height=1px border=0 " + imagenTrans + "><a style=\"text-decoration:none\" href=\"JavaScript:{verTercer('" + id + "','" + '' + "','" + texto + "');}\" onMouseOut=\"JavaScript:{salirOp('" + id + "');}\"><font face=\"arial\" size=\"2\" color="+ texto2+">" + texto.toLowerCase() + "</font></a></td>";		
	strHTMLmascara2+= "</tr>";								
	strHTMLmascara2+= "</table></div>";		
	
	return strHTMLmascara2;
	
}

