// JavaScript Document

function initArray() {
    this.length = initArray.arguments.length;
    for (var i = 0; i < this.length; i++)
        this[i] = initArray.arguments[i];
}
   
function from10toradix(value,radix){
    var retval = '';
    var ConvArray = new initArray(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F');
    var intnum;
    var tmpnum;
    var i = 0;

    intnum = parseInt(value,10);
    if (isNaN(intnum)){
        retval = 'NaN';
    }else{
        while (intnum > 0.9){
            i++;
            tmpnum = intnum;
           retval = ConvArray[tmpnum % radix] + retval;  
            intnum = Math.floor(tmpnum / radix);
            if (i > 100){
                retval = 'NaN';
                break;
            }
        }
    }
    return retval;
}

var colores = new Array(8);
var menu_trans1=new Array(300);
var menu_trans2=new Array(300);
var menu_elem1=new Array(300);
var n_seg=0; n_pila1=0; i_actual1=0;n_inter=50;
var n_pila2=0; i_actual2=0;

function Menu_Trans1(elem,color2)
{
 //color1= document.getElementById(elem).style.backgroundColor;
 //alert(color1);
 color1="#2B5511"; 
 color1=color1.substr(1);
 color2=color2.substr(1);
 color1=color1.toUpperCase();
 color2=color2.toUpperCase();
 color1R=parseInt(color1.substr(0,2),16);
 color1G=parseInt(color1.substr(2,2),16);
 color1B=parseInt(color1.substr(4,2),16);

 color2R=parseInt(color2.substr(0,2),16);
 color2G=parseInt(color2.substr(2,2),16);
 color2B=parseInt(color2.substr(4,2),16);

 rangoR=(Math.round((color2R - color1R)/8));
 rangoG=(Math.round((color2G - color1G)/8));
 rangoB=(Math.round((color2B - color1B)/8));

 menu_elem1[n_pila1]=elem;
 menu_trans1[n_pila1++]="document.getElementById('" + elem + "').style.backgroundColor='#" + color1 + "'";
 menu_trans2[n_pila2+7]="document.getElementById('" + elem + "').style.backgroundColor='#" + color1 + "'";
 for (a=2;a<8;a++)
 {
  colores1='#' + from10toradix(color1R+(rangoR*(a-1)),16) + from10toradix(color1G+(rangoG*(a-1)),16)+from10toradix(color1B+(rangoB*(a-1)),16);
  menu_elem1[n_pila1]=elem;
  menu_trans1[n_pila1++]="document.getElementById('" + elem + "').style.backgroundColor='" + colores1 + "'";
  menu_trans2[n_pila2+8-a]="document.getElementById('" + elem + "').style.backgroundColor='" + colores1 + "'";
 }
 menu_elem1[n_pila1]=elem;
 menu_trans1[n_pila1++]="document.getElementById('" + elem + "').style.backgroundColor='#" + color2 + "'";
 menu_trans2[n_pila2]="document.getElementById('" + elem + "').style.backgroundColor='#" + color2 + "'";
 n_pila2+=8;
}

function Menu_Cambia(elem,color2)
{
 Menu_Trans1(elem,color2);
 /*
 if ((n_pila-i_actual)>8)  { n_inter=50; } 
 if ((n_pila-i_actual)>8 && (n_pila-i_actual)<16) { n_inter=25; } 
 if ((n_pila-i_actual)>16) { n_inter=8; } 
*/
//Menu_Aplica(elem,color2,1);
}

function reloj_menu_on()
{
 if (i_actual1<n_pila1) 
 	  { eval(menu_trans1[i_actual1] ); 
	    if ( (n_pila1-i_actual1)>16) { i_actual1+=2; }
		i_actual1++; 
	  }	 
}
function reloj_menu_off()
{
 if ((i_actual1-i_actual2)>=8)	 
 {
  // if ( menu_elem1[i_actual1]!=menu_elem1[i_actual2] )
	eval(menu_trans2[i_actual2] ); 
	i_actual2++;
	
  }
}
//setInterval("reloj_menu_on()",25);
//setInterval("reloj_menu_off()",30);


function Menu_Cambia_Out(elem,color2)
{

}

function Menu_borra(c,actual) {
	var a;
   for (a=1;a<=c;a++)
	{
	   if (document.getElementById("DC"+a)!=null)	
	    {
		this.ca=document.getElementById("DC"+a);
		ca.className  = "C1Oculto";
		}
	   if (document.getElementById("aDC"+a)!=null)	
	    {
		if (a!=actual) 	 { document.getElementById("aDC"+a).className='menu_n1'; }
		}
	}

}
function Menu_borra2(c,actual) {
	var a;
   for (a=1;a<=c;a++)
	{
	  if (document.getElementById("DS"+a)!=null)	
	   {
		this.ca=document.getElementById("DS"+a);
		ca.className  = "C2Oculto";
	   }
	   if (document.getElementById("aDS"+a)!=null)	
	    {
		if (a!=actual) { document.getElementById("aDS"+a).className='menu_n2'; }
		}
	}
}

function Menu_borra3(actual) {
	var a;
   for (a=1;a<=50;a++)
	{
	   if (document.getElementById("aDT"+a)!=null)	
	    {
		if (a!=actual) { document.getElementById("aDT"+a).className='menu_n3'; }
		}
	}
}

var m_activo1='';
var m_activo2='';
var m_activo3='';

var m_activoi1=0;
var m_activoi2=0;
var m_activoi3=0;

function Menu(id_Div,nombre, c,st,actual) {
	if (nombre=="C1") {	 Menu_borra(c,actual);	 Menu_borra2(st,actual); m_activo1=id_Div; }
	else { Menu_borra2(st,actual);  m_activo2=id_Div; }
	m_activoi1=0; m_activoi2=0; m_activoi3=0; 
   if(id_Div.className == nombre + "Oculto") {
		id_Div.className = nombre + "Visible";
	} else {
		id_Div.className = nombre + "Oculto";
	}
}

function menu_out1(id_Div,obj_a) {
	if (id_Div!=m_activo1) { obj_a.className='menu_n1'; }

}
function menu_out2(id_Div,obj_a) {
	if (id_Div!=m_activo2) { obj_a.className='menu_n2'; }
}
function menu_out3(id_Div,obj_a) {
	if (id_Div!=m_activo3) { obj_a.className='menu_n3'; }
}

function menu_activar1(c,st,actual) {
    Menu_borra(c,actual);
	Menu_borra2(st,actual); 
	m_activoi1=actual;
    m_activo1='';
}
function menu_activar2(st,actual) {
    //Menu_borra(c,actual);
    Menu_borra2(st,actual); 	
	m_activoi2=actual;
	m_activo2='';
}
function menu_activar3(actual) {
    Menu_borra3(actual); 
	m_activoi3=actual;
	m_activo3='';
}

function menu_outi1(obj_a,actual) {
  if (m_activoi1!=actual) {  obj_a.className='menu_n1'; }
}
function menu_outi2(obj_a,actual) {
  if ( m_activoi2!=actual) { obj_a.className='menu_n2'; }
}
function menu_outi3(obj_a,actual) {
  if ( m_activoi3!=actual) { obj_a.className='menu_n3'; }
}


