function rollOver(imgId,imgSrc)
{
	imgSrc.background=imgId;
}

function showHide(capa,estado)
{
	if ( eval ("document.getElementById('subMenu0"+capa+"')") )
	{
		eval ("document.getElementById('submenu"+capa+"').style.visibility = '"+estado+"'");
		if (estado="visible") 
			eval ("flecha"+capa+".src='docs/img/menu_flecha_on.gif'");
		else 
			eval ("flecha"+capa+".src='docs/img/menu_flecha.gif'");
	}		
}

//var numMenus=4;

// Cuándo el menú principal tiene imagen de fondo

function hideAll()
{
	for (i=1;i<=numMenus;i++)
	{
		if ( eval ("document.getElementById('subMenu0"+i+"')") )
		{
			eval ("document.getElementById('subMenu0"+i+"').style.visibility = 'hidden'");
			eval ("tdmenu"+i+".background=''");
			eval ("flecha0"+i+".src='docs/img/menu_flecha.gif'");
		}	
	}
	if (activo !=0)
	{
		eval ("tdmenu"+activo+".background='docs/img/menu_bg_on.gif'");
	}
}


var timerID = null;
var rollID = null;
var timerOn = false;
var timecount = 500;	

function startTime() 
{
	if (timerOn == false) 
	{
       	timerID = setTimeout( "hideAll()" , timecount);
		timerOn = true;
	}
}

function stopTime() 
{
	if (timerOn) 
	{
		clearTimeout(timerID);
       	timerID = null;
		rollID = null;
    	timerOn = false;
    }
}	

// Cuándo el menú principal tiene imagen de fondo
function subMenu(imgId,imgSrc,capa,estado)
{
	if(imgId!="")
	{
		rollOver(imgId,imgSrc);
	}
	showHide(capa,estado);
}

// Cuándo el menú principal no tiene imagen de fondo, son estilos
function rollOverMenu(capaM,colorM,textoM,capaSM,estadoSM)
{
	eval ("document.getElementById('"+capaM+"').style.backgroundColor = '"+colorM+"'");
	eval ("document.getElementById('"+capaM+"').style.color = '"+textoM+"'");
	showHide(capaSM,estadoSM);
}

function rollOverSM(capa,color,texto)
{
	eval ("document.getElementById('"+capa+"').style.backgroundColor = '"+color+"'");
	eval ("document.getElementById('"+capa+"').style.color = '"+texto+"'");
}

var activo = 0;
function activar(num)
{
	activo = num;
}

function colocarSubMenus(num)
{
	var posicion = ((document.body.clientWidth-768)/2)+15;

	for (i=1;i<num;i++)
	{
		sm = i+1;
		eval("anchura = document.getElementById('tdmenu"+i+"').clientWidth + 2");
		posicion = posicion + anchura;
		document.getElementById("subMenu0"+sm+"").style.left = posicion;
	}
}


