//Function 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"] = "2";
//div de la Ficha Nutricion
cantidad["ficha"] = "2";
//div del menu contacto
//cantidad["contacto"] = "2";
//div de los combobox
cantidad["zuko"] = "1";
cantidad["kryzpo"] = "1";
cantidad["naturezza"] = "1";
cantidad["coronado"] = "1";
cantidad["livean"] = "1";
cantidad["lucchetti"] = "1";
cantidad["raff"] = "1";
cantidad["talliani"] = "1";
cantidad["vancook"] = "1";
cantidad["tempo"] = "1";
cantidad["yupi"] = "1";
cantidad["yuz"] = "1";
cantidad["monterrey"] = "1";
cantidad["gold"] = "1";
cantidad["miraflores"] = "1";
//div categorias
cantidad["aceites"] = "1";
cantidad["infantiles"] = "1";
cantidad["calientes"] = "1";
cantidad["frias"] = "1";
cantidad["harinas"] = "1";
cantidad["jugos"] = "1";
cantidad["pastas"] = "1";
cantidad["postres"] = "1";
cantidad["salsas"] = "1";
cantidad["snacks"] = "1";
cantidad["caldos"] = "1";

//tipos
var entrada	= new Array();
var content	= new Array ();
//div del menu principal
initArray("menu");
//div de la ficha nutricion
initArray("ficha");
//div del menu contacto
initArray("contacto");
//div de los combobox
initArray("zuko");
initArray("kryzpo");
initArray("naturezza");
initArray("coronado");
initArray("livean");
initArray("lucchetti");
initArray("raff");
initArray("talliani");
initArray("vancook");
initArray("tempo");
initArray("yupi");
initArray("yuz");
initArray("monterrey");
initArray("gold");
initArray("miraflores");
//div categorias
initArray("aceites");
initArray("infantiles");
initArray("calientes");
initArray("frias");
initArray("harinas");
initArray("jugos");
initArray("pastas");
initArray("postres");
initArray("salsas");
initArray("snacks");
initArray("caldos");


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];
}
//-->
