function fn_AbrirVentanaHijos (idMenu, TituloMenu)
{
fn_InvocarAjax_Post ("menu_ajax.php", "txt_HacerMostrarCombos=-1&idMenu=" + idMenu + "&tituloMenu=" + fn_Escape (TituloMenu));
}

function fn_MostrarVentanaHijos (TituloMenu)
{
var ancho, alto, top, left;

document.getElementById ("span_TituloMenu").innerHTML = TituloMenu;

// Seteamos el DIV del sombreado.
document.getElementById ("div_Sombreado").style.height = document.body.scrollHeight;
document.getElementById ("div_Sombreado").style.width = document.body.scrollWidth;

// Mostramos los DIVs.
document.getElementById ("div_Sombreado").style.display = "block";
document.getElementById ("div_OpcionesHijas").style.display = "block";

// Seteamos el DIV de los filtros.	
ancho = 381;
alto = document.getElementById ("div_OpcionesHijas").clientHeight;

top = parseInt ((document.body.clientHeight - alto) / 2) + document.body.scrollTop;
left = parseInt ((document.body.clientWidth - ancho) / 2);	

document.getElementById ("div_OpcionesHijas").style.width = ancho.toString () + "px";
document.getElementById ("div_OpcionesHijas").style.top = top.toString () + "px";
document.getElementById ("div_OpcionesHijas").style.left = left.toString () + "px";	

document.getElementById ("cmb_Menu_1").focus ();
}

function fn_CerrarVentanaOpcionesHijas ()
{
document.getElementById ("div_OpcionesHijas").style.display = "none";
document.getElementById ("div_Sombreado").style.display = "none";
}

function fn_CargarHTMLCombos (HTMLCombos)
{
document.getElementById ("td_Combos").innerHTML = HTMLCombos;
}

function fn_SeleccionMenuCombo (indice, cantNiveles)
{
var idMenuSeleccionado = document.getElementById ("cmb_Menu_" + indice).value;

if (idMenuSeleccionado == "0")
{
if (cantNiveles > parseInt (indice))
{
for (i = parseInt (indice) + 1; i <= cantNiveles; i++)
{
document.getElementById ("tr_Menu_" + i).style.display = "none";
}
}

document.getElementById ("tr_BotonAceptarOpcionesHijas").style.display = "none";

try { document.getElementById ("tr_EspacioInferiorOpcionesHijas").style.display = "table-row"; }
catch (err) { document.getElementById ("tr_EspacioInferiorOpcionesHijas").style.display = "block"; };		
}
else	
{
fn_BloquearBotonesFiltrosOpcionesHijas (cantNiveles);
fn_InvocarAjax_Post ("menu_ajax.php", "txt_HacerLlenarComboHijo=-1&indice=" + indice + "&idMenu=" + idMenuSeleccionado + "&cantNiveles=" + cantNiveles);
}
}

function fn_LlenarCombo (indice, contenidoCombo, cantNiveles)
{
document.getElementById ("div_ComboMenu_" + indice).innerHTML = contenidoCombo;

try { document.getElementById ("tr_Menu_" + indice).style.display = "table-row"; }
catch (err) { document.getElementById ("tr_Menu_" + indice).style.display = "block"; };

if (cantNiveles > parseInt (indice))
{
for (i = parseInt (indice) + 1; i <= cantNiveles; i++)
{
document.getElementById ("tr_Menu_" + i).style.display = "none";
}
}

document.getElementById ("tr_BotonAceptarOpcionesHijas").style.display = "none";

try { document.getElementById ("tr_EspacioInferiorOpcionesHijas").style.display = "table-row"; }
catch (err) { document.getElementById ("tr_EspacioInferiorOpcionesHijas").style.display = "block"; };

document.getElementById ("cmb_Menu_" + indice).focus ();
}

function fn_HabilitarBotonAceptar (indice, vinculo, cantNiveles)
{
document.getElementById ("txt_VinculoBotonAceptar").value = vinculo;
document.getElementById ("txt_CantNivelesCombos").value = cantNiveles;

if (cantNiveles > parseInt (indice))
{
for (i = parseInt (indice) + 1; i <= cantNiveles; i++)
{
document.getElementById ("tr_Menu_" + i).style.display = "none";
}
}

try { document.getElementById ("tr_BotonAceptarOpcionesHijas").style.display = "table-row"; }
catch (err) { document.getElementById ("tr_BotonAceptarOpcionesHijas").style.display = "block"; };

document.getElementById ("tr_EspacioInferiorOpcionesHijas").style.display = "none";
}

function fn_AbrirOpcionMenu ()
{
var cantNiveles = parseInt (document.getElementById ("txt_CantNivelesCombos").value);

fn_BloquearBotonesFiltrosOpcionesHijas (cantNiveles);
window.location.href = document.getElementById ("txt_VinculoBotonAceptar").value;
}

function fn_BloquearBotonesFiltrosOpcionesHijas (cantNiveles)
{
document.getElementById ("tablaFiltrosOpcionesHijas").style.cursor = "wait";

for (i = 1; i <= cantNiveles; i++)
{
document.getElementById ("cmb_Menu_" + i).disabled = true;
}

document.getElementById ("btn_ConsultarOpcionesHijas").style.cursor = "wait";
document.getElementById ("btn_ConsultarOpcionesHijas").disabled = true;
}	

function fn_HabilitarBotonesFiltrosOpcionesHijas (cantNiveles)
{
document.getElementById ("btn_ConsultarOpcionesHijas").style.cursor = "pointer";
document.getElementById ("btn_ConsultarOpcionesHijas").disabled = false;

for (i = 1; i <= cantNiveles; i++)
{
document.getElementById ("cmb_Menu_" + i).disabled = false;
}

document.getElementById ("tablaFiltrosOpcionesHijas").style.cursor = "default";		
}
