// Funcion Oculta Tabla ID
isOPERA = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
isIE    = (document.all && !isOPERA)? true : false;
isDOM   = (document.getElementById && !isIE && !isOPERA)? true : false;


// Cantidad de div a desplegar
var cantidad	= new Array(); 

// div del menu principal
cantidad["menu"] = "3";

//Otros menus (hay que duplicar cantidad[nombre_Menu] = "numero cantidad")


//tipos
var entrada	= new Array();
var content	= new Array ();

// Iniciamos el div del menu principal
initArray("menu");

//initArray de otros menus (hay que duplicar initArray("nombre_Menu");)


function initArray (llave) {
	for (x=0; x < cantidad[llave]; x++) {
		entrada [llave + "_"+x] = true;
	}
}
function show (llave, id, displayValue) {
		var e;
		e = document.getElementById(llave+'_'+id);
		e.style.display = "block";
		var pos = findPos(e.parentElement);
		//e.style.top = pos[1] -(e.childNodes.length*10);
		//alert(pos[1] -(e.childNodes.length*10)+"px");
		
/*
	else if (isIE)
		document.all[llave+'_'+id].style.display = "block";*/
}

function menu (llave, id) {
	hide_all(llave);
	if (entrada[llave + "_"+id]){
		show (llave, id, 'table-row');
		for (x=0; x < cantidad[llave]; x++){
			entrada [llave + "_"+x] = true;
		}
		entrada[llave + "_"+id] = true;//false;
	} else {
		entrada[llave + "_"+id]=true;
	} 
}
 
function hide (id) {
	if (isDOM)
		document.getElementById(id).style.display = "none";
	else if (isIE)
		document.all[id].style.display = "none";
}
 
function hide_all (llave) {
	for (i=0; i<cantidad[llave];i++){
		hide(llave + "_" + i);
	}
}


var iDelay = 100 ;
var sDisplayTimer = null;
var oLastItem = true;
var iNSWidth = 100;
var timerArray = new Array();
 
function stopTimer (el) {
	if (el) {
		clearTimeout(timerArray[el]);
	}
	clearTimeout(sDisplayTimer)
}

function startTimer (el) {
	stopTimer(el);
	varSDisplayTimer = setTimeout("hideItem('"+el+"')",iDelay);
	timerArray[el] = varSDisplayTimer;
}

function hideItem (el) {
	if (oLastItem) {
		hide_all(el);
	}
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}
//-->