 total = 5;
 total++;
 
 marcado = 0;
 submarcado = 0;
 ativo = 0;
 subativo = 0;

 qtdsub = new Array(total);
 totsub = new Array(total);

 qtdsub[1] = 8;
 qtdsub[2] = 2;
 qtdsub[3] = 0;
 qtdsub[4] = 3;
 qtdsub[5] = 0;

 totsub[1] = 0;
 totsub[2] = 8;
 totsub[3] = 10;
 totsub[4] = 10;
 totsub[5] = 13;

 totalsub = 12+1;
 
 mon = new Array(total);
 moff = new Array(total); 

 for (i=1; i < total; i++) {
   mon[i] = new Image();
   mon[i].src = "imageng/menu/mo_"+i+".GIF";
   moff[i] = new Image();
   moff[i].src = "imageng/menu/m_"+i+".GIF";
 }

 subon = new Array(totalsub);
 suboff = new Array(totalsub); 

 for (i=1; i<=4; i++) {
    base = totsub[i] + 1;
    conta = 1;
    for (j=base; j<=totsub[i+1]; j++) {
        
       subon[j] = new Image();
       subon[j].src = "imageng/menu/so_"+i+conta+".GIF";
       suboff[j] = new Image();
       suboff[j].src = "imageng/menu/s_"+i+conta+".GIF";
       conta = conta + 1;
    }
 }


 function c(quem,qual) {
   marcado = quem;
   submarcado = 0;
 }

 function sc(quem, qual) {
   marcado = quem;
   submarcado = qual;
 }
 
 function sm(quem, qual) {
  if (submarcado != 0) {
     posicao = totsub[marcado] + submarcado + marcado;
     indice = totsub[marcado] + submarcado;
     document.images[posicao].src = suboff[indice].src;
  }
  posicao = totsub[quem] + qual + quem;
  indice = totsub[quem] + qual;
  subativo = indice;
  document.images[posicao].src = subon[indice].src;
 }
 
 function sd(quem, qual) {
  if (submarcado != 0) {
     posicao = totsub[marcado] + submarcado + marcado;
     indice = totsub[marcado] + submarcado;
     document.images[posicao].src = subon[indice].src;
  }
  posicao = totsub[quem] + qual + quem;
  indice = totsub[quem] + qual;
  document.images[posicao].src = suboff[indice].src;
  subativo = 0;
 }

 function m(quem) {
   fecha();
   ativo = quem;
   if (marcado != 0) {
      document.images[totsub[marcado]+marcado].src = moff[marcado].src;
	  if (marcado == 1) {
	     for (j=1; j<=2; j++) {
            objeto = document.getElementById("submenu"+marcado+""+j);
            objeto.style.enabled = false;
            objeto.style.visibility = "hidden";
		 }
	  }	 
	  else {
         objeto = document.getElementById("submenu"+marcado);
         objeto.style.enabled = false;
         objeto.style.visibility = "hidden";
	  }
   }
   posicao = quem + totsub[quem];
   document.images[posicao].src = mon[quem].src;
   if (quem == 1) {
     for (j=1; j<=2; j++) {
        objeto = document.getElementById("submenu"+quem+""+j);
        objeto.style.enabled = true;
        objeto.style.visibility = "visible";
     }
   }
   else {
      objeto = document.getElementById("submenu"+quem);
      objeto.style.enabled = true;
      objeto.style.visibility = "visible";
   }
}

 function fechatudo() { 
   ativo = 0;
   subativo = 0;
   marcado = 0;
   submarcado = 0;
   marcado = 0;
   submarcado = 0;
   for (i = 1; i< total; i++) {
     posicao = totsub[i] + i;
     document.images[posicao].src = moff[i].src;
     objeto = document.getElementById("submenu"+i);
     objeto.style.enabled = false;
     objeto.style.visibility = "hidden";
  }   
 }
 
 function fecha() { 
   if (ativo != 0) {
      posicao = totsub[ativo] + ativo;
      document.images[posicao].src = moff[ativo].src;
      if (ativo == 1) {
	     for (j=1; j<=2; j++) {
             objeto = document.getElementById("submenu"+ativo+""+j);
             objeto.style.enabled = false;
             objeto.style.visibility = "hidden";
		 }
	 }
     else {
        objeto = document.getElementById("submenu"+ativo);
        objeto.style.enabled = false;
        objeto.style.visibility = "hidden";
	 }
     ativo = 0;
  }   
  if (marcado != 0) {
     posicao = totsub[marcado] + marcado;
     document.images[posicao].src = mon[marcado].src;
     if (marcado == 1) {
	    for (j=1; j<=2; j++) {
           objeto = document.getElementById("submenu"+marcado+""+j);
           objeto.style.enabled = true;
           objeto.style.visibility = "visible";
		}
	 }
     else {	 
        objeto = document.getElementById("submenu"+marcado);
        objeto.style.enabled = true;
        objeto.style.visibility = "visible";
	 }	
  }
  if (submarcado != 0) {
     posicao = totsub[marcado] + submarcado + marcado;
     indice =  totsub[marcado] + submarcado;
     document.images[posicao].src = subon[indice].src;
  }
}

function d(quem) {
}

function acende() {
 if (marcado != 0) {
    ativo = marcado;
    posicao = marcado + totsub[marcado];
    document.images[posicao].src = mon[marcado].src;
     if (marcado == 1) {
	    for (j=1; j<=2; j++) {
           objeto = document.getElementById("submenu"+marcado+""+j);
           objeto.style.enabled = true;
           objeto.style.visibility = "visible";
		}
	 }
     else {	 
        objeto = document.getElementById("submenu"+marcado);
        objeto.style.enabled = true;
        objeto.style.visibility = "visible";
	 }	
    objeto.style.enabled = true;
    objeto.style.visibility = "visible";
 }
 if (submarcado != 0) {
    subativo = submarcado;
    posicao = totsub[marcado] + submarcado + marcado;
    indice =  totsub[marcado] + submarcado;
    document.images[posicao].src = subon[indice].src;
  }
}

//////////////////////////////////////

var initialised; 

var speed=50 
 
var loop, timer 
 
function criaobjeto(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el = document.getElementById(obj); 
    this.css = document.getElementById(obj).style; 
    this.scrollHeight = this.el.offsetHeight;
    this.clipHeight = this.el.offsetHeight;
    this.cima = sobe;
    this.baixo = desce; 
    this.mover = mover; 
    this.x; 
    this.y; 
    this.obj = obj + "Object"; 
    eval(this.obj + "=this");
    return this;
} 

function mover(x,y){ 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
} 
 
function desce(move){ 
  if (this.y > - this.scrollHeight + defora.clipHeight){ 
     this.mover(0, this.y - move) 
     if (loop) 
        setTimeout(this.obj+".baixo("+move+")",speed) 
  } 
} 
function sobe(move){ 
  if (this.y < 0){ 
     this.mover(0, this.y - move) 
     if (loop) 
        setTimeout(this.obj+".cima("+move+")",speed) 
  } 
} 
 
function r(speed) { 
  if (initialised) { 
     loop = true; 
     if (speed > 0) 
        dedentro.baixo(speed) 
     else 
        dedentro.cima(speed) 
  } 
} 
 
function p() { 
  loop = false;
  if (timer) 
     clearTimeout(timer);
} 

function iniciatexto(){ 
    defora = new criaobjeto('tipofora');
    dedentro = new criaobjeto('tipomain','tipofora');
    dedentro.mover(0,0);
    defora.css.visibility = 'visible';
//    alert(defora.clipHeight);
//    alert(dedentro.clipHeight);
    if (defora.clipHeight < dedentro.clipHeight) {
       s1 = document.getElementById("seta1");
       s1.style.visibility = "visible";
       s1.style.enabled = true;
       s1 = document.getElementById("seta2");
       s1.style.visibility = "visible";
       s1.style.enabled = true;
       initialised = true; 
    }
} 

legativo = 0;

function legenda(){ 
  obj = document.getElementById("flegabre");
  obj.style.visibility = "hidden";
  obj.style.enabled = false;
  obj = document.getElementById("fleg");
  obj.style.visibility = "visible";
  obj.style.enabled = true;
  obj = document.getElementById("flegtex");
  obj.style.visibility = "visible";
  obj.style.enabled = true;
  legativo = 1;
}

function noleg(){ 
  
  obj = document.getElementById("flegtex");
  obj.style.visibility = "hidden";
  obj.style.enabled = false;
  obj = document.getElementById("fleg");
  obj.style.visibility = "hidden";
  obj.style.enabled = false;
  obj = document.getElementById("flegabre");
  obj.style.visibility = "visible";
  obj.style.enabled = true;
} 


