function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();

var botaoAtivo = null;

var divFrame = null;

var auxId=0;

function clicaBotao(event, menuId) {

  /* verificando a árvore de diretórios */
  if(menuId.childNodes.length >1){
  
   if(browser.isIE){
        menuId = menuId.childNodes[1].getAttribute("id");
   }else{    
        menuId= menuId.childNodes[3].getAttribute("id"); // funciona firefox, chrome, safari, ie7, opera menos no ie6
        }
  }
  auxId=menuId;
    
 
    
 /* fim  */   
    
  //botao.menu = menuId.childNodes[1];   
if(menuId>0){// se nao for um menu

  var botao;

  if (browser.isIE)
    botao = window.event.srcElement;
  else
    botao = event.currentTarget;

  if (botao.menu == null) {
    botao.menu = document.getElementById(menuId);
  }
  
  if (botaoAtivo != null)
    fechaMenu(botaoAtivo);

  if (botao != botaoAtivo) {
    abreMenu(botao);
    botaoAtivo = botao;
  } else {
    botaoAtivo = null;
  }
}  
  
  return false;

}

function abreMenu(botao) {

  botao.menu.style.zIndex = 4

  if (browser.isIE) {
  
        frameM = document.getElementById("iFrameMenu"+auxId);
    
    frameM.style.zIndex = (botao.menu.style.zIndex-1);
    
    frameM.style.visibility = "visible";
  }
  

  botao.className += " menuButtonActive";

  botao.menu.style.visibility = "visible";
}

function fechaMenu(botao) {

  botao.className = "menuButton";

  if (botao.menu != null) {

    if (browser.isIE) {

        frameM = document.getElementById("iFrameMenu"+auxId);
		
        frameM.style.visibility = "hidden";
      }

    botao.menu.style.visibility = "hidden";
  }
}


function getPageOffsetLeft(el) {

  var x;

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}
