
// variables globales aquí
var PulldownVisible="";
var HidePDiv;
var MAXSUBMENU=10;
var MAXMENU=11;
var MenuY="136px";
var FavBack="#9999FF";
var SubMenuInk="#000000";

//var ActvMenuBack="#0000CD"; 
var ActvMenuBack="#9933FF"; 
var	ActvMenuColor="yellow";
var	MenuInk="#FFFFFF"; //tinta de menús en modo inactivo
var	MenuBack="#000005"; //fondo de menus en modo inactivo


var VisSubMi="#000000"; //color submenus visitados
var SubMenuBack = new Array();
var SubMenuColor = new Array();

/*
for (var i =0; i<MAXSUBMENU; i++){
	SubMenuBack[i]=FavBack;
	SubMenuColor[i]="#FFFFFF";
}

for (var i =1; i<MAXSUBMENU; i+=2){
	SubMenuBack[i]=FavBack;
	SubMenuColor[i]="white";
}
*/
//document.getElementById
//--------------------------------------------------------------------------------------------------
function InitMenus(){
	InitMenusNS();
}
//--------------------------------------------------------------------------------------------------
function InitMenusIE(){
//Despues de cargar página o dará casque al noexistir aun las tablas de los submenus
	//Inicializa Menus
	//border=1 bordercolor="#000000" rules="none"
	alert("Entrado en initMenus");
	for (var j=1;j<MAXMENU;j++){			
	    strSubMenuName = "SubMenu" + j;
		alert("Submenu:"+strSubMenuName);
		if (document.getElementById(strSubMenuName) !=null)	{ //Si existe el menu y es accesible
			//podría no existir si no está cargado correctamente
		   document.getElementById(strSubMenuName).style.background=FavBack; //fondo de los menus
		   //document.getElementById(strSubMenuName).style.background=SubMenuBack[j]; //fondo de los menus
		   //document.getElementById(strSubMenuName).style.color=SubMenuColor[j]; //texto de los menus
		   document.getElementById(strSubMenuName).style.color="#000000"; //texto de los menus
		   document.getElementById(strSubMenuName).style.fontWeight="bold"; //bold //normal
		   document.getElementById(strSubMenuName).style.fontSize="9pt";
		   document.getElementById(strSubMenuName).style.fontFamily="arial";
		   document.getElementById(strSubMenuName).style.cursor="hand";
	//VERTICAL-ALIGN: top;		   
		   //document.getElementById(strSubMenuName).style.vertical-align="top";


			//config de las tablas
		   document.getElementById(strSubMenuName).width=1
		//Borde de submenus=0 = sin borde
				//1 = recuadro fino docble
	
		   document.getElementById(strSubMenuName).border=1; // activamos el borde
		   document.getElementById(strSubMenuName).borderColor="#000000"; //color del borde de cada menu negro
		   document.getElementById(strSubMenuName).rules="none"; //no mostrar las rayas internas de las cells
			//***Ahora los que nos dan problemas:
			/*
			// cellSpacing=0 cellPadding=0 width=0 border=0
		   document.getElementById(strSubMenuName).cellSpacing=0;
		   document.getElementById(strSubMenuName).cellPadding=0;
		   document.getElementById(strSubMenuName).width=0;
		   document.getElementById(strSubMenuName).border=0;
		   */
		   
		   //ponemos la altura a la que deben estar
		   document.getElementById(strSubMenuName).style.top=MenuY; //posición vertical de los submenus
			//Inicialmente todos los menus layers ocultos:
			//
		   //document.getElementById(strSubMenuName).style.overflow="hidden"; //oculto
		//   document.getElementById(strSubMenuName).style.DISPLAY="none"; //NO FUNCIONA porque Property es con minúscula
		   document.getElementById(strSubMenuName).style.display="none"; //oculto

		}//if document.all
	} //for
}
//--------------------------------------------------------------------------------------------------
function InitMenusNS(){
//Despues de cargar página o dará casque al noexistir aun las tablas de los submenus
	//Inicializa Menus
	//border=1 bordercolor="#000000" rules="none"
	//alert("Entrado en initMenus");
	for (var j=1;j<MAXMENU;j++){			
	    strSubMenuName = "SubMenu" + j;
		//alert("Submenu:"+strSubMenuName);
		if (document.getElementById(strSubMenuName) !=null)	{ //Si existe el menu y es accesible
			//podría no existir si no está cargado correctamente
		   document.getElementById(strSubMenuName).style.background=FavBack; //fondo de los menus
		   //document.getElementById(strSubMenuName).style.background=SubMenuBack[j]; //fondo de los menus
		   //document.getElementById(strSubMenuName).style.color=SubMenuColor[j]; //texto de los menus
		   document.getElementById(strSubMenuName).style.color="#000000"; //texto de los menus
		   document.getElementById(strSubMenuName).style.fontWeight="bold"; //bold //normal
		   document.getElementById(strSubMenuName).style.fontSize="9pt";
		   document.getElementById(strSubMenuName).style.fontFamily="arial";
		   document.getElementById(strSubMenuName).style.cursor="hand";
	//VERTICAL-ALIGN: top;		   
		   //document.getElementById(strSubMenuName).style.vertical-align="top";


			//config de las tablas
		   document.getElementById(strSubMenuName).width=1
		//Borde de submenus=0 = sin borde
				//1 = recuadro fino docble
	
		   document.getElementById(strSubMenuName).border=1; // activamos el borde
		   document.getElementById(strSubMenuName).borderColor="#000000"; //color del borde de cada menu negro
		   document.getElementById(strSubMenuName).rules="none"; //no mostrar las rayas internas de las cells
			//***Ahora los que nos dan problemas:
			/*
			// cellSpacing=0 cellPadding=0 width=0 border=0
		   document.getElementById(strSubMenuName).cellSpacing=0;
		   document.getElementById(strSubMenuName).cellPadding=0;
		   document.getElementById(strSubMenuName).width=0;
		   document.getElementById(strSubMenuName).border=0;
		   */
		   
		   //ponemos la altura a la que deben estar
		   document.getElementById(strSubMenuName).style.top=MenuY; //posición vertical de los submenus
			//Inicialmente todos los menus layers ocultos:
			//
		   //document.getElementById(strSubMenuName).style.overflow="hidden"; //oculto
		//   document.getElementById(strSubMenuName).style.DISPLAY="none"; //NO FUNCIONA porque Property es con minúscula
		   document.getElementById(strSubMenuName).style.display="none"; //oculto

		}//if document.all
	} //for
}
//--------------------------------------------------------------------------------------------------
function HideAllCombo(){
	if (document.getElementsByTagName("SELECT")!=null) {
		var coll = document.getElementsByTagName("SELECT");
		var nComboMax;
		if (coll.length > 12)
			nComboMax = 12;
		 else
			nComboMax =coll.length;
		
		for (var k =1; k< nComboMax;k++){
			coll[k].style.visibility="hidden";
		} //for
	} //if
}
//--------------------------------------------------------------------------------------------------
function ShowAllCombo() {
	if (document.getElementsByTagName("SELECT")!=null) {
		var coll = document.getElementsByTagName("SELECT");
		//alert ("testShow All combo");
		for (var k =0; k< coll.length;k++){
			coll[k].style.visibility="visible";
		}
	}
}
//--------------------------------------------------------------------------------------------------
function RestoreMenu(){
	//if (typeof PulldownVisible !="undefined" && navigator.appName=="Microsoft Internet Explorer" && parseInt(navigator.appVersion) >=4 ){
//	if (typeof PulldownVisible !="undefined"){
		if (PulldownVisible !=""){
			if (document.getElementById(PulldownVisible)!=null)
				document.getElementById(PulldownVisible).style.display="none"
			if (document.getElementById("TypeSearch") !=null)
				ShowAllCombo();
			PulldownVisible="";
			
			var strMenuName ;
			for (var j=1;j<=MAXMENU;++j){			
				strMenuName = "MenuItem" + j;
				if (document.getElementById(strMenuName) !=null){
					document.getElementById(strMenuName).style.background=MenuBack;
					document.getElementById(strMenuName).style.color=MenuInk; //Pone color normal de ink de menu
				} // if !=null
			}//for
		}
//	}
	
}
//--------------------------------------------------------------------------------------------------
function OpenWin(strOpenWin){
	if (strOpenWin !=""){
		document.location = strOpenWin;
		}
}
//--------------------------------------------------------------------------------------------------
function ShowDiv(strMenuId){
	if (PulldownVisible!="" && PulldownVisible != strMenuId ){
		document.getElementById(PulldownVisible).style.display="none"; //oculta antiguo
		if (document.getElementById("PowerNav")!=null)
			document.getElementById("PowerNav").style.display="none";
		document.getElementById(strMenuId).style.display=""; //muestra actual
	}
	//if (PulldownVisible=="" && PulldownVisible!="SubMenu1"){
	if (PulldownVisible=="" ){
		if (document.getElementById("PowerNav")!=null)
			document.getElementById("PowerNav").style.display="none";
		document.getElementById(strMenuId).style.display="";
	}
	PulldownVisible=strMenuId; //marca cual es el submenu extendido
	
		
	if (window.event){
		window.event.cancelBubble = true;
		}
}
//--------------------------------------------------------------------------------------------------
function HideDiv(strMenuId){
	document.getElementById(strMenuId).style.display="none";
	PulldownVisible="";
}
//--------------------------------------------------------------------------------------------------
//Pone el color de la barra de menu superior
function SetDefaultColor(){
	var strMenuName="MenuItem";
	for( var j=1;j<=10;j++){
		strMenuName = "MenuItem" +  j;
		if (document.getElementById(strMenuName)!=null) {
			document.getElementById(strMenuName).style.background="black"
	//		document.getElementById(strMenuName).style.color="white"
			document.getElementById(strMenuName).style.color="yellow"
		}
	}
}
//--------------------------------------------------------------------------------------------------
function ShowDivNSwitchColor(strDiv){
	//antes invocada como:
	// onmouseover="ShowDivNSwitchColor('SubMenu2|MenuItem2|FFFFCC|black')" 

    //ahora invocada como:
	// onmouseover="ShowDivNSwitchColor('SubMenu2|2|FFFFCC|black')" 
	
	var temparr = new Array();
	temparr=strDiv.split("|");
	
	if (PulldownVisible == temparr[0]){
		if (window.event){
			window.event.cancelBubble = true;
			return;
		}
	}
	SetDefaultColor()
	ShowDiv (temparr[0]);
	
    if(parseInt(temparr[0].charAt(7))>=4 || temparr[0] == "SubMenu10")
		 HideAllCombo();
	
	if(temparr[0]=="SubMenu2" ||  temparr[0]=="SubMenu1" ){
	  if (document.getElementById("TypeSearch") !=null) {
		  //alert(document.getElementById("TypeSearch"));
		  document.getElementById("TypeSearch").style.visibility="hidden";
	  }
	}
	//SubMenuPaper[i]="blue";
	//SubMenuInk[i]="white";
	//temparr[1] contiene el num de MenuItem
    var strMenuName="MenuItem";
	var strMenu="";
	
	//
	//document.print(strMenuName);
			
	strMenu= temparr[1];
	strMenuName = "MenuItem" + strMenu;	
	//strMenuName contiene el nombre del menu principal (no de los submenus)
	
	 //window.alert("strMenuName:\n"+strMenuName); //alerts for debug
	
	if (document.getElementById(strMenuName)!=null) {
		document.getElementById(strMenuName).style.background=ActvMenuBack; 
		document.getElementById(strMenuName).style.color=ActvMenuColor;
		document.getElementById(strMenuName).style.border=0;
	}
		
}
//--------------------------------------------------------------------------------------------------
function ShowBackColor(strDiv){
	if (document.getElementById(strDiv)!=null) {
		document.getElementById(strDiv).style.backgroundColor="black" 
		document.getElementById(strDiv).style.color="white"
	}
	window.event.cancelBubble = true;
}
//--------------------------------------------------------------------------------------------------
function ColorRes(strDiv){
//devuelve el color a un submenu al abandonar su posición (el mouse)
// ahora : onmouseout="ColorRes('MenuItem810|009999|FFFFFF')" width=0><IMG 

	var temparr = new Array();
	temparr=strDiv.split("|");
	//document.getElementById(temparr[0]).style.background=temparr[1];
	//document.getElementById(temparr[0]).style.color=temparr[2];
	if (document.getElementById(temparr[0])!=null) {
		document.getElementById(temparr[0]).style.background=FavBack; //ponemos color de fondo favorito
		document.getElementById(temparr[0]).style.color=SubMenuInk; //Tinta de cada submenu
	}
	window.event.cancelBubble = true;
}
//--------------------------------------------------------------------------------------------------
function SetVar() {
	HidePDiv = "False";
	window.event.cancelBubble = true;
}
