startList = function() {
if (document.all&&document.getElementById) {
	navRoot = document.getElementById("nav");
	for (i=0; i<navRoot.childNodes.length; i++) {
	node = navRoot.childNodes[i];
	if (node.nodeName=="LI") {
		node.onmouseover=function() {
		this.className+=" over";
		}
		node.onmouseout=function() {
		this.className=this.className.replace(" over", "");
		}
	}
}
}
}
window.onload=startList;



function color_productos_on() {
document.getElementById("celdaproductos").style.backgroundColor="#009ee0";
document.getElementById("celdaproductos").style.color="#FFF";
}
function color_productos_off() {
document.getElementById("celdaproductos").style.backgroundColor="#ffffff";
document.getElementById("celdaproductos").style.color="#009ee0";
}
function color_servicios_on() {
document.getElementById("celdaservicios").style.backgroundColor="#009ee0";
document.getElementById("celdaservicios").style.color="#FFF";
}
function color_servicios_off() {
document.getElementById("celdaservicios").style.backgroundColor="#ffffff";
document.getElementById("celdaservicios").style.color="#009ee0";
}
function color_acercade_on() {
document.getElementById("celdaacercade").style.backgroundColor="#009ee0";
document.getElementById("celdaacercade").style.color="#FFF";
}
function color_acercade_off() {
document.getElementById("celdaacercade").style.backgroundColor="#ffffff";
document.getElementById("celdaacercade").style.color="#009ee0";
}

// COOKIE IDIOMA:
// función llamada desde el formulario 
function GuardaValorEnCookie() 
{ 

// jvila, esta parte si lee correctamente el valor del combo
// Leemos el valor del combobox
	var Idioma
	var selIndex = document.formulario.idioma.selectedIndex;
	Idioma = document.formulario.idioma.options[selIndex].value;
	
// borra la cookie anterior
	document.cookie = "idioma=;expires=Thu, 01-Jan-70 00:00:01 GMT"; 

// jvila, este for esta sustituido por las lineas anteriores que si leen correctamente el valor del combo
	// lee el valor pasado en el formulario 
	//for (i=0;i < document.formulario.idioma.length;i++){
	//	var Idioma = document.formulario.idioma[i].value; 
	//}
	
//caducidad; 
	var Caducidad = 3; //expira a los tres meses 
	expireDate = new Date; 
	expireDate.setMonth(expireDate.getMonth() + Caducidad); 
	
//escribe cookie;
	// jvila, hemos añadido el parametro de path=/ para que lo aplique a toda la pagina
	document.cookie="idioma" + "=" + Idioma + ";expires=" + expireDate.toGMTString()+";path=/;"; 
	
// llama a la función que chequea el idioma en la cookie 
	chequeaIdioma(); 
} 

// función que chequea el idioma en la cookie 
function chequeaIdioma(){
		
	var IdiomaCookie;
	IdiomaCookie=get_cookie("idioma");
	// Castellano
	if (IdiomaCookie=="cast") {
		document.location.href = "/index.html";
	}
	// Catala
	if (IdiomaCookie=="cat") {
		document.location.href = "/cat/index.html";
	}
	// Euskera
	if (IdiomaCookie=="eus") {
		document.location.href = "/eus/index.html";
	}
	// Galego
	if (IdiomaCookie=="gal") {
		document.location.href = "/gal/index.html";
	}
		
	// jvila, lo he tenido que hacer como arriba.	
	// Castellano
	// var cast = document.cookie.indexOf("cast"); 
	// si "cast" está en la cookie redirige a index 
	//if (cast != -1) document.location.href = "http://demos.esemtia.com/webesemtia/index.html"; 
	
	// Catala
	// var cat = document.cookie.indexOf("cat"); 
	// si "cat" está en la cookie redirige a la versión en catalán 
	// if (cat != -1) document.location.href = "http://demos.esemtia.com/webesemtia/cat/index.html"; 
	
	return; 
} 

// jvila, funcion que lee el valor de la cookie
function get_cookie (cookie_name)
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}
