// -----------------------------------------------------------
//                         menu.js
// -----------------------------------------------------------
// Descricao: Menu Vertical e Horizontal
// Criacao..: 01/12/2003
// Elaborado: Adriano A. Gobbo
// -----------------------------------------------------------
// Utilização : Deve ser criada um vetor de tabelas do tipo 
// 		lista com o nome do item, link e o target do 
//		link no corpo da pagina, maior esclarecimento 
//		sobre vetores no corpo da pagina;
//		Deverá ser criada um funçao de updateit no 
//		fim do corpo da pagina para poder formar um 
//		loop infinito, necessario para captura de 
//		movimento e clique de mouse e rolamento da 
//		barra de rolamento;
//		Para cada menu diferente que quiser criar no
// 		site deve-se repetir o código com variáveis 
//		diferentes;
//		Utiliza-se variáveis para formatar a tabela;
// ----------------------------------------------------------- 

/*Função para declarar tabela do tipo do menu
texto contém o texto do item, em link contém o link 
e em target contém o target do link*/
function linha(texto, funcao, link, target, tpPagina, parametro, acesso, menurestrito, idSubMenu)
{
	this.texto=texto;
	this.funcao=funcao;
	this.link=link;
	this.target=target;
	this.tpPagina=tpPagina;
	this.parametro=parametro;
	this.acesso=acesso;
	this.menurestrito=menurestrito;
	this.idSubMenu=idSubMenu;
}	

//////////////////////////////////////////
// Inicio das Funções de Menu Vertical  //
//////////////////////////////////////////

/*Aqui é chamada as funções que recebe e inclui as variáveis
das tabelas na função do menu*/
function showToolbar(vetorMenu,n,nv)
{
  menu = new Menu();
  totId = 0;
  for (i=0; i<n; i++)
  {
	//Aqui se inclui um item de menu sem link
    if (vetorMenu[i].funcao==0)
    {
		totId++;
		menu.addItem("a"+totId, vetorMenu[i].texto, vetorMenu[i].texto, null, null, vetorMenu[i].target, vetorMenu[i].tpPagina, null, vetorMenu[i].acesso, vetorMenu[i].menurestrito, nv, vetorMenu[i].idSubMenu);
    }
	/*Aqui se inclui um item, com link e sem submenu*/
    else if (vetorMenu[i].funcao==1)
	{
		totId++;
		local=vetorMenu[i].link;
		menu.addItem("a"+totId, vetorMenu[i].texto, vetorMenu[i].texto, local, local, vetorMenu[i].target, vetorMenu[i].tpPagina, vetorMenu[i].parametro, vetorMenu[i].acesso, null, nv, vetorMenu[i].idSubMenu);				
	}
	else if (vetorMenu[i].funcao==2)
	{
	/*Aqui se inclui um subitem, ou um item de submenu*/
		texto=vetorMenu[i].texto;
		texto+="&nbsp;";
		menu.addSubItem("a"+totId, texto, texto, vetorMenu[i].link, vetorMenu[i].target, vetorMenu[i].tpPagina, vetorMenu[i].parametro, vetorMenu[i].acesso, null, vetorMenu[i].idSubMenu);
	}    
  }
  menu.showMenu();
}


//----

/*Testando se o browser é Internet Explorer ou Netscape*/
if (navigator.appVersion.indexOf("MSIE")!=-1) {n=0;ie=1;n6=0;fShow="visible";fHide="hidden";}
if (navigator.appVersion.indexOf("MSIE")==-1) {n=1;ie=0;n6=0;fShow="show";fHide="hide";}
if (navigator.userAgent.indexOf("Gecko")!=-1) {n=0;ie=0;n6=1;fShow="visible";fHide="hidden";}
if (navigator.userAgent.indexOf("Opera")!=-1) {n=0;ie=0;n6=1;fShow="visible";fHide="hidden";}
window.onerror=new Function("return true")

/*É criada uma string com texto html imbutido para a criação do
menu. Aqui é criado apenas o corpo geral do html sem ser incluido as itens e subitens*/
function Menu()
{
/*Declaração de variáveis*/
  this.bgColor = "#ffffff";/*bgcolor da tabela principal que contém os itens*/
  this.addItem    = addItem;/*função de criar um item*/
  this.addSubItem = addSubItem;/*função de criar um subitem*/
  this.showMenu   = showMenu;/*função de executar o menu e Submenu*/
  this.mainPaneBorder = 0;/*borda da tabela principal*/
  this.subMenuPaneBorder = 1;/*borda do submenu*/
  this.subMenubgColor = "#99CCFF";/*bgcolor do submenu*/
  this.ieBorderColor = "#6699CC";/*cor de borda do submenu em internet explorer*/
  this.nBorderColor = URLAdmin + "/images/pixelBranco.gif";/*gif com pixel de cor para 
							separar subitens no menu*/
  this.subMenuPaneWidth = 190;/*width do submenu*/

  lastMenu = null;
	
  rightY = 0;
  leftY = 0;
  leftX = 0;

  HTMLstr = "";
  HTMLstr += "<!-- MENU PANE DECLARATION BEGINS -->\n";
  HTMLstr += "\n";
  if (ie||n6) HTMLstr += "<div id='MainTable'>\n";
  //HTMLstr += "<table class='menu' bgcolor='"+this.bgColor+"' border='"+this.mainPaneBorder+"' width=100% CELLSPACING=0 CELLPADDING=1>\n";
  HTMLstr += "<table class='menu' border='"+this.mainPaneBorder+"' width=100% CELLSPACING=0 CELLPADDING=1>\n";
  HTMLstr += "<!-- MAIN MENU STARTS -->\n";
  HTMLstr += "<!-- MAIN_MENU -->\n";
  HTMLstr += "<!-- MAIN MENU ENDS -->\n";
  HTMLstr += "</table>\n";
  HTMLstr += "\n";
  HTMLstr += "<!-- SUB MENU STARTS -->\n";
  HTMLstr += "<!-- SUB_MENU -->\n";
  HTMLstr += "<!-- SUB MENU ENDS -->\n";
  HTMLstr += "\n";
  if (ie||n6) HTMLstr+= "</div>\n";
  HTMLstr += "<!-- MENU PANE DECALARATION ENDS -->\n";
}


/*Adiciona um item na tabela principal, sendo ele um item que dispara um submenu, ou um
item que tem um link apenas*/
function addItem(idItem, text, hint, location, altLocation, target, tpPag, parametro, acesso, menurestrito, tot, idSubMenu)
{
  var Lookup = "<!-- ITEM "+idItem+" -->";
  if (HTMLstr.indexOf(Lookup) != -1)
  {
    return;
  }
  var MENUitem = "";
  MENUitem += "\n<!-- ITEM "+idItem+" -->\n";
  if (n)
  {	
    MENUitem += "<tr>\n";
    MENUitem += "<td width=5>&nbsp</td>";
    MENUitem += "<td>\n";
    MENUitem += "<ilayer name="+idItem+">";
    if (location != null)
    {
	  if (tpPag=="P")
	  {
		if (target=="P")
		{
		  if (location.indexOf("/scripts/")==-1)
		  {
		    MENUitem += "<a href='' class='menu' onClick='document.frmGeral.ItemMenu.value = \""+location+"\"; document.frmGeral.Parametro.value = \""+parametro+"\"; document.frmGeral.submit(); return false;' onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\">";
		  }
		  else
		  {
			MENUitem += "<a href='"+location+"' class='menu' onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\">";
		  }
		}
		if (target=="N")
		{
		  MENUitem += "<a href='' class='menu' onClick='novaJanela(\""+location+"\",0,\""+idSubMenu+"\");return false;' onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\">";
		}
		if (target=="A")
		{
		  MENUitem += "<a href='' class='menu' onClick='novaJanela(\""+location+"\",1,\""+idSubMenu+"\");return false;' onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\">";
		}
		//MENUitem += "<a href='' onClick='document.frmGeral.ItemMenu.value = \""+location+"\"; document.frmGeral.Parametro.value = \""+parametro+"\"; document.frmGeral.submit(); return false;' onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\">";	    
	  }
	  else
	  {
		if (target=="P")
		  MENUitem += "<a href='"+location+"' class='menu' target=_parent onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\">";
		if (target=="N")
		  MENUitem += "<a href='' class='menu' onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\" onClick='novaJanela(\""+location+"\"); return false;'>";
		if (target=="A")
		  MENUitem += "<a href='' class='menu' onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\" onClick='novaJanela(\""+location+"\",1); return false;'>";  
	  }	  
	}
    else
    {
      MENUitem += "<a href='.'  class='menu' target='"+target+"' onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\" onclick=\"return false;\">";
    }
    if ((altLocation!=null && acesso=="R")||(altLocation == null && menurestrito=="R"))
    {
	  MENUitem += "<B>";
	  MENUitem += text;
      MENUitem += "</b>";
    }
    else
    {
	  MENUitem += text;
    }
    MENUitem += "</a>";
    MENUitem += "</ilayer>";
    MENUitem += "</td>\n";
    MENUitem += "</tr>\n";
    MENUitem += "<tr><td height=1 width=100% colspan=2></td></tr>";    
  }
  if (ie||n6)
  {
    MENUitem += "<tr>\n";
    MENUitem += "<td width=5>&nbsp</td>";
    MENUitem += "<td>\n";
    MENUitem += "<div id='"+idItem+"' style='position:relative;'>\n";
    MENUitem += "<a ";
    if (hint != null)
      MENUitem += "title='"+hint+"' ";      
    if (location != null)
    {
      
	  if (tpPag=="P")
	  {
		if (target=="P")
		{
		  if (location.indexOf("/scripts/")==-1)
		  {
		    MENUitem += "<a href='' class='menu' onClick='document.frmGeral.ItemMenu.value = \""+location+"\"; document.frmGeral.Parametro.value = \""+parametro+"\"; document.frmGeral.submit(); return false;'";
		  }
		  else
		  {
			MENUitem += "<a href='"+location+"' class='menu'";
		  }
		}
		if (target=="N")
		{
		  MENUitem += "<a href='' class='menu' onClick='novaJanela(\""+location+"\",0,\""+idSubMenu+"\");return false;'";
		}
		if (target=="A")
		{
		  MENUitem += "<a href='' class='menu' onClick='novaJanela(\""+location+"\",1,\""+idSubMenu+"\");return false;'";
		}
	    //MENUitem += "<a href='' class='menu' onClick='document.frmGeral.ItemMenu.value = \""+location+"\"; document.frmGeral.Parametro.value = \""+parametro+"\"; document.frmGeral.submit(); return false;'";        
	  }
	  else
	  {
        if (target=="N")
		{
		  MENUitem += "href='' class='menu'";
          MENUitem += "onmouseover=\"hideAll()\" onClick='novaJanela(\""+location+"\",0,\""+idSubMenu+"\"); return false;' "; //alterei aqui
        }
        if (target=="A")
		{
		  MENUitem += "href='' class='menu'";
          MENUitem += "onmouseover=\"hideAll()\" onClick='novaJanela(\""+location+"\",1,\""+idSubMenu+"\"); return false;' "; //alterei aqui
        }
	  }	  
    }
    else
    {
      if (altLocation != null)
        MENUitem += "href='"+altLocation+"' class='menu' target='"+target+"' ";
      else
      {
        MENUitem += "href='.' class='menu' target='"+target+"' ";
      }
      MENUitem += "onmouseover=\"displaySubMenu('"+idItem+"', '"+tot+"')\" ";
      MENUitem += "onclick=\"return false;\" "
    }
    MENUitem += ">";
    if ((altLocation!=null && acesso=="R")||(altLocation == null && menurestrito=="R"))
    {
	  MENUitem += "<B>";
      MENUitem += text;
      MENUitem += "</b>";
    }
    else
    {
      MENUitem += text;
    }
    MENUitem += "</a>\n";
    MENUitem += "</div>\n";
    if (altLocation == null)
    {
	  MENUitem += "</td>\n";
	  MENUitem += "<td>\n";
	  MENUitem += "<img src='" + URLSeta + "/images/setaMenuVert.gif'>\n";
	}	
    MENUitem += "</td>\n";
    MENUitem += "</tr>\n";
/*Aqui é adicionada a linha azul entre os itens da tabela principal*/
    MENUitem += "<tr><td height=1 width=100% colspan=2><img src='" + URLAdmin + "/images/pixelRosa.gif' width=100% height=1></td></tr>";    
  }
  MENUitem += "<!-- END OF ITEM "+idItem+" -->\n\n";
  MENUitem += "<!-- MAIN_MENU -->\n";
  HTMLstr = HTMLstr.replace("<!-- MAIN_MENU -->\n", MENUitem);  
  
}

/*Adiciona um subitem no submenu já relacionado ao seu item*/

function addSubItem(idParent, text, hint, location, target, tpPag, parametro, acesso, menurestrito, idSubMenu)
{
  var MENUitem = "";
  Lookup = "<!-- ITEM "+idParent+" -->";
  if (HTMLstr.indexOf(Lookup) == -1)
  {
    alert(idParent + " not found");
    return;
  }
  Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->";
  if (HTMLstr.indexOf(Lookup) == -1)
  {
    if (n)
    {
      MENUitem += "\n";
      //MENUitem += "<layer id='"+idParent+"submenu' width='"+this.subMenuPaneWidth+"' bgcolor='"+this.subMenubgColor+"' visibility=hide>\n";
      //MENUitem += "<layer class='menuCor' id='"+idParent+"submenu' width='"+this.subMenuPaneWidth+"' visibility=hide>\n";
      MENUitem += "<layer class='CorDoMenu' id='"+idParent+"submenu' width='"+this.subMenuPaneWidth+"' visibility=hide>\n";
      MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
      MENUitem += "</layer>\n";
      MENUitem += "\n";
    }
    if (ie||n6)
    {
      MENUitem += "\n";
      MENUitem += "<div id='"+idParent+"submenu' style='position:absolute; visibility: hidden; width: "+this.subMenuPaneWidth+";'>\n";
      //MENUitem += "<table border=1 cellpading='0' cellspacing='0' bordercolor='"+this.ieBorderColor+"' bgcolor='"+this.subMenubgColor+"' width='"+this.subMenuPaneWidth+"'>\n";
      //MENUitem += "<table class='menuCor' border=1 cellpading='0' cellspacing='0' width='"+this.subMenuPaneWidth+"'>\n";
      MENUitem += "<table class='CorDoMenu' border=1 cellpading='0' cellspacing='0' width='"+this.subMenuPaneWidth+"'>\n";
      MENUitem += "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
      MENUitem += "</table>\n";
      MENUitem += "</div>\n";
      MENUitem += "\n";
    }
    MENUitem += "<!-- SUB_MENU -->\n";
    HTMLstr = HTMLstr.replace("<!-- SUB_MENU -->\n", MENUitem);
  }

  Lookup = "<!-- NEXT ITEM OF SUB MENU "+ idParent +" -->\n";
  if (tpPag=="P")
  {
	if (ie||n6) 
	{
	  if (target=="P")
	  {
		if (location.indexOf("/scripts/")==-1)
		{
	      MENUitem = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='' onClick='document.frmGeral.ItemMenu.value = \""+location+"\"; document.frmGeral.Parametro.value = \""+parametro+"\"; document.frmGeral.submit(); return false;'>";
	    }
	    else
	    {
		  MENUitem = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='"+location+"'>";
		}
	  }
	  if (target=="N")
	  {
	    MENUitem = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='' onClick='novaJanela(\""+location+"\",0,\""+idSubMenu+"\");return false;'>";
	  }
	  if (target=="A")
	  {
	    MENUitem = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='' onClick='novaJanela(\""+location+"\",1,\""+idSubMenu+"\");return false;'>";
	  }
	  if (acesso=="R")
		MENUitem += "<b>";
	  MENUitem += text;
	  if (acesso=="R")
	    MENUitem += "</b>";
	  MENUitem += "</a>\n";
//	  if (acesso=="R")
//		MENUitem += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
      MENUitem += "</td></tr>\n";					  
	}
	if (n) 
	{
	  if (target=="P")
	  {
	    if (location.indexOf("/scripts/")==-1)
	      MENUitem = "&nbsp;<a title='"+hint+"' href='' class='subMenu' onClick='document.frmGeral.ItemMenu.value = \""+location+"\"; document.frmGeral.Parametro.value = \""+parametro+"\"; document.frmGeral.submit(); return false;'>";
	    else
		  MENUitem = "&nbsp;<a title='"+hint+"' href='"+location+"' class='subMenu'>";
	  }
	  if (target=="N")
	  {
	    MENUitem = "&nbsp;<a title='"+hint+"' href='' class='subMenu' onClick='novaJanela(\""+location+"\",0,\""+idSubMenu+"\");return false;'>";	    
	  }
	  if (target=="A")
	  {
	    MENUitem = "&nbsp;<a title='"+hint+"' href='' class='subMenu' onClick='novaJanela(\""+location+"\",1,\""+idSubMenu+"\");return false;'>";
	  }
	  if (acesso=="R")
		MENUitem += "<b>";
	  MENUitem += text;
	  if (acesso=="R")
	    MENUitem += "</b>";
	  MENUitem += "</a>\n";	  
//	  if (acesso=="R")
//		MENUitem += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	  MENUitem += "<br>\n";
	  MENUitem += "<img src='"+this.nBorderColor+"' width=100% height=2><br>\n";    
	}
  }
  else
  {
	if (target=="P")
	{
	  if (ie||n6) 
	  {  
	    MENUitem = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hint+"' class='subMenu' target=_parent href='"+location+"'>";
	  if (acesso=="R")
		MENUitem += "<b>";
	  MENUitem += text;
	  if (acesso=="R")
	    MENUitem += "</b>";
	  MENUitem += "</a>\n";
//	    if (acesso=="R")
//		  MENUitem += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
		MENUitem += "</td></tr>\n";	  
	  }
	  if (n) 
	  {
  	    MENUitem = "&nbsp;<a title='"+hint+"' target=_parent href='' class='subMenu'>";
	  if (acesso=="R")
		MENUitem += "<b>";
	  MENUitem += text;
	  if (acesso=="R")
	    MENUitem += "</b>";
	  MENUitem += "</a>\n";
//  	    if (acesso=="R")
//		  MENUitem += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
		MENUitem += "<br>\n";
	    MENUitem += "<img src='"+this.nBorderColor+"' width=100% height=2><br>\n";
	  }
	}
	if (target=="N")
	{
	  //if (ie||n6) MENUitem = "<tr><td class='menuCor' height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='' onClick='novaJanela(\""+location+"\",0,\""+idSubMenu+"\");return false;'>"+text+"</a></td></tr>\n";
	  if (ie||n6) 
	  {
	    MENUitem = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='' onClick='novaJanela(\""+location+"\",0,\""+idSubMenu+"\");return false;'>";
	  if (acesso=="R")
		MENUitem += "<b>";
	  MENUitem += text;
	  if (acesso=="R")
	    MENUitem += "</b>";
	  MENUitem += "</a>\n";
//  	    if (acesso=="R")
//		  MENUitem += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
		MENUitem += "</td></tr>\n";	  
	  }
	  //if (ie||n6) MENUitem = "<tr><td height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='' onClick='novaJanela(\""+location+"\",0,\""+idSubMenu+"\");return false;'>"+text+"</a></td></tr>\n";
	  if (n) 
	  {
  	    MENUitem = "&nbsp;<a title='"+hint+"' href='' class='subMenu' onClick='novaJanela(\""+location+"\",0,\""+idSubMenu+"\");return false;'>";
	  if (acesso=="R")
		MENUitem += "<b>";
	  MENUitem += text;
	  if (acesso=="R")
	    MENUitem += "</b>";
	  MENUitem += "</a>\n";
  	  //  if (acesso=="R")
		//  MENUitem += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
		MENUitem += "<br>\n";
	    MENUitem += "<img src='"+this.nBorderColor+"' width=100% height=2><br>\n";
	  }
	}
	if (target=="A")
	{
	  //if (ie||n6) MENUitem = "<tr><td class='menuCor' height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='' onClick='novaJanela(\""+location+"\",1,\""+idSubMenu+"\");return false;'>"+text+"</a></td></tr>\n";
	  if (ie||n6) 
	  {
	    MENUitem = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='' onClick='novaJanela(\""+location+"\",1,\""+idSubMenu+"\");return false;'>";
	  if (acesso=="R")
		MENUitem += "<b>";
	  MENUitem += text;
	  if (acesso=="R")
	    MENUitem += "</b>";
	  MENUitem += "</a>\n";
  	  //  if (acesso=="R")
		//  MENUitem += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
		MENUitem += "</td></tr>\n";	  
	  }
	  //if (ie||n6) MENUitem = "<tr><td height='1'>&nbsp;<a title='"+hint+"' class='subMenu' href='' onClick='novaJanela(\""+location+"\",1,\""+idSubMenu+"\");return false;'>"+text+"</a></td></tr>\n";
	  if (n) 
	  {
  	    MENUitem = "&nbsp;<a title='"+hint+"' href='' class='subMenu' onClick='novaJanela(\""+location+"\",1,\""+idSubMenu+"\");return false;'>";
	  if (acesso=="R")
		MENUitem += "<b>";
	  MENUitem += text;
	  if (acesso=="R")
	    MENUitem += "</b>";
	  MENUitem += "</a>\n";
  	  //  if (acesso=="R")
		//  MENUitem += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
		MENUitem += "<br>\n";
	    MENUitem += "<img src='"+this.nBorderColor+"' width=100% height=2><br>\n";
	  }
	}
  }
  MENUitem += Lookup;
  
  HTMLstr = HTMLstr.replace(Lookup, MENUitem);  
}

/*É executado o menu criado*/
function showMenu()
{
//alert(HTMLstr);
  document.writeln(HTMLstr);
}

/*É criada as relações de posição do submenu, onde ele aparece, e o campo que o mouse
pode se movimentar sem desaparecer o menu*/
function displaySubMenu(idMainMenu, tot)
{	
  var menu;
  var submenu;

  //---identificando o browser do cliente
  navegador=navigator.appName;
  versao=navigator.appVersion;
  atualizacao=navigator.appMinorVersion;
  //---fim

  if (n)
  {
	/*posições do submenu*/
    submenu = document.layers[idMainMenu+"submenu"];
    if (lastMenu != null && lastMenu != submenu) hideAll();
    submenu.left = document.layers[idMainMenu].pageX + document.layers[idMainMenu].clip.width + 10;
    submenu.top  = document.layers[idMainMenu].pageY;
    submenu.visibility = fShow;

	/*campo onde mouse pode se movimentar sem desaparecer o menu*/
    leftX  = document.layers[idMainMenu].left;
    rightX = leftX + document.layers[idMainMenu+"submenu"].left + document.layers[idMainMenu+"submenu"].clip.width;
    leftY  = document.layers[idMainMenu+"submenu"].top;
    rightY = leftY + document.layers[idMainMenu+"submenu"].clip.height;
  } 
  if (ie) 
  {
    menu = eval(idMainMenu);
    submenu = eval(idMainMenu+"submenu.style");
	/*posições do submenu*/
    submenu.left = calculateSumOffset(menu, 'offsetLeft') + document.all[idMainMenu].offsetWidth + 1;
	/*Posição do menu de acordo com cada versão, a partir do MSIE 5.0*/
	if (((versao.indexOf("MSIE 6.0")!=-1) &&
	     (atualizacao.indexOf("SP1")!=-1) && 
		 (atualizacao.indexOf("SP2")!=-1) && 
		 (atualizacao.indexOf("SP3")!=-1) && 
		 (atualizacao.indexOf("Q831167")==-1)&&
		 (atualizacao.indexOf("Q837009")==-1)&&
		 (atualizacao.indexOf("Q810847")==-1)&&
		 (atualizacao.indexOf("Q324929")==-1)&&
		 (atualizacao!=';SP1;')&&
		 (atualizacao!=';SP2;')&&
		 (atualizacao!=';SP3;'))
	   ||
	   (versao.indexOf("MSIE 5.0")!=-1)) 
	{
		submenu.top = calculateSumOffset(menu, 'offsetTop');
	}
    else if ((((versao.indexOf("MSIE 6.0")!=-1)&&
              (atualizacao.indexOf("SP1")!=-1)&& 
			  (atualizacao.indexOf("SP2")!=-1)&&
			  (atualizacao.indexOf("SP3")!=-1)&&
			  (atualizacao.indexOf("q313829")==-1)&&
			  (atualizacao.indexOf("Q813489")==-1)&&
			  (atualizacao.indexOf("Q818529")==-1)&&
			  (atualizacao.indexOf("Q832894")==-1)&&
			  (atualizacao.indexOf("Q822925")==-1)&&
			  (atualizacao.indexOf("Q828750")==-1)&&
			  (atualizacao.indexOf("Q824145")==-1))
			 ||(versao.indexOf("MSIE 5.5")!=-1)
			 ||((versao.indexOf("MSIE 6.0")!=-1)&&
			    (atualizacao.indexOf("SP1")==-1)&&
			    (atualizacao.indexOf("SP2")==-1)&&
			    (atualizacao.indexOf("SP3")==-1))) && (versao.indexOf("MSIE 7.0") == -1) && (versao.indexOf("MSIE 8.0") == -1))
    {	
		// é criado um ajuste (relativo á posição vertical) para cada cliente, e depois é preenchida a posição de topo do menu
		if (SiglaCliente=="DP")
			ajuste = -25
		else if (SiglaCliente=="PMES")
			ajuste = 9
		else if (SiglaCliente=="SESA")
			ajuste = -1
		else if (SiglaCliente=="ADMIN")
			ajuste = 0
		else if (SiglaCliente=="PRODEST")
			ajuste = 0
		else if (SiglaCliente=="FAMES")
			ajuste = -14
		else if (SiglaCliente=="PGE")
			ajuste = 10
		else if (SiglaCliente=="DETRAN")
			ajuste = -26
		else if (SiglaCliente=="ASPE")
			ajuste = 2
		else if (SiglaCliente=="SEDU")
			ajuste = 11
		else if (SiglaCliente=="DP")
			ajuste = 0
		else if (SiglaCliente=="PORTALDOSMUNICIPIOS")
			ajuste = 11
		else if (SiglaCliente=="PMAC")
			ajuste = 31
		else if (SiglaCliente=="PMARN")
			ajuste = 36
		else if (SiglaCliente=="PMI")
			ajuste = 18
		else if (SiglaCliente=="PMA")
			ajuste = 36
		else if (SiglaCliente=="PMBE")
			ajuste = 0
		else if (SiglaCliente=="PMC")
			ajuste = 36
		else if (SiglaCliente=="PMDM")
			ajuste = 36
		else if (SiglaCliente=="PMGL")
			ajuste = 36
		else if (SiglaCliente=="PMIBITIRAMA")
			ajuste = 36
		else if (SiglaCliente=="PMLT")
			ajuste = 36
		else if (SiglaCliente=="PMNV")
			ajuste = 36
		else if (SiglaCliente=="PMP")
			ajuste = 36
		else if (SiglaCliente=="PMPK")
			ajuste = -26
		else if (SiglaCliente=="PMRB")
			ajuste = -13
		else if (SiglaCliente=="PMJM")
			ajuste = 36
		else if (SiglaCliente=="PMSL")
			ajuste = 36
		else if (SiglaCliente=="PMST")
			ajuste = 36
		else if (SiglaCliente=="PMVA")
			ajuste = 36
		else if (SiglaCliente=="PMV")
			ajuste = 36
		else if (SiglaCliente=="PMVV")
			ajuste = 36
		else if (SiglaCliente=="PMM")
			ajuste = 36
		else
			ajuste = 0;
		submenu.top = calculateSumOffset(menu, "offsetTop")/2 + 91 + ajuste;				
	}
	else 
	{
		submenu.top = calculateSumOffset(menu, 'offsetTop');
	}
	submenu.visibility = fShow;
    if (lastMenu != null && lastMenu != submenu) hideAll();

	/*campo onde mouse pode se movimentar sem desaparecer o menu*/
    leftX  = document.all[idMainMenu].offsetLeft;
    rightX = document.all[idMainMenu+"submenu"].offsetLeft + document.all[idMainMenu].offsetWidth + document.all[idMainMenu+"submenu"].offsetWidth;
    leftY  = document.all[idMainMenu+"submenu"].style.posTop - document.body.scrollTop;    
    rightY = leftY + document.all[idMainMenu+"submenu"].offsetHeight;    
  }
  if (n6)
  {
    menu = document.getElementById(idMainMenu);
    submenu = document.getElementById(idMainMenu+"submenu").style;
	/*posições do submenu*/
    submenu.left = calculateSumOffset(menu, 'offsetLeft') + parseInt(document.getElementById(idMainMenu).offsetWidth);   
	/*Posição do menu de acordo com cada versão*/
    submenu.top = calculateSumOffset(menu, 'offsetTop');
    submenu.visibility = fShow;
    if (lastMenu != null && lastMenu != submenu) hideAll();
   
	/*campo onde mouse pode se movimentar sem desaparecer o menu*/
    leftX  = calculateSumOffset(menu, 'offsetLeft');
    rightX = parseInt(document.getElementById(idMainMenu+"submenu").style.left) + parseInt(document.getElementById(idMainMenu+"submenu").offsetWidth);
    leftY  = parseInt(document.getElementById(idMainMenu+"submenu").style.top);    
    rightY = leftY + parseInt(document.getElementById(idMainMenu+"submenu").offsetHeight);     
  }
  lastMenu = submenu;
}

/*Calcula posicao do menu para internet explorer*/
function calculateSumOffset(idItem, offsetName)
{
	var totalOffset = 0;
	var item = eval('idItem');
	//do
	while (item != null)
	{
	//	alert(totalOffset);
		totalOffset += eval('item.'+offsetName);
		item = eval('item.offsetParent');		
	}
	//} while (item != null);
	return totalOffset;
}

/*função que faz o submenu desaparecer*/
function hideAll()
{
  if (lastMenu != null) 
  {
    lastMenu.visibility = fHide;
    lastMenu.left = 0;
  }
}

/*Nessa função, que fica em loop durante a visualisação da home page, é sempre testado 
se o mouse está ou não dentro do campo de movimentação do mouse, para saber se deve ou
não fazer o menu desaparecer */
function updateIt(e)
{
  if (ie)
  {
    var x = window.event.clientX;
    var y = window.event.clientY;
    var xh = window.event.clientX;
    var yh = window.event.clientY; 
    
    if (x > rightX || x < leftX) hideAll();
    else if (y > rightY || y < leftY) hideAll();
    
    if (xh > rightXh || xh < leftXh) hideAllh();
    else if (yh > rightYh || yh < leftYh) hideAllh();
  }
  if (n||n6)
  {
    var x = e.pageX;
    var y = e.pageY;

    if (x > rightX || x < leftX) hideAll();
    else if (y > rightY || y < leftY) hideAll();
    
    if (x > rightXh || x < leftXh) hideAllh();
    else if (y > rightYh || y < leftYh) hideAllh();
  }
}


/*função em loop que captura os movimentos e cliques do mouse e arraste de barra
de rolamento da página, para desaparecer o menu*/
function UpdateIt()
{
  rightX = 0;
  
  if (ie)
  {
    setTimeout("UpdateIt(MainTable)", 200);
  }

  if (ie||n6)
  {
    document.body.onclick=hideAll;
    document.body.onscroll=hideAll;
    document.body.onmousemove=updateIt;
  }
  
  if (n)
  {
    document.onmousedown=hideAll;
    window.captureEvents(Event.MOUSEMOVE);
    window.onmousemove=updateIt;
  }
  
  rightXh = 0;
  
  if (ie)
  {
    setTimeout("UpdateIt()", 200);
  }
}

///////////////////////////////////////
// Fim das Funções de Menu Vertical  //
///////////////////////////////////////

////////////////////////////////////////////
// Inicio das Funções de Menu Horizontal  //
////////////////////////////////////////////


/* MENU HORIZONTAL. */

/*Aqui é chamada as funções que recebe e inclui as variáveis
das tabelas na função do menu*/
function showHorizontalbar(vetMenu,nh)
{
  menuh = new Menuh();
  totIdh = 0;
  for (i=0; i<nh; i++)
  {		
	//Aqui se inclui um item de menu sem link
    if (vetMenu[i].funcao==0)
    {
		totIdh++;
		menuh.addItemh("h"+totIdh, vetMenu[i].texto, vetMenu[i].texto, null, null, vetMenu[i].target, vetMenu[i].tpPagina, null, vetMenu[i].acesso, vetMenu[i].menurestrito, vetMenu[i].idSubMenu);
    }
	/*Aqui se inclui um item, com link e sem submenu*/
    else if (vetMenu[i].funcao==1)
	{
		totIdh++;
		localh=vetMenu[i].link;
		menuh.addItemh("h"+totIdh, vetMenu[i].texto, vetMenu[i].texto, localh, localh, vetMenu[i].target, vetMenu[i].tpPagina, vetMenu[i].parametro, vetMenu[i].acesso, null, vetMenu[i].idSubMenu);		
	}
	else if (vetMenu[i].funcao==2)
	{
	/*Aqui se inclui um subitem, ou um item de submenu*/
	    menuh.addSubItemh("h"+totIdh, vetMenu[i].texto, vetMenu[i].texto, vetMenu[i].link, vetMenu[i].target, vetMenu[i].tpPagina, vetMenu[i].parametro, vetMenu[i].acesso, null, vetMenu[i].idSubMenu);
	}    
  }
  menuh.showMenuh();
}



/*É criada uma string com texto html imbutido para a criação do
menu. Aqui é criado apenas o corpo geral do html sem ser incluido as itens e subitens*/
function Menuh()
{
  this.bgColorh = "#ffffff";/*bgcolor do menu*/
  this.addItemh    = addItemh;/*funcao que adiciona item do menu*/
  this.addSubItemh = addSubItemh;/*funcao que adiciona subitem do submenu*/
  this.showMenuh   = showMenuh;/*funcao que executa o menu e submenu*/
  this.mainPaneBorderh = 0;/*borda do menu*/
  this.subMenuPaneBorderh = 1;/*borda do submenu*/
  this.subMenubgColorh = "#99CCFF";/*bg color do submenu*/
  this.ieBorderColorh = "#6699CC";/*cor de borda do submenu em internet explorer*/
  this.nBorderColorh = URLAdmin + "/images/pixelBranco.gif";/*gif com pixel de cor para 
							 separar subitens no menu*/
  this.subMenuPaneWidthh = 190;/*width do submenu*/
  
  lastMenuh = null;
	
  rightYh = 0;
  leftYh = 0;
  leftXh = 0;

  HTMLstrh = "";
  HTMLstrh += "<!-- MENU PANE DECLARATION BEGINS -->\n";
  HTMLstrh += "\n";
  if (ie||n6) HTMLstrh += "<div id='MainTableh'>\n";
  //HTMLstrh += "<table align='right' class='menuh' bgcolor='"+this.bgColorh+"' border='"+this.mainPaneBorderh+"' CELLSPACING=0 CELLPADDING=1>\n";
  HTMLstrh += "<table align='right' class='menuh' border='"+this.mainPaneBorderh+"' CELLSPACING=0 CELLPADDING=1>\n";  
  HTMLstrh += "<!-- MAIN MENU STARTS -->\n";
  HTMLstrh += "<!-- MAIN_MENU -->\n";
  HTMLstrh += "<!-- MAIN MENU ENDS -->\n";
  HTMLstrh += "</table>\n";
  HTMLstrh += "\n";
  HTMLstrh += "<!-- SUB MENU STARTS -->\n";
  HTMLstrh += "<!-- SUB_MENU -->\n";
  HTMLstrh += "<!-- SUB MENU ENDS -->\n";
  HTMLstrh += "\n";
  if (ie||n6) HTMLstrh += "</div>\n";
  HTMLstrh += "<!-- MENU PANE DECALARATION ENDS -->\n";
}

/*aqui é adicionado os itens de menu*/
function addItemh(idItemh, texth, hinth, locationh, altLocationh, targeth, tpPagh, parametroh, acessoh, menurestritoh, idSubMenuh)
{
  var Lookuph = "<!-- ITEM "+idItemh+" -->";
  if (HTMLstrh.indexOf(Lookuph) != -1)
  {
    return;
  }
  var MENUitemh = "";
  MENUitemh += "\n<!-- ITEM "+idItemh+" -->\n";
  if (n)
  {	
    MENUitemh += "<td>\n";
    MENUitemh += "<ilayer name="+idItemh+">";
    if (locationh != null)
      if (tpPagh=="P")
	  {
		if (targeth=="P")
		{
		  if (locationh.indexOf("/scripts/")==-1)
		  {
		    MENUitemh += "<a href='' class='menuh' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\"; document.frmGeral.Parametro.value = \""+parametroh+"\"; document.frmGeral.submit(); return false;' onmouseover=\"displaySubMenuh('"+idItem+"')\">";
		  }
		  else
		  {
			MENUitemh += "<a href='"+location+"' class='menuh' onmouseover=\"displaySubMenuh('"+idItem+"')\">";
		  }
		}
		if (targeth=="N")
		{
		  MENUitemh += "<a href='' class='menuh' onClick='novaJanela(\""+locationh+"\",0,\""+idSubMenuh+"\");return false;' onmouseover=\"displaySubMenuh('"+idItem+"')\">";
		}
		if (targeth=="A")
		{
		  MENUitemh += "<a href='' class='menuh' onClick='novaJanela(\""+locationh+"\",1,\""+idSubMenuh+"\");return false;' onmouseover=\"displaySubMenuh('"+idItem+"')\">";
		}
	    //MENUitemh += "<a href='' class='menuh' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\";  document.frmGeral.Parametro.value = \""+parametroh+"\";document.frmGeral.submit(); return false;'>";
	  }
	  else
	  {	    
		if (targeth=="N")
		  MENUitemh += "<a href='' class='menuh' onmouseover=\"displaySubMenuh('"+idItemh+"')\" onClick='novaJanela(\""+locationh+"\",0,); return false;'>";
		if (targeth=="A")
		  MENUitemh += "<a href='' class='menuh' onmouseover=\"displaySubMenuh('"+idItemh+"')\" onClick='novaJanela(\""+locationh+"\",1); return false;'>";  
	  }
    else
      MENUitemh += "<a href='.'  class='menuh' target='"+targeth+"' onmouseover=\"displaySubMenuh('"+idItemh+"')\" onclick=\"return false;\">";
    if ((altLocationh!=null && acessoh=="R")||(altLocationh == null && menurestritoh=="R"))
		MENUitemh += "<b>";
    MENUitemh += texth;
    if ((altLocationh!=null && acessoh=="R")||(altLocationh == null && menurestritoh=="R"))
		MENUitemh += "</b>";
    MENUitemh += "</a>";
// //   if ((altLocationh!=null && acessoh=="R")||(altLocationh == null && menurestritoh=="R"))
  //    MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
    MENUitemh += "</ilayer>";
    MENUitemh += "</td><td>&nbsp;&nbsp;</td>\n";
  }
  if (ie||n6)
  {
    //MENUitemh += "<td width=5>&nbsp</td>";
    MENUitemh += "<td>\n";
    MENUitemh += "<div id='"+idItemh+"' style='position:relative;'>\n";
    MENUitemh += "<a ";
    if (hinth != null)
      MENUitemh += "title='"+hinth+"' ";      
    if (locationh != null)
    {
      if (tpPagh=="P")
	  {
	    //MENUitemh += "<a href='' class='menuh' target='"+targeth+"' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\"; document.frmGeral.Parametro.value = \""+parametroh+"\"; document.frmGeral.submit(); return false;'";
	    if (targeth=="P")
		{
		  if (locationh.indexOf("/scripts/")==-1)
		  {
		    MENUitemh += "<a href='' class='menuh' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\"; document.frmGeral.Parametro.value = \""+parametroh+"\"; document.frmGeral.submit(); return false;'";
		  }
		  else
		  {
			MENUitemh += "<a href='"+locationh+"' class='menuh'";
		  }
		}
		if (targeth=="N")
		{
		  MENUitemh += "<a href='' class='menuh' onClick='novaJanela(\""+locationh+"\",0,\""+idSubMenuh+"\");return false;'";
		}
		if (targeth=="A")
		{
		  MENUitemh += "<a href='' class='menuh' onClick='novaJanela(\""+locationh+"\",1,\""+idSubMenuh+"\");return false;'";
		}
	  }
	  else
	  {
	    if (targeth=="N")
		{
		  MENUitemh += "href='' class='menuh'";
          MENUitemh += "onmouseover=\"hideAllh()\" onClick='novaJanela(\""+locationh+"\",0,\""+idSubMenuh+"\"); return false;' "; //alterei aqui
        }
        if (targeth=="A")
		{
		  MENUitemh += "href='' class='menuh'";
          MENUitemh += "onmouseover=\"hideAllh()\" onClick='novaJanela(\""+locationh+"\",1,\""+idSubMenuh+"\"); return false;' "; //alterei aqui
        }
		//MENUitemh += "href='"+locationh+"' class='menuh' target='"+targeth+"' ";
        //MENUitemh += "onmouseover=\"hideAll()\" ";
        //MENUitem += "<a href='"+location+"' class='menu' target='"+target+"' onmouseover=\"displaySubMenu('"+idItem+"')\">";
	  }
	  //MENUitemh += "href='"+locationh+"' class='menuh' target='"+targeth+"' ";
      //MENUitemh += "onmouseover=\"hideAllh()\" ";
    }
    else
    {
      if (altLocationh != null)
        MENUitemh += "href='"+altLocationh+"' class='menuh' target='"+targeth+"' ";
      else
        MENUitemh += "href='.' class='menuh' target='"+targeth+"' ";
      MENUitemh += "onmouseover=\"displaySubMenuh('"+idItemh+"')\" ";
      MENUitemh += "onclick=\"return false;\" "
    }
    MENUitemh += ">";
    if ((altLocationh!=null && acessoh=="R")||(altLocationh == null && menurestritoh=="R"))
		MENUitemh += "<b>";
    MENUitemh += texth;
    if ((altLocationh!=null && acessoh=="R")||(altLocationh == null && menurestritoh=="R"))
		MENUitemh += "</b>";
    MENUitemh += "</a>\n";
    //if (acessoh=="R" && altLocationh != null)
	  //MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	MENUitemh += "</div>\n";
    if (altLocationh == null)
    {
	  MENUitemh += "</td>\n";
	  MENUitemh += "<td>\n";
	  MENUitemh += "<img src='" + URLSeta + "/images/setaMenuHor.gif'>\n";
	}
    MENUitemh += "</td><td>&nbsp;&nbsp;</td>\n";
  }
  MENUitemh += "<!-- END OF ITEM "+idItemh+" -->\n\n";
  MENUitemh += "<!-- MAIN_MENU -->\n";

  HTMLstrh = HTMLstrh.replace("<!-- MAIN_MENU -->\n", MENUitemh);  
}

/*é adicionado um subitem de submenu*/
function addSubItemh(idParenth, texth, hinth, locationh, targeth, tpPagh, parametroh, acessoh, menurestritoh, idSubMenuh)
{
  var MENUitemh = "";
  Lookuph = "<!-- ITEM "+idParenth+" -->";
  if (HTMLstrh.indexOf(Lookuph) == -1)
  {
    alert(idParenth + " not found");
    return;
  }
  Lookuph = "<!-- NEXT ITEM OF SUB MENU "+ idParenth +" -->";
  if (HTMLstrh.indexOf(Lookuph) == -1)
  {
    if (n)
    {
      MENUitemh += "\n";
      MENUitemh += "<layer id='"+idParenth+"submenuh' width='"+this.subMenuPaneWidthh+"' bgcolor='"+this.subMenubgColorh+"' visibility=hide>\n";
      //MENUitemh += "<layer class='menuCor' id='"+idParenth+"submenuh' width='"+this.subMenuPaneWidthh+"' visibility=hide>\n";
      MENUitemh += "<layer class='CorDoMenu' id='"+idParenth+"submenuh' width='"+this.subMenuPaneWidthh+"' visibility=hide>\n";      
      //MENUitemh += "<!-- NEXT ITEM OF SUB MENU "+ idParenth +" -->\n";
      MENUitemh += "</layer>\n";
      MENUitemh += "\n";
    }
    if (ie||n6)
    {
      MENUitemh += "\n";
      MENUitemh += "<div id='"+idParenth+"submenuh' style='position:absolute; visibility: hidden; width: "+this.subMenuPaneWidthh+";'>\n";
      //MENUitemh += "<table border=1 cellpading='0' cellspacing='0' bordercolor='"+this.ieBorderColorh+"' bgcolor='"+this.subMenubgColorh+"' width='"+this.subMenuPaneWidthh+"'>\n";
      //MENUitemh += "<table class='menuCor' border=1 cellpading='0' cellspacing='0' width='"+this.subMenuPaneWidthh+"'>\n";
      MENUitemh += "<table class='CorDoMenu' border=1 cellpading='0' cellspacing='0' width='"+this.subMenuPaneWidthh+"'>\n";      
      MENUitemh += "<!-- NEXT ITEM OF SUB MENU "+ idParenth +" -->\n";
      MENUitemh += "</table>\n";
      MENUitemh += "</div>\n";
      MENUitemh += "\n";
    }
    MENUitemh += "<!-- SUB_MENU -->\n";
    HTMLstrh = HTMLstrh.replace("<!-- SUB_MENU -->\n", MENUitemh);
  }

  Lookuph = "<!-- NEXT ITEM OF SUB MENU "+ idParenth +" -->\n";
  if (tpPagh=="P")
  {
	//if (ie||n6) MENUitemh = "<tr><td class='menuCor' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' targeth='"+targeth+"' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\";  document.frmGeral.Parametro.value = \""+parametroh+"\"; document.frmGeral.submit(); return false;'>"+texth+"</a></td></tr>\n";
	if (ie||n6) 
	{
	  //MENUitemh = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' targeth='"+targeth+"' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\";  document.frmGeral.Parametro.value = \""+parametroh+"\"; document.frmGeral.submit(); return false;'>";
	  if (targeth=="P")
	  {
		if (locationh.indexOf("/scripts/")==-1)
		{
	      MENUitemh = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\"; document.frmGeral.Parametro.value = \""+parametroh+"\"; document.frmGeral.submit(); return false;'>";
	    }
	    else
	    {
		  MENUitemh = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='"+locationh+"'>";
		}
	  }
	  if (targeth=="N")
	  {
	    MENUitemh = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' onClick='novaJanela(\""+locationh+"\",0,\""+idSubMenuh+"\");return false;'>";
	  }
	  if (targeth=="A")
	  {
	    MENUitemh = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' onClick='novaJanela(\""+locationh+"\",1,\""+idSubMenuh+"\");return false;'>";
	  }
	  if (acessoh=="R")
		MENUitemh += "<b>";
	  MENUitemh += texth;
	  if (acessoh=="R")
	    MENUitemh += "</b>";
	  MENUitemh += "</a>\n";
	  //if (acessoh=="R")
	    //MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	  MENUitemh += "</td></tr>\n";	
	}
	//if (ie||n6) MENUitemh = "<tr><td height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' targeth='"+targeth+"' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\";  document.frmGeral.Parametro.value = \""+parametroh+"\"; document.frmGeral.submit(); return false;'>"+texth+"</a></td></tr>\n";
	if (n) 
	{
	  //MENUitemh = "&nbsp;<a title='"+hinth+"' href='' class='subMenuh' targeth='"+targeth+"' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\"; document.frmGeral.Parametro.value = \""+parametroh+"\"; document.frmGeral.submit(); return false;'>";
	  if (targeth=="P")
	  {
	    if (locationh.indexOf("/scripts/")==-1)
	      MENUitemh = "&nbsp;<a title='"+hinth+"' href='' class='subMenuh' onClick='document.frmGeral.ItemMenu.value = \""+locationh+"\"; document.frmGeral.Parametro.value = \""+parametroh+"\"; document.frmGeral.submit(); return false;'>";
	    else
		  MENUitemh = "&nbsp;<a title='"+hinth+"' href='"+locationh+"' class='subMenuh'>";
	  }
	  if (targeth=="N")
	  {
	    MENUitemh = "&nbsp;<a title='"+hinth+"' href='' class='subMenuh' onClick='novaJanela(\""+locationh+"\",0,\""+idSubMenuh+"\");return false;'>";	    
	  }
	  if (targeth=="A")
	  {
	    MENUitemh = "&nbsp;<a title='"+hinth+"' href='' class='subMenuh' onClick='novaJanela(\""+locationh+"\",1,\""+idSubMenuh+"\");return false;'>";
	  }
	  if (acessoh=="R")
		MENUitemh += "<b>";
	  MENUitemh += texth;
	  if (acessoh=="R")
	    MENUitemh += "</b>";
	    MENUitemh += "</a>\n";
	  //if (acessoh=="R")
	    //MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	  MENUitemh += "<br>\n";
	  MENUitemh += "<img src='"+this.nBorderColorh+"' width=100% height=2><br>\n";
	}	
  }
  else
  {
	if (targeth=="P")
	{
	  //if (ie||n6) MENUitemh = "<tr><td class='menuCor' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='"+locationh+"' targeth='"+targeth+"'>"+texth+"</a></td></tr>\n";
	  if (ie||n6)
	  {
	    MENUitemh = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='"+locationh+"' targeth='"+targeth+"'>";
	  if (acessoh=="R")
		MENUitemh+= "<b>";
	  MENUitemh += texth;
	  if (acessoh=="R")
	    MENUitemh+= "</b>";
	    MENUitemh += "</a>\n";
	//  if (acessoh=="R")
	  //  MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	  MENUitemh += "</td></tr>\n";	  
	  }
	  //if (ie||n6) MENUitemh = "<tr><td height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='"+locationh+"' targeth='"+targeth+"'>"+texth+"</a></td></tr>\n";
	  if (n) 
	  {
	    MENUitemh = "&nbsp;<a title='"+hinth+"' href='"+locationh+"' class='subMenuh' targeth='"+targeth+"'>";
	  if (acessoh=="R")
		MENUitemh+= "<b>";
	  MENUitemh += texth;
	  if (acessoh=="R")
	    MENUitemh+= "</b>";
	    MENUitemh += "</a>\n";
//	  if (acessoh=="R")
//	    MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	  MENUitemh += "<br>\n";
	    MENUitemh += "<img src='"+this.nBorderColorh+"' width=100% height=2><br>\n";
	  }
	}
	if (targeth=="N")
	{
	  //if (ie||n6) MENUitemh = "<tr><td class='menuCor' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' onClick='novaJanela(\""+locationh+"\",0,\""+idSubMenuh+"\");return false;'>"+texth+"</a></td></tr>\n";
	  if (ie||n6) 
	  {
	    MENUitemh = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' onClick='novaJanela(\""+locationh+"\",0,\""+idSubMenuh+"\");return false;'>";
	  if (acessoh=="R")
		MENUitemh+= "<b>";
	  MENUitemh += texth;
	  if (acessoh=="R")
	    MENUitemh+= "</b>";
	    MENUitemh += "</a>\n";
//	  if (acessoh=="R")
//	    MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	  MENUitemh += "</td></tr>\n";	  
	  }
	  //if (ie||n6) MENUitemh = "<tr><td height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' onClick='novaJanela(\""+locationh+"\",0,\""+idSubMenuh+"\");return false;'>"+texth+"</a></td></tr>\n";
	  if (n) 
	  {
  	    MENUitemh = "&nbsp;<a title='"+hinth+"' href='' class='subMenuh' onClick='novaJanela(\""+locationh+"\",0,\""+idSubMenuh+"\");return false;'>";
	  if (acessoh=="R")
		MENUitemh+= "<b>";
	  MENUitemh += texth;
	  if (acessoh=="R")
	    MENUitemh+= "</b>";
	    MENUitemh += "</a>\n";
//	  if (acessoh=="R")
//	    MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	  MENUitemh += "<br>\n";
	    MENUitemh += "<img src='"+this.nBorderColorh+"' width=100% height=2><br>\n";
	  }
	}
	if (targeth=="A")
	{
	  //if (ie||n6) MENUitemh = "<tr><td class='menuCor' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' onClick='novaJanela(\""+locationh+"\",1,\""+idSubMenuh+"\");return false;'>"+texth+"</a></td></tr>\n";
	  if (ie||n6)
	  {
	    MENUitemh = "<tr><td class='CorDoMenu' height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' onClick='novaJanela(\""+locationh+"\",1,\""+idSubMenuh+"\");return false;'>";
	  if (acessoh=="R")
		MENUitemh+= "<b>";
	  MENUitemh += texth;
	  if (acessoh=="R")
	    MENUitemh+= "</b>";
	    MENUitemh += "</a>\n";
//	  if (acessoh=="R")
//	    MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	  MENUitemh += "</td></tr>\n";	  
	  }
	  //if (ie||n6) MENUitemh = "<tr><td height='1'>&nbsp;<a title='"+hinth+"' class='subMenuh' href='' onClick='novaJanela(\""+locationh+"\",1,\""+idSubMenuh+"\");return false;'>"+texth+"</a></td></tr>\n";
	  if (n) 
	  {
  	    MENUitemh = "&nbsp;<a title='"+hinth+"' href='' class='subMenuh' onClick='novaJanela(\""+locationh+"\",1,\""+idSubMenuh+"\");return false;'>";
	  if (acessoh=="R")
		MENUitemh+= "<b>";
	  MENUitemh += texth;
	  if (acessoh=="R")
	    MENUitemh+= "</b>";
	    MENUitemh += "</a>\n";
//	  if (acessoh=="R")
//	    MENUitemh += "<img src='" + URLAdmin + "/images/loginR.gif' height=12 width=16>\n";	  
	  MENUitemh += "<br>\n";
	    MENUitemh += "<img src='"+this.nBorderColorh+"' width=100% height=2><br>\n";
	  }
	}
  }
  MENUitemh += Lookuph;
  
  HTMLstrh = HTMLstrh.replace(Lookuph, MENUitemh);  
}

/*executa o menu criado*/
function showMenuh()
{
  document.writeln(HTMLstrh);
}

/*É criada as relações de posição do submenu, onde ele aparece, e o campo que o mouse
pode se movimentar sem desaparecer o menu*/
function displaySubMenuh(idMainMenuh)
{
  var menuh;
  var submenuh;
  if (n)
  {
    submenuh = document.layers[idMainMenuh+"submenuh"];
    if (lastMenuh != null && lastMenuh != submenuh) hideAllh();
/*posicoes do submenu*/
    submenuh.left = document.layers[idMainMenuh].pageX;
    submenuh.top  = document.layers[idMainMenuh].pageY + document.layers[idMainMenuh].clip.height;
    submenuh.visibility = fShow;

/*campo onde mouse pode se movimentar sem desaparecer o menu*/
    leftXh  = document.layers[idMainMenuh].pageX;
    rightXh = leftXh + document.layers[idMainMenuh+"submenuh"].clip.width;
    leftYh  = document.layers[idMainMenuh].pageY;
    rightYh = leftYh + document.layers[idMainMenuh].clip.height + document.layers[idMainMenuh+"submenuh"].clip.height;
    
  } 
  if (ie) 
  {
    menuh = eval(idMainMenuh);
    submenuh = eval(idMainMenuh+"submenuh.style");
    
/*posicoes do submenu*/
    submenuh.left = calculateSumOffset(menuh, 'offsetLeft');
    submenuh.top = calculateSumOffset(menuh, 'offsetTop') + document.all[idMainMenuh].offsetHeight;
    submenuh.visibility = fShow;
    if (lastMenuh != null && lastMenuh != submenuh) hideAllh();

/*campo onde mouse pode se movimentar sem desaparecer o menu*/
    leftXh  = calculateSumOffset(menuh, 'offsetLeft');
    rightXh = leftXh + document.all[idMainMenuh+"submenuh"].offsetWidth;
    leftYh  = calculateSumOffset(menuh, 'offsetTop') - document.body.scrollTop;
    rightYh = leftYh + document.all[idMainMenuh].offsetHeight + document.all[idMainMenuh+"submenuh"].offsetHeight;    
  }
  if (n6)
  {
    menuh = document.getElementById(idMainMenuh);
    submenuh = document.getElementById(idMainMenuh+"submenuh").style;
/*posições do submenu*/
    submenuh.left = calculateSumOffseth(menuh, 'offsetLeft');   
/*Posição do menu de acordo com cada versão*/
    submenuh.top = calculateSumOffseth(menuh, 'offsetTop') + parseInt(document.getElementById(idMainMenuh).offsetHeight);
    submenuh.visibility = fShow;
    if (lastMenuh != null && lastMenuh != submenuh) hideAllh();
     
/*campo onde mouse pode se movimentar sem desaparecer o menu*/
    leftXh  = calculateSumOffseth(menuh, 'offsetLeft');
    rightXh = leftXh + parseInt(document.getElementById(idMainMenuh+"submenuh").offsetWidth);
    leftYh  = calculateSumOffseth(menuh, 'offsetTop') - document.body.scrollTop;
//    leftYh  = parseInt(document.getElementById(idMainMenuh+"submenuh").style.top) - document.body.scrollTop;    
    rightYh = leftYh + parseInt(document.getElementById(idMainMenuh).offsetHeight) + parseInt(document.getElementById(idMainMenuh+"submenuh").offsetHeight);     

    
    
  }
  lastMenuh = submenuh;
}

/*calcula a posicao do submenu em internet explorer*/
function calculateSumOffseth(idItemh, offsetNameh)
{
	var totalOffseth = 0;
	var itemh = eval('idItemh');
	do
	{
		totalOffseth += eval('itemh.'+offsetNameh);
		itemh = eval('itemh.offsetParent');
	} while (itemh != null);
	return totalOffseth;
}

/*funcao que desaparece com o menu*/
function hideAllh()
{
  if (lastMenuh != null) 
  {
    lastMenuh.visibility = fHide;
    lastMenuh.left = 0;
  }
}

/////////////////////////////////////////
// Fim das Funções de Menu Horizontal  //
/////////////////////////////////////////
