var t=0;
var intervalo;
var posSubmenuA = 1088;
var posSubmenuB = 1088;
var btn;
//---Control sobre el Menu Principal
function submenuOn(n){//Entro en el menu
	document.getElementById("1").style.background = "none";//Quito el fondo de color primero
	document.getElementById("2").style.background = "none";//Quito el fondo de color primero
	btn = n;//Seleccion del boton
	document.getElementById(btn).style.background = "#FFCC00";//Pongo el boton del menu en el mismo color que el submenu
	//document.getElementById(btn).style.backgroundImage="url('./img/submenu"+n+"_Btn.png')"; //Pongo el boton del menu en el mismo color que el submenu con una img
	clearInterval(intervalo);//Paro el intervalo al volver a entrar
	t=0;//Vuelvo a poner el conteo a 0
	document.getElementById('submenuA').style.top = (-1000)+"px";//Vuelvo a ocultar el submenu
	document.getElementById('submenuB').style.top = (-1000)+"px";//Vuelvo a ocultar el submenu
	switch(n){
	case 1:
	document.getElementById('submenuA').style.top = posSubmenuA+"px";//Muestro submenu
	break;
	case 2:
	document.getElementById('submenuB').style.top = posSubmenuB+"px";//Muestro submenu
	break;
	}
}
function submenuOff(){//Salgo del menu y empiezo conteo para cerrar
	intervalo = setInterval("cierreAuto()",100);
	
}
function cierreAuto(){//Conteo hasta cierre de submenus
	t++;
	if(t>=1){
		clearInterval(intervalo);//Paro el intervalo al volver a entrar
		document.getElementById('submenuA').style.top = (-1000)+"px";//Oculto el submenu
		document.getElementById('submenuB').style.top = (-1000)+"px";//Oculto el submenu
		document.getElementById(btn).style.background = "none";//Quito el fondo de color del boton del menu
	}	
}
//---Fin Control sobre el Menu Principal
//-----Botones Submenu
document.getElementById('submenuA').onmouseover = function(){
	clearInterval(intervalo);//Paro el intervalo al volver a entrar
	document.getElementById('submenuA').style.top = posSubmenuA+"px";
};
document.getElementById('submenuA').onmouseout = function(){
	//document.getElementById('submenuA').style.top = (-1000)+"px";
	intervalo = setInterval("cierreAuto()",100);
};
document.getElementById('submenuB').onmouseover = function(){
	clearInterval(intervalo);//Paro el intervalo al volver a entrar
	document.getElementById('submenuB').style.top = posSubmenuB+"px";
};
document.getElementById('submenuB').onmouseout = function(){
	//document.getElementById('submenuB').style.top = (-1000)+"px";
	intervalo = setInterval("cierreAuto()",100);
};
//-----Fin Botones Submenu