    var idMenu="";
    var idMenuH="";
    var idSubMenu="";
    var TimeOutH;
	function mostra_h(pulo,id_categoria,table_pai)
	{

        trataJanelasPrimaria_h(id_categoria);   // Verifica se existe janela em aberto de outra categoria, se tiver, ele fecha.
	    var somaLeft=somaTop=intContador=0;
	    obj  = document.getElementById(table_pai);
	    objp = document.getElementById("table_l"+pulo);
//	    alert("P"+pulo+" - "+id_categoria +" - "+table_pai);
	    if(!document.getElementById("table_h_"+id_categoria))
            return;

	    obj2 = document.getElementById("table_h_"+id_categoria);
        objp = objp.appendChild(obj2);
		obj2.style.width='100px';
		obj2.style.visibility = "";

   		idMenu = idMenuH = id_categoria;
	}
	function mostra_T_h(pulo,id_categoria,table_pai, letra, masterLetra)
	{

        trataJanelasSecundaria_h(id_categoria); // Verifica se existe janela em aberto de outra subcategoria, se tiver, ele fecha.
	    if(!document.getElementById("table"+id_categoria))
            return;
        if(!document.getElementById("table_h"+letra+pulo))
            return;
        var calibradorH = document.getElementById("tabelaH_"+pulo+"a"+id_categoria).offsetTop;

	    obj2 = document.getElementById("table"+id_categoria);

		objp = document.getElementById("table_h"+letra+pulo);
        obj2.style.visibility = "";
		obj2.style.width='100px';
        obj3 = document.getElementById("table_h_"+masterLetra);
        obj2.style.left=obj3.offsetLeft+95;
        obj2.style.top =obj3.offsetTop+calibradorH;
        obj3.insertAdjacentElement("afterEnd",obj2);
        //objp.appendChild(obj2);
		idSubMenu = id_categoria;
	}
	function esconde_h(id_categoria)
	{

        if(id_categoria!="")
        {
            if(isNaN(id_categoria))  // Se a categoria é um número(indica que é uma categoria do menu) então roda o tableX, senão é do menu horizontal.
            {
                obj = document.getElementById("table_h_"+id_categoria);
            }else
                obj = document.getElementById("table"+id_categoria);

            if(obj)
            {
                obj.style.visibility = "hidden";
                clearTimeout(TimeOutH);
            }
        }
	}
	function escondeSub_h(id_categoria, id_categoria_pai)
	{

        if(id_categoria!="")
        {
            obj = document.getElementById("table"+id_categoria);
            obj.style.visibility = "hidden";
        }
        if(id_categoria_pai!="")
        {
            if(document.getElementById("table_h_"+id_categoria_pai))
            {
                obj2 = document.getElementById("table_h_"+id_categoria_pai);
                obj2.style.visibility = "hidden";
            }
        }
    }
	function ativaEsconde_h(id_categoria)
    {

        TimeOutH = setTimeout("esconde_h(\""+id_categoria+"\")",600);
    }
	function ativaEscondeTudo_h()
    {

        TimeOutH = setTimeout("escondeSub_h('"+ idSubMenu +"' ,'"+ idMenuH +"')",600);
    }
    function trataJanelasPrimaria_h(id_categoria)
    {
        if(id_categoria!=idMenu && idMenu!="")
        {
            esconde_h(idMenu);
            idMenu="";
        }
        clearTimeout(TimeOutH);
        if(idSubMenu!="")
        {
            trataJanelasSecundaria_h(id_categoria);
        }
    }
    function trataJanelasSecundaria_h(id_categoria)
    {
        if(id_categoria!=idSubMenu && idSubMenu!="")
        {
            esconde_h(idSubMenu);
            idSubMenu="";
        }
        clearTimeout(TimeOutH);
    }
    function seguraTMenu_h()
    {
        if(TimeOutH)
            clearTimeout(TimeOutH);
        segura=false;
    }
    
    function seguraPeao()
    {

    }
    var dado1Atual;
    var dado2Atual;
    function corInH(dado1,dado2)
    {
        dado1Atual=dado1;
        dado2Atual=dado2;
        obj = document.getElementById("tabelaH_"+dado1+"a"+dado2);
        obj.style.backgroundColor='#AAAAAA';
        obj = document.getElementById("tabelaH_"+dado1+"a2"+dado2);
        obj.style.backgroundColor='#AAAAAA';
    }
    function corOutH(dado1,dado2)
    {
        obj = document.getElementById("tabelaH_"+dado1+"a"+dado2);
        obj.style.backgroundColor='#000000';
        obj = document.getElementById("tabelaH_"+dado1+"a2"+dado2);
        obj.style.backgroundColor='#000000';
    }

    

    //////////////////////////////////////////////////////////////////////////////

    var idMenu="";
    var idSubMenu="";
    var TimeOut;
    var topPosX = Array(0,0,0,0,0,0);
    var topPosY = Array(0,0,0,0,0,0);
    var segura=false;
    
	function mostra(pulo,id_categoria,table_pai)
	{
        trataJanelasPrimaria(id_categoria);
        ativaEscondeMenuAtuais(idSubMenu,idMenu);
	    var somaLeft=somaTop=intContador=0;
	    obj  = document.getElementById(table_pai);
	    objp = document.getElementById("table_p"+pulo);
	    if(!document.getElementById("table"+id_categoria))
            return;
	    obj2 = document.getElementById("table"+id_categoria);
        objp = objp.appendChild(obj2);
		obj2.style.visibility = "";
        obj2.style.width='100px';
   		idMenu = id_categoria;
	}
	function mostra_T(pulo,id_categoria,table_pai)
	{
	    var somaLeft=somaTop=intContador=0;
        var calibrador = document.getElementById(table_pai+"pos"+pulo).offsetTop;
        trataJanelasSecundaria(id_categoria);
   	    obj = document.getElementById(table_pai);
	    if(!document.getElementById("table"+id_categoria))
             return;
	    obj2 = document.getElementById("table"+id_categoria);
		obj2.style.visibility = "";
		obj2.style.width='100px';
		obj2.style.top=objp.offsetTop+calibrador;

        var calibradorLado = objp.offsetWidth-100;
        if(screen.width==1280)
        {
            obj2.style.left=obj.offsetLeft+objp.offsetWidth-2;//(obj.offsetLeft+objp.offsetWidth-2) +'px';// 1024x768
        }
        if(screen.width==1152)
        {
            obj2.style.left=obj.offsetLeft+objp.offsetWidth-2;//(obj.offsetWidth+objp.offsetWidth+135) +'px';// 1024x768
        }
        if(screen.width==1024)
        {
            obj2.style.left=obj.offsetLeft+objp.offsetWidth-2;//(354+calibradorLado) +'px';// 1024x768
        }
        if(screen.width==800)
            obj2.style.left=obj.offsetLeft+objp.offsetWidth-2;//'242px';
        objp.insertAdjacentElement("afterEnd",obj2);

		//objp.appendChild(obj2);
		//objp = document.getElementById(table_pai+"_s"+pulo);

		idSubMenu = id_categoria;
	}
	function mostra_TTop(pulo,id_categoria,table_pai)
	{
	    var somaLeft=somaTop=intContador=0;
        var calibrador = document.getElementById("calibradorTop"+pulo).offsetTop;
        if(segura==true)
            return;
        trataJanelasSecundariaTop(id_categoria);
   	    obj = document.getElementById(table_pai);

	    if(!document.getElementById("table"+id_categoria))
	    {
            idSubMenu="";
            return;
        }

        objp = document.getElementById(table_pai+"_s"+pulo);
        obj2 = document.getElementById("table"+id_categoria);

		obj2.style.width='100px';
        //objp.insertAdjacentElement("beforeEnd",obj2);
        objp.appendChild(obj2);

         if(topPosX[pulo]==0)
         {
             topPosX[pulo] = obj2.offsetTop+2;
         }else
            obj2.style.top = topPosX[pulo];
         if(topPosY[pulo]==0)
         {
             topPosY[pulo] = obj2.offsetLeft-10;
         }else
            obj2.style.left = topPosY[pulo];
		//objp.appendChild(obj2);
		//objp = document.getElementById(table_pai+"_s"+pulo);
		obj2.style.visibility = "";
		idSubMenu = id_categoria;
        segura=false;
	}
	function esconde(id_categoria)
	{

        if(id_categoria!="")
        {
            if(document.getElementById("table"+id_categoria))
            {
                obj = document.getElementById("table"+id_categoria);
                obj.style.visibility = "hidden";
            }
        }
	}
	function escondeSub(id_categoria, id_categoria_pai)
	{
        if(segura==true)
            return;

        if(id_categoria!="")
        {
            if(document.getElementById("table"+id_categoria))
            {
                obj = document.getElementById("table"+id_categoria);
                obj.style.visibility = "hidden";
                idSubMenu="";
            }
        }
        if(id_categoria_pai!="")
        {
            if(document.getElementById("table"+id_categoria_pai))
            {
                obj2 = document.getElementById("table"+id_categoria_pai);
                obj2.style.visibility = "hidden";
                idMenu="";
            }
        }
    }
	function ativaEsconde(id_categoria)
    {

        TimeOut = setTimeout("esconde("+id_categoria+")",600);
        segura=false;
    }
	function ativaEscondeTudo(origem)
    {

        if(origem!="V")
            ativaEscondeTudo_h();
        TimeOut = setTimeout("escondeSub('"+ idSubMenu +"' ,'"+ idMenu +"')",600);
        segura=false;
    }
	function ativaEscondeMenuAtuais(idSubMenu, idMenu)
    {

        escondeSub(idSubMenu,idMenu);
    }
    function trataJanelasPrimaria(id_categoria)
    {

        if(id_categoria!=idMenu && idMenu!="")
        {
            esconde(idMenu);
            idMenu="";
        }
        clearTimeout(TimeOut);
    }
    function trataJanelasSecundaria(id_categoria)
    {

        if(id_categoria!=idSubMenu && idSubMenu!="")
        {

            esconde(idSubMenu);
            idSubMenu="";
        }

        clearTimeout(TimeOut);
    }
    function trataJanelasSecundariaTop(id_categoria)
    {
        if(segura==true)
            return;
        if(id_categoria!=idSubMenu && idSubMenu!="")
        {
            esconde(idSubMenu);
            idSubMenu="";
        }
        clearTimeout(TimeOut);
    }
	function ativaEscondeTudoTop()
    {

        TimeOut = setTimeout("escondeSub('"+ idSubMenu +"' ,'"+ idMenu +"')",1000);
    }
    function seguraTMenu()
    {
        seguraTMenu_h();
        clearTimeout(TimeOut);
        segura=true;
    }
    
    
    
    /////////////Menu
    

    var oTabela,oTBody;
    var oTabelaT,oTBodyT;
    var  oTabelaT = new Array();
    var oRow,oCell,iContadorT;
    var oRowT,oCellT;
    var vMouseOver;
    var tabs = document.getElementById("tabs");
    var tabs1 = document.getElementById("tabs1");
    iContadorT = 0;
    function MegaTabela()
    {
        oTabela = document.createElement("TABLE");
        oTabela.style.border=0;
        oTabela.cellPadding=0;
        oTabela.cellSpacing=0;
        oTabela.style.width='140px';
        oTBody  = document.createElement("TBODY");

        oTBody.cellSpacing=0;
        oTBody.cellPadding=0;
        for(intContador=0;intContador<oDados.length;intContador++)//>
        {
            oTabela.name = "table"+oDados[intContador][0]; oTabela.id = "table"+oDados[intContador][0];
            //for(intContador2=0;intContador2<oDados[0].length;intContador2++) //>
            {
                oRow  = document.createElement("<TR width=244 height=20 class=textomenu >");
                oRow.style.width='400px';
                vMouseOver = 'mostra_T('+oDados[intContador][1][0]+','+oDados[intContador][1][2]+',"table'+oDados[intContador][1][1]+'")';
                oRow.id  = "table"+oDados[intContador][0]+"pos"+oDados[intContador][1][0];
                oRow.name= "table"+oDados[intContador][0]+"pos"+oDados[intContador][1][0];
                oCell = document.createElement("<TD align=left width=184 onMouseMove="+vMouseOver+" onMouseOut='ativaEscondeTudo(\"V\");'>");
                //oCell = document.createElement("TD");
                oCell.style.border=0;
                oCell.style.height='12px';
                oCell.style.backgroundColor='#BDD235';
                oCell.style.fontFamily="Verdana, Arial, Helvetica, sans-serif";
                oCell.style.fontSize="11px";
                oCell.style.textDecoration="none";
                oCell.onmousemove = vMouseOver;
                oCell.onMouseOut = 'ativaEscondeTudo();';
                oCell.innerHTML = '<A  HREF=\''+ oDados[intContador][1][4]+'\' class="textomenu">&nbsp;'+ oDados[intContador][1][3]+'</A>';

                oRow.appendChild(oCell);

                oCell = document.createElement("TD");
                oCell.style.border=0;
                oCell.style.backgroundColor='#BDD235';
                oCell.style.fontFamily="Verdana, Arial, Helvetica, sans-serif";
                oCell.style.fontSize="11px";
                oCell.style.textDecoration="none";
                oCell.align='right';
                oCell.style.color='#585657';

                oCell.innerHTML = oDados[intContador][1][5];
                oRow.appendChild(oCell);

                //oCell = document.createElement("TD");
                oCell = document.createElement("<TD onMouseMove="+vMouseOver+" onMouseOut='ativaEscondeTudo();'>");

                oCell.id = 'table'+oDados[intContador][1][1]+'_s'+oDados[intContador][1][0]+'';
                oRow.appendChild(oCell);
                oTBody.appendChild(oRow);

                oRow  = document.createElement("<TR width=244>");
                //oCell = document.createElement("TD");

                //oCell.onMouseOver = vMouseOver;
                //oRow.appendChild(oCell);

                oCell = document.createElement("<TD onMouseMove="+vMouseOver+" onMouseOut='ativaEscondeTudo();'>");
                oCell.style.border=0;
                oCell.style.backgroundColor='#7A7A7A';
                oCell.id = 'table'+oDados[intContador][1][1]+'_s'+oDados[intContador][1][0];
                oCell.colSpan=2;
                oRow.appendChild(oCell);

                oTBody.appendChild(oRow);

            }
        }
        oTabela.appendChild(oTBody);
        oTabela.border=1;
        oTabela.style.position="absolute";
        oTabela.style.visibility="hidden";

        tabs.appendChild(oTabela);
    }
    function MegaTabelaT()
    {
        oTabelaT = document.createElement("<TABLE onMouseOver='seguraTMenu();'>");
        oTabelaT.style.border=0;
        oTabelaT.cellPadding=0;
        oTabelaT.cellSpacing=0;
        oTabelaT.style.zIndex=10;
        oTBodyT  = document.createElement("TBODY");
        for(intContador=0;intContador<oDadosT.length;intContador++)//>
        {
            oTabelaT.name = "table"+oDadosT[intContador][0]; oTabelaT.id = "table"+oDadosT[intContador][0];
            //for(intContador2=0;intContador2<oDadosT[0].length;intContador2++) //>
            {
                oRowT  = document.createElement("<TR onMouseOver='seguraTMenu();' width=144 height=20 >");
                oCellT = document.createElement("<TD align=left onMouseOver='seguraTMenu();' onMouseOut='ativaEscondeTudo();'>");
                oCellT.style.border=0;
                oCellT.width='220px';
                oCellT.style.backgroundColor='#BDD235';
                oCellT.style.fontFamily="Verdana, Arial, Helvetica, sans-serif";
                oCellT.style.fontSize="11px";
                oCellT.style.textDecoration="none";

                vMouseOver = 'seguraTMenu();';
                //oCellT.onMouseOver = vMouseOver;
                //oCellT.onMouseOut='ativaEscondeTudo();';
                oCellT.innerHTML = '<A HREF=\''+ oDadosT[intContador][2]+'\' class="textomenu">&nbsp;'+ oDadosT[intContador][1]+'</A>';
                oRowT.appendChild(oCellT);
                oTBodyT.appendChild(oRowT);

                oRowT  = document.createElement("<TR>");
                oCellT = document.createElement("<TD>");
                oCellT.style.border=0;
                oCellT.style.backgroundColor='#7A7A7A';
                oRowT.appendChild(oCellT);
                oTBodyT.appendChild(oRowT);
            }
        }
        oTabelaT.appendChild(oTBodyT);
        oTabelaT.style.position="absolute";
        oTabelaT.style.visibility="hidden";
        //oTabelaT[iContadorT] = oTabela;
        iContadorT++;
        tabs.appendChild(oTabelaT);
    }


