/* Variable Globales */
var menucontex = asignar("Est&aacute;s en el men&uacute; contextual.");

function asignar(texto)
{
   return texto;
}

// funci&oacute;n que muestra la capa
function EscribeCapa(capaIE,capaNSPadre,capaNSHija,texto_salida) 
{
	if (ie4) eval('document.all["' + capaIE + '"].innerHTML=texto_salida;');
	else if (ns4)
	{
		var lyr = document.layers[capaNSPadre].document.layers[capaNSHija].document;
		lyr.open();
		lyr.write(texto_salida);
		lyr.close();
	}
	else if (ns6)
	{
		document.getElementById(capaNSPadre).innerHTML = texto_salida;
	}
}


function inicioMenu (nOp, nSOp)
{
	hm_numOp_ini = nOp-1;
	hm_numOpcion = nOp-1;
	hm_numLk_ini = nSOp-1;

	

	hm_Muestra();
	
}

function hm_Chequea(nOp)
{
	hm_numOpcion	= nOp;
	// Si la pesta&ntilde;a va directamente a una url:
	if (hm_opciones_submenu[nOp]==0)
	{
	  window.open(hm_opciones_links[nOp],hm_opciones_marco[nOp]);
	}
	else
	{
		hm_Muestra();
	}
	
}

function hm_Muestra() {
	
	var htm_out="";
	var img_pestania;
	var alt_pestania;
	var i=0;
	var columnas;
	htm_out="";
	htm_out=htm_out + '<table width=606 cellpadding=0 cellspacing=0 border=0>';
	htm_out=htm_out + '<tr>';
	htm_out=htm_out + '<td><a name="menupestanas"><img src="/images/pixel.gif" width=0 height=0 border=0 alt="'+menucontex+'"></a></td></tr><tr>';	

	columnas=(hm_numOpciones*2)+1;

	//A&ntilde;ado Opciones
	for (i=0;i<hm_numOpciones;i++)
	{
		if (i == hm_numOpcion && hm_opciones_submenu[i]==1) {
			img_pestania = hm_img_selec[i];
			alt_pestania = hm_opciones_alt[i];
			fondo = hm_opciones_sepcolor;
			fondotexto = eval("hm_opciones" + i + "_bgcolor");
		} else {
			if (i!=hm_numOpcion) {
				img_pestania = hm_opciones[i];
				alt_pestania = hm_opciones_alt[i];
				fondo = hm_opciones_bgcolor;
				fondotexto = hm_opciones_bgcolor;
			}
			else {
				img_pestania = hm_img_selec[i];
				alt_pestania = hm_opciones_alt[i];
				fondo = hm_opciones_bgcolor;
				fondotexto = hm_opciones_bgcolor;
			}
		}
	  	
		htm_out = htm_out + '<td valign="top" align="left"><a href="javascript:hm_Chequea(' + i + ')"><img src="' + hm_imgraiz_usr + img_pestania + '" border=0 alt="' + alt_pestania + '"></a></td>';

		htm_out = htm_out + '<td width=2><img src="/images/pixel.gif" border=0></td>';

		if (i < hm_numOpciones && i == hm_numOpcion && hm_opciones_submenu[i] == 1)
			fondo = hm_opciones_sepcolor;
		else 
			fondo = hm_opciones_bgcolor;
			
		if (i==6) {
		htm_out = htm_out + '<td width=99%><img src="/images/pixel.gif" border=0></td>';
		htm_out = htm_out + '</tr>';
		htm_out=htm_out + '</table>';
		htm_out=htm_out + '<table width=606 cellpadding=0 cellspacing=0 border=0>';
		htm_out=htm_out + '<tr>';	
		htm_out = htm_out + '<td width=606><img src="/images/pixel.gif" height=2 border=0></td>';
		htm_out=htm_out + '</tr>';
		htm_out=htm_out + '</table>';
		
		htm_out=htm_out + '<table width=606 cellpadding=0 cellspacing=0 border=0>';
		htm_out=htm_out + '<tr>';	
		}
	}
		htm_out = htm_out + '<td width=99%><img src="/images/pixel.gif" border=0></td>';
	htm_out = htm_out + '</tr>';
	htm_out = htm_out + '<tr>';

	//A&ntilde;ado l&iacute;neas blanco de abajo, tantas como opciones haya introducido
	for (i=7;i < (hm_numOpciones);i++) {
		if (i == hm_numOpcion && hm_opciones_submenu[i] == 1) fondotexto = eval("hm_opciones" + i + "_bgcolor") 
		else fondotexto = hm_opciones_sepcolor; 
		
		if (i == hm_numOpcion && hm_opciones_submenu[i] == 1)
		{
			fondo_separacion = "#C5C5C5";
		}
		else
		{
			fondo_separacion = "#FFFFFF";
		}
		
		htm_out = htm_out + '<!--txt--><td bgcolor="' + fondo_separacion + '" height=3 width=1><img src="/images/pixel_trans.gif" height=3 border=0></td><td><img src="/images/pixel.gif" border=0></td>';
	}

	htm_out=htm_out + '</tr>';

	if (hm_numOpcion == -1 || hm_opciones_submenu[hm_numOpcion] == 0)
	{
		htm_out = htm_out + '<tr><td WIDTH=606 colspan=' + columnas + ' bgcolor="#FFFFFF" class="' + hm_estilo_loc + '">';
	}
	else
	{
		htm_out = htm_out + '<tr><td WIDTH=606 colspan=' + columnas + ' bgcolor="#C5C5C5" class="' + hm_estilo_loc + '">';
	}

	//SUBMENU

	if (hm_opciones_submenu[hm_numOpcion] == 0) {
		htm_out = htm_out + '&nbsp;';
	} else if (hm_numOpcion == -1)	{
		htm_out = htm_out + '&nbsp;';
	} else	{
		fondolocalizador = eval("hm_opciones" + hm_numOpcion + "_bgcolor");
		htm_out = htm_out + '&nbsp;';

		for (i=0;i<eval("hm_opciones" + hm_numOpcion + ".length");i++)
		{
			if ((hm_numLk_ini == i) && (hm_numOpcion == hm_numOp_ini))
			{
				htm_out=htm_out + '<a href="' + eval('hm_opciones' + hm_numOpcion + '_links['+ i + ']') + '" target="' + eval('hm_opciones' + hm_numOpcion + '_marco[' + i + ']') + '" title="' + eval('hm_opciones' + hm_numOpcion + '_alt[' + i + ']') + ' "><FONT COLOR="' + hm_link_sel + '">' + eval('hm_opciones' + hm_numOpcion + '['+ i + ']') + '</FONT></a>&nbsp;';
			}
			else
			{
				htm_out=htm_out + '<a href="' + eval('hm_opciones' + hm_numOpcion + '_links['+ i + ']') + '" target="' + eval('hm_opciones' + hm_numOpcion + '_marco[' + i + ']') + '" title="' + eval('hm_opciones' + hm_numOpcion + '_alt[' + i + ']') + ' ">' + eval('hm_opciones' + hm_numOpcion + '['+ i + ']') + '</a>&nbsp;';
			}
			if (i != (eval("hm_opciones" + hm_numOpcion + ".length")-1))
				htm_out = htm_out + '| ';
		}
	}

	htm_out = htm_out + '</td>';
	htm_out = htm_out + '</tr>';
	htm_out = htm_out + '</table>';

	EscribeCapa (hm_capaMenu,hm_capaMenuPadre,hm_capaMenu,htm_out);
}