var alt_cerrado = "Haz click aqui para mostrar las opciones";
var alt_abierto = "Haz click aqui para ocultar las opciones";


/* ==================================================================
		CAMBIO DE NOMBRE DE LOS BOTONES
=====================================================================*/
var etiquetas = new Array();
etiquetas[1] = "/frances/imagenes/botones/inicio";
etiquetas[2] = "/frances/imagenes/botones/empresas";
etiquetas[3] = "/frances/imagenes/botones/servicios";
etiquetas[4] = "/frances/imagenes/botones/nuestros_servicios";
etiquetas[5] = "/frances/imagenes/botones/destacados";

var botones_abiertos = new Array();
botones_abiertos[0]="/imagenes/botones/boton_menosazul";
botones_abiertos[1]="/imagenes/botones/boton_menosverde";

var botones_cerrados = new Array();
botones_cerrados[0]= "/imagenes/botones/boton_masazul";
botones_cerrados[1]= "/imagenes/botones/boton_masverde";

var vError_imagen;
vError_imagen = 0;

function menu_init(arrDesplegables) {

	var i;
	var ValCooky;
	var bIzda;
	
	for (i=1;i<=4;i++) { //el 4 es el número de menús que hay
		if(i%2!=0)
			bIzda = 1;
		else
			bIzda = 0;
		ValCooky=GetCookie("menu" + i);
		//alert("Valor de la cookie " + i + ": " + ValCooky);
		if (ValCooky=="abierto") {
			var oContent = document.all.item("frame" + i);
			var oBoton = document.all.item("boton" + i);
			//var oEtiqueta = document.all.item("etiqueta" + i);
			if(oContent) { //si no existe el frame de fallo (opción de que sea un desplegable o no)
				oContent.style.display = "";
				oBoton.src = botones_abiertos[bIzda] + ".gif";
				oBoton.alt = alt_abierto;
			}
		} else {
//			alert(i-1 + '=' + arrDesplegables[i-1] + " valor de la cookie " + i + ": " + ValCooky);
			if (arrDesplegables[i-1]=='True' && ValCooky == null) {  //se despliegan los menús que le mando en el array (ASP)
				var oContent = document.all.item("frame" + i);
				var oBoton = document.all.item("boton" + i);
				//var oEtiqueta = document.all.item("etiqueta" + i);			
				if(oContent) { //si no existe el frame da fallo (opción de que sea un desplegable o no)
					oContent.style.display = "";
					oBoton.src = botones_abiertos[bIzda] + ".gif";
					oBoton.alt = alt_abierto;
				}
			}						
		}
	}
}

function mostrar_menu(id,codigo) {
	var oContent = document.all.item("frame" + id);
	var oBoton = document.all.item("boton" + id);	
	var oEtiqueta = document.all.item("etiqueta" + id);
	var bOver;
	var bOn;
	var sIzda;
	var bIzda;
	
	sIzda = IzdaDcha(id);

	if(sIzda=="_i")
		bIzda = 1;
	else
		bIzda = 0;
		
	if (event.srcElement)
	{
		bOver = (event.srcElement.src.toLowerCase().indexOf("1.gif") != -1);
		bOn = (oContent.style.display.toLowerCase() == "none");
	}
	
	if(bOver)
			oEtiqueta.src = etiquetas[codigo] + sIzda + "_2.gif";
	else
			oEtiqueta.src = etiquetas[codigo] + sIzda + ".gif";
	if(bOn)
	{
		SetCookie("menu" + id, "abierto")  //actualizar el cookie

		oContent.style.display = "";
		
		if(bOver)	
			oBoton.src = botones_abiertos[bIzda] + "_2.gif";		
		else
			oBoton.src = botones_abiertos[bIzda] + ".gif";		
			
		oBoton.alt = alt_abierto;
	}
	else
	{
		SetCookie("menu" + id, "cerrado")  //actualizar el cookie
		oContent.style.display = "none";
			
		if(bOver)
			oBoton.src = botones_cerrados[bIzda] + "_2.gif";		
		else
			oBoton.src = botones_cerrados[bIzda] + ".gif";		
			
		oBoton.alt = alt_cerrado;
	}
}

function roll_over(id, bOver, codigo) {
	var oContent = document.all.item("frame" + id);
	var oBoton = document.all.item("boton" + id);
	var oEtiqueta = document.all.item("etiqueta" + id);		
	var bIzda;
		
	vError_imagen = 0;
		
	var sIzda;
	
	sIzda = IzdaDcha(id)
	
	if(sIzda=="_i")
		bIzda = 1;
	else
		bIzda = 0;
	
	if(bOver)
	{	
		oEtiqueta.src = etiquetas[codigo] + sIzda + "_2.gif";
		if(oContent.style.display.toLowerCase() == "none") { //cuando no está desplegada
			oBoton.src = botones_cerrados[bIzda] + "_2.gif";		

		} else { //cuando está desplegada
			oBoton.src = botones_abiertos[bIzda] + "_2.gif";			
		}
	} else { //cuando sale del botón
		oEtiqueta.src = etiquetas[codigo] + sIzda + ".gif";
		if(oContent.style.display.toLowerCase() == "none") { //cuando la capa no está desplegada
			oBoton.src = botones_cerrados[bIzda] + ".gif";			
		} else {
			oBoton.src = botones_abiertos[bIzda] + ".gif";		
		}			
	}
}

function IzdaDcha(ID) {
	
	var sIzda;
	
	if (ID%2!=0) 
		sIzda = "_i";
		
	else
		sIzda = "_d";		
	
	return sIzda;
}
