/*	Fecha de creación: 03/10/2007	Autor: Juan Antonio de Juan Berenguel*/// Array con la lista de paises, de mercados disponiblesvar paises =new Array();		paises['ES'] = "España";		paises['FR'] = "France";	  paises['IT'] = "Italia";	  paises['UK'] = "United Kingdom";	  paises['PT'] = "Portugal";		paises['AR'] = "Argentina";		paises['BR'] = "Brasil";		paises['MX'] = "México";		paises['DO'] = "Rep. Dominicana";		paises['VE'] = "Venezuela";		paises['US'] = "USA";		paises['PE'] = "Perú";		paises['OT'] = "Otros/Others";var short_paises=new Array();		short_paises['ES'] = "ES";		short_paises['FR'] = "FR";		short_paises['IT'] = "IT";		short_paises['UK'] = "UK";		short_paises['AR'] = "AR";		short_paises['BR'] = "BR";		short_paises['MX'] = "MX";		short_paises['DO'] = "DO";		short_paises['VE'] = "VE";		short_paises['US'] = "US";		short_paises['PT'] = "PT";		short_paises['PE'] = "PE";		short_paises['OT'] = "OT";// Array con la descripcion de todos los idiomas disponiblesvar desc_idiomas =new Array();		desc_idiomas['IT'] = "Italiano";		desc_idiomas['FR'] = "Français";		desc_idiomas['ES'] = "Español";		desc_idiomas['CA'] = "Català";		desc_idiomas['AR'] = "Argentino";		desc_idiomas['BR'] = "Português";		desc_idiomas['PT'] = "Português";		desc_idiomas['EN'] = "English";var short_desc_idiomas =new Array();		short_desc_idiomas['Italiano'] = "IT";		short_desc_idiomas['Français'] = "FR";		short_desc_idiomas['Español'] = "ES";		short_desc_idiomas['Català'] = "CA";		short_desc_idiomas['Argentino'] = "AR";		short_desc_idiomas['Português'] = "BR";		short_desc_idiomas['Português'] = "PT";		short_desc_idiomas['English'] = "EN";var idiomas =new Array();		idiomas['IT'] = [['IT'], ['ES']];		idiomas['FR'] = [['FR'], ['ES']];		idiomas['UK'] = [['ES'], ['EN']];		idiomas['ES'] = [['ES'], ['EN'], ['CA']];		idiomas['AR'] = [['ES'], ['EN']];		idiomas['BR'] = [['BR'], ['ES']];		idiomas['MX'] = [['ES'], ['EN']];		idiomas['DO'] = [['ES'], ['EN']];		idiomas['VE'] = [['ES'], ['EN']];		idiomas['US'] = [['ES'], ['EN']];		idiomas['PT'] = [['PT'], ['ES']];		idiomas['PE'] = [['ES'], ['EN']];		idiomas['OT'] = [['ES'], ['EN']];	// OT = otrosvar seleccion="seleccion"; // Se encarga de gestionar el nombre y contenido de la cookie	// Funcion compatible para generar una opcion del combofunction generaOpcionCombo(txt,value,idCombo,pos) {	oOption = document.createElement("OPTION");	oOption.text = txt;	oOption.value = value;		//asi se puede acceder al browser que sea		document.getElementById(idCombo).options[pos] = oOption;	}// Genera las opciones para el combobox de paises dejando seleccionado por defecto el Españafunction generaOpcionComboPaises(txt,value,idCombo,pos) {	oOption = document.createElement("OPTION");	oOption.text = txt;	oOption.value = value;	//asi se puede acceder al browser que sea		document.getElementById(idCombo).options[pos] = oOption;}function init_default(){			/*Lanzado al cargar la pagina*/		var fechaExp = new Date();			// Estable una fecha desde la cual se va a calcular la fecha final para la caducidad de la cookie	fechaExp.setTime(calculaFechaExpiracion());	if(leerCookie(seleccion)!=null)	{						//alert(leerCookie(seleccion));		actualizarCookie(seleccion, leerCookie(seleccion), fechaExp);		cargaHomeCookie(leerCookie(seleccion));	}else{		//alert(leerCookie('seleccion'));		cargaPaises('combo_aptpai');	// Cargamos el combo de paises	}	document.foDatosSesion.submit();}function cargaPaises(comboId){	var posCombo = 0;	var txt = '';	var value = '';	//borramos contenido	document.getElementById(comboId).options.length = 0;			    //añadimos un elemento centinela ?->		generaOpcionCombo('...',0,comboId, 0);					for(pai in paises)	{		posCombo++;		txt=paises[pai];		generaOpcionComboPaises(txt, short_paises[pai], comboId, posCombo);	}	cargaIdiomas('combo_aptpai', 'combo_aptidi');}function cargaIdiomas(paisId, idiomaId){	var posComboIdioma=0;	var aptPai= document.getElementById(paisId).value;	var l_idioma = idiomas[aptPai];	//var nomIdioma;	document.getElementById(idiomaId).options.length=0;	//generaOpcionCombo('...',0,comboId,0);	generaOpcionCombo('...',0,idiomaId,0);	for(listaIdioma in l_idioma){		//alert('entra en bucle');		var arrIdioma=l_idioma[listaIdioma];		posComboIdioma++;		nomIdioma=desc_idiomas[arrIdioma[0]];		//alert(nomIdioma);		generaOpcionCombo(nomIdioma,short_desc_idiomas[nomIdioma],idiomaId,posComboIdioma);	}			document.getElementById(idiomaId).options[document.getElementById(idiomaId).selectedIndex].value='1'	//document.getElementById(idiomaId).selectedIndex.value='1';}function cargaHome(paisId, idiomaId){	var fechaExp = new Date();	var error='';	fechaExp.setTime(parent.calculaFechaExpiracion());	var aptIdi=document.getElementById(idiomaId).value;	var aptPai=document.getElementById(paisId).value;	document.foDatosSesion.p_codmer.value=document.getElementById(paisId).value;	document.foDatosSesion.p_codidi.value=document.getElementById(idiomaId).value;	//var aptIdi=parent.document.foDatosSesion.p_codidi.value;	//var aptPai=parent.document.foDatosSesion.p_codmer.value;	//aptIdi=aptIdi.toLowerCase();	//aptPai=aptPai.toLowerCase();    if(aptPai!='0' && aptIdi !='0')	{		document.foDatosSesion.submit();		parent.establecerCookie(parent.seleccion ,aptPai+"/"+aptIdi, fechaExp);	}	else{		alert('Por favor, especifique el país y/o el idioma.');		return 0;	}}// Funcion que se encargara de calcular una fecha de expiracion 4 meses despues de la fecha actualfunction calculaFechaExpiracion(){	var fechaAct= new Date();	// Establece una fecha desde la cual se va a calcular la fecha final para la caducidad de la cookie	var MSxDia=24*60*60*1000;	// Cantidad de milisegundos que tiene un dia	var fechaFin = new Date(fechaAct.getTime()+MSxDia*120);	// 	return fechaFin;}// Lee el contenido de una cookie para posteriormente, realizar las gestiones pertinentesfunction leerCookie(name){  var cname = name + "=";                 var dc = document.cookie;               if (dc.length > 0) {                  begin = dc.indexOf(cname);           if (begin != -1) {                 begin += cname.length;             end = dc.indexOf(";", begin);      if (end == -1) end = dc.length;        return unescape(dc.substring(begin, end));    }   }  return null;}// Crea una cooki en funcion de la seleccion del usuarios respecto al idioma y el pais// para que el navegador se acuerde en ocasiones venideras, de dicha seleccion.function establecerCookie (name, value, expires, path, domain, secure){  document.cookie = name + "=" + escape(value) +   ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +  ((path == null) ? "" : "; path=" + path) +  ((domain == null) ? "" : "; domain=" + domain) +  ((secure == null) ? "" : "; secure");}function actualizarCookie (name, value, expires, path, domain, secure){  document.cookie = name + "=" + escape(value) +   ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +  ((path == null) ? "" : "; path=" + path) +  ((domain == null) ? "" : "; domain=" + domain) +  ((secure == null) ? "" : "; secure");}function borrarCookie (name,path,domain) {  if (getCookie(name)) {    document.cookie = name + "=" +    ((path == null) ? "" : "; path=" + path) +    ((domain == null) ? "" : "; domain=" + domain) +    "; expires=Thu, 01-Jan-70 00:00:01 GMT";  }}/*function cargaHomeCookie(redireccion){	if(redireccion=='br/es' || redireccion=='br/br' || redireccion=='ar/es' || redireccion=='ar/en')	{		document.location="http://www.aireuropa.com/"+redireccion+"/default_amadeus.html";			}else{		document.location="http://www.aireuropa.com/"+redireccion+"/default.html";	}	}*/function cargaHomeCookie(redireccion){	if (redireccion=='BR/ES'||redireccion=='BR/BR'||redireccion=='AR/ES'||redireccion=='AR/EN'||redireccion=='DO/EN'||redireccion=='DO/ES'||redireccion=='VE/EN'||redireccion=='VE/ES'||redireccion=='MX/EN'||redireccion=='MX/ES'||redireccion=='US/ES'||redireccion=='US/EN'||redireccion=='PT/ES'||redireccion=='PT/PT'||redireccion=='PE/ES'||redireccion=='PE/EN'){		if (redireccion=='BR/ES'){			document.foDatosSesion.p_codmer.value='BR';			document.foDatosSesion.p_codidi.value='ES';		}else if (redireccion=='BR/EN'){			document.foDatosSesion.p_codmer.value='BR';			document.foDatosSesion.p_codidi.value='BR';		}else if (redireccion=='AR/ES'){			document.foDatosSesion.p_codmer.value='AR';			document.foDatosSesion.p_codidi.value='ES';		}else if (redireccion=='AR/EN'){			document.foDatosSesion.p_codmer.value='AR';			document.foDatosSesion.p_codidi.value='EN';		}else if (redireccion=='VE/ES'){			document.foDatosSesion.p_codmer.value='DO';			document.foDatosSesion.p_codidi.value='ES';		}else if (redireccion=='DO/RN'){			document.foDatosSesion.p_codmer.value='DO';			document.foDatosSesion.p_codidi.value='EN';		}else if (redireccion=='DO/ES'){			document.foDatosSesion.p_codmer.value='MX';			document.foDatosSesion.p_codidi.value='ES';		}else if (redireccion=='VE/EN'){			document.foDatosSesion.p_codmer.value='MX';			document.foDatosSesion.p_codidi.value='EN';		}else if (redireccion=='MX/ES'){			document.foDatosSesion.p_codmer.value='VE';			document.foDatosSesion.p_codidi.value='EN';		}else if (redireccion=='MX/EN'){			document.foDatosSesion.p_codmer.value='VE';			document.foDatosSesion.p_codidi.value='EN';		}else if (redireccion=='US/ES'){			document.foDatosSesion.p_codmer.value='US';			document.foDatosSesion.p_codidi.value='ES';		}else if (redireccion=='US/EN'){			document.foDatosSesion.p_codmer.value='US';			document.foDatosSesion.p_codidi.value='EN';		}else if (redireccion=='UK/ES'){			document.foDatosSesion.p_codmer.value='UK';			document.foDatosSesion.p_codidi.value='ES';		}else if (redireccion=='UK/EN'){			document.foDatosSesion.p_codmer.value='UK';			document.foDatosSesion.p_codidi.value='EN';		}else if (redireccion=='PT/ES'){			document.foDatosSesion.p_codmer.value='PT';			document.foDatosSesion.p_codidi.value='ES';		}else if (redireccion=='PT/PT'){			document.foDatosSesion.p_codmer.value='PT';			document.foDatosSesion.p_codidi.value='PT';		}else if (redireccion=='PE/ES'){			document.foDatosSesion.p_codmer.value='PE';			document.foDatosSesion.p_codidi.value='ES';		}else if (redireccion=='PE/EN'){			document.foDatosSesion.p_codmer.value='PE';			document.foDatosSesion.p_codidi.value='EN';		}				if (redireccion=='US/ES'|| redireccion=='US/EN' || redireccion=='UK/ES'|| redireccion=='UK/EN' || redireccion=='PT/ES'|| redireccion=='PT/PT'|| redireccion=='PE/ES'|| redireccion=='PE/EN')    {    redireccion=redireccion.toLowerCase();		document.location="http://www.aireuropa.com/"+redireccion+"/default.html";    }else{		redireccion=redireccion.toLowerCase();		document.location="http://www.aireuropa.com/"+redireccion+"/default_amadeus.html";	  }	}else{		if (redireccion=='ES/ES'){			document.foDatosSesion.p_codmer.value='ES';			document.foDatosSesion.p_codidi.value='ES';			document.location="http://www.aireuropa.com/es/default.html";		}else if (redireccion=='ES/EN'){			document.foDatosSesion.p_codmer.value='ES';			document.foDatosSesion.p_codidi.value='EN';			document.location="http://www.aireuropa.com/en/default.html";					}else if (redireccion=='ES/CA'){			document.foDatosSesion.p_codmer.value='ES';			document.foDatosSesion.p_codidi.value='CA';			document.location="http://www.aireuropa.com/ca/default.html";		}else if (redireccion=='FR/FR'){			document.foDatosSesion.p_codmer.value='FR';			document.foDatosSesion.p_codidi.value='FR';			document.location="http://www.aireuropa.com/fr/default.html";		}else if (redireccion=='FR/ES'){			document.foDatosSesion.p_codmer.value='FR';			document.foDatosSesion.p_codidi.value='FR';			document.location="http://www.aireuropa.com/es/default.html";		}else if (redireccion=='IT/IT'){			document.foDatosSesion.p_codmer.value='IT';			document.foDatosSesion.p_codidi.value='IT';			document.location="http://www.aireuropa.com/it/default.html";		}else if (redireccion=='IT/ES'){			document.foDatosSesion.p_codmer.value='IT';			document.foDatosSesion.p_codidi.value='ES';			document.location="http://www.aireuropa.com/es/default.html";		}else if (redireccion=='OT/EN'){			document.foDatosSesion.p_codmer.value='OT';			document.foDatosSesion.p_codidi.value='EN';			document.location="http://www.aireuropa.com/en/default.html";		}else{			document.foDatosSesion.p_codmer.value='OT';			document.foDatosSesion.p_codidi.value='ES';			document.location="http://www.aireuropa.com/es/default.html";		}	}}
