// JavaScript Document

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function redireccion(ruta,sede){
  if (sede=='es')window.location.href = ruta+"es/index.htm";
	else if (sede=='fr')window.location.href = ruta+"fr/index.htm";
	else if (sede=='it')window.location.href = ruta+"it/index.htm";
	else if (sede=='mx')window.location.href = ruta+"mx/index.htm";
	else if (sede=='ar')window.location.href = ruta+"ar/index.htm";
	else if (sede=='us')window.location.href = ruta+"us/index.htm";
	else if (sede=='uk')window.location.href = ruta+"en/index.htm";
  else window.location.href = ruta+"en/index.htm";
}

function selectDelegacion(ruta){
	if( ruta=="undefined"){
		ruta=""};
	var elem = document.getElementById("sede");
 	var sede = elem.options[elem.selectedIndex].value;
	redireccion(ruta,sede)
}