var timeout; //don't touch it, this is to declare the variable
var timeout2; //don't touch it, this is to declare the variable
	function QuitaTimeOut() {
		if (timeout) {
			clearTimeout(timeout);
		}
		if (timeout2) {
			clearTimeout(timeout2);
		}
	}
	
	function devuelvePosY(docElement){
		for (psY=0;docElement!=null;)
			{
				
				psY +=docElement.offsetTop;
				docElement=docElement.offsetParent;
			}
		return psY;
	}
	
	function devuelvePosX(docElement){
		for (psX=0;docElement!=null;)
			{
				psX +=docElement.offsetLeft;
				docElement=docElement.offsetParent;
				}
		return psX;
	}

	function FiltraColeccion(colObjetos,strFiltro)
	{
		var strTemp="";
		var arJoin = new Array();
		for (var i=0;i<colObjetos.length;i++)
		{
			strTemp =colObjetos[i].id;
			if( strTemp.indexOf(strFiltro)>=0)
			{
				arJoin.push(strTemp);
			}
		}
		return arJoin;
	}

	function OcultaMenus(strMenuPadre)
	{
		var arMenus = FiltraColeccion(document.getElementsByTagName('table'),"tblSM");
		for (var i=0;i<arMenus.length;i++)
		{
			
			objMenu = document.getElementById(arMenus[i]);
			if(strMenuPadre!=arMenus[i])
				objMenu.style.visibility="hidden";
		}
	}
	
	
	function FrameVisible(blnVisible)
	{
		var frmTemp = document.getElementById('frameTemario');
		if (frmTemp)
		{
			if (blnVisible)
				frmTemp.style.visibility="visible";
			else
				frmTemp.style.visibility="hidden";
		}	
	}
	
	function ActivaMenu(strID,strColor,strSubMenu,strMenuPadre)
	{
	

		//quitar timeout
		QuitaTimeOut();
		FrameVisible(false);
		
		posY=0;
		posX=0;
		objTemp = document.getElementById(strID);
		objTemp.style.backgroundColor=strColor;
	
	
		//esconder menus
		OcultaMenus(strMenuPadre);
	   	
	   	//mostrar menu
	   	posY = devuelvePosY(objTemp);
	   	posX = devuelvePosX(objTemp)+ objTemp.offsetWidth;
	   
	   	if (strSubMenu != "") 
	   	{
	   		subMenu = document.getElementById(strSubMenu);
	   	   	subMenu.style.top = posY + "px";
	   		subMenu.style.left = posX + "px";
	   		subMenu.style.visibility="visible";
	   	}
	}
			
	function DesactivaMenu(strID,strColor,strSubMenu,strMenuPadre)
	{
		ok = document.getElementById(strID);
	   	ok.style.backgroundColor=strColor;
	   	timeout = setTimeout ('OcultaMenus()', 550); 
	   	timeout2 = setTimeout ('FrameVisible(true)', 550); 
	 }
	
		
	function CambiaBG(strID,strColor)
	{
		ok = document.getElementById(strID);
	   	ok.style.backgroundColor=strColor;
	   	QuitaTimeOut();
	}
	
	function RestauraBG(strID,strColor)
	{
		ok = document.getElementById(strID);
		ok.style.backgroundColor=strColor;
		timeout = setTimeout ('OcultaMenus()', 550); 
		timeout2 = setTimeout ('FrameVisible(true)', 550); 
	}
	
	function Muestra(strID) {
	ok = document.getElementById(strID);
	ok.style.visibility="visible";
	}

	function Esconde(strID) {
		ok = document.getElementById(strID);
		ok.style.visibility="hidden";
	}

	
