function close_layers() {	if((document.getElementById("depFrameSal")) && (document.getElementById("depFrameSal").style.display=='block')) {		document.getElementById("depFrameSal").style.display='none';	}		if((document.getElementById("depFrameArr")) && (document.getElementById("depFrameArr").style.display=='block')) {		document.getElementById("depFrameArr").style.display='none';	}	 	if((document.getElementById("hotFrame")) && (document.getElementById("hotFrame").style.display=='block')) {		document.getElementById("hotFrame").style.display='none';	}	 	if((document.getElementById("calendarFrame")) && (document.getElementById("calendarFrame").style.display=='block')) {		document.getElementById("calendarFrame").style.display='none';	}		if((document.getElementById("calendarFrameExt")) && (document.getElementById("calendarFrameExt").style.display=='block')){		document.getElementById("calendarFrameExt").style.display='none';	}	 	if (document.getElementById("defCityBox")) document.getElementById("defCityBox").style.display = 'none';	if (document.getElementById("defCityBoxShim")) document.getElementById("defCityBoxShim").style.display = 'none';}function findY(obj) {	var curtop = 0;	if (obj.offsetParent) {		while (obj.offsetParent) {			curtop += obj.offsetTop			obj = obj.offsetParent;		}	}	else if (obj.y)		curtop += obj.y;	return curtop;}function findX(obj) {	var curleft = 0;	if (obj.offsetParent) {		while (obj.offsetParent) {			curleft += obj.offsetLeft			obj = obj.offsetParent;		}	}	else if (obj.x)		curleft += obj.x;	return curleft;}function putCityValue(src,clr) {	document.hotelsSearch.city.value=src;}function cleanUp(obj, txt) {	if (obj.value == txt) {		obj.value='';	}	return;}var selectednum=0;var cellSelected='#F6FBFF';var rolloverout='#BBDBFE';var last=null;var theTable=null;function mOvr(src){	src.style.cursor="hand"; }function mOut(src){}// vuelos search - select airlines function arl() {	var wAirline=window.frames.airlineFrame;	if(null==wAirline.airlineLoaded || false==wAirline.airlineLoaded){		alert("No se pueden mostrar las aerolineas.\nPor favor, actualiza la página.");		return;	}    wAirline.showAirline(window.document.abairline, 1);}function selecciona(src,num){	close_layers();	hideLayerId("flSearch");	hideLayerId("hoSearch");	hideLayerId("viSearch");	document.searchSelector.radiomiddle[num].checked = true;	showLayerId(src);		if (num == 0) {		document.getElementById('flSel').className = "tab-on";		document.getElementById('hoSel').className = "tab-off";		document.getElementById('viSel').className = "tab-off";	} else if (num == 1) {		document.getElementById('flSel').className = "tab-off";		document.getElementById('hoSel').className = "tab_mid-on";		document.getElementById('viSel').className = "tab-off";	} else if (num == 2) { 		document.getElementById('flSel').className = "tab-off";		document.getElementById('hoSel').className = "tab-off";		document.getElementById('viSel').className = "tab_mid-on";	}}function showLayerId(id) {		document.getElementById(id).style.display = "block";}function hideLayerId(id) {		document.getElementById(id).style.display = "none";}function setSearchtermDest2(){	var index = document.sopsSearch.selectDestination.selectedIndex;	document.sopsSearch.searchterm.value=document.sopsSearch.selectDestination.options[index].value;}function dcal(eTrig, dMin, dMax, campo, fr, isExt) {	var wCal=window.frames['calendarFrame'];	if ((document.flightsSearch) && (document.flightsSearch.depDate.value=='Soy flexible' && campo!='depDate')){		alert("Si pulsas sobre el boton buscar, el buscaprecios se encargara de mostrarte las fechas disponibles de retorno.");		return;	}	if (isExt == 'true') {		wCal=window.frames['calendarFrameExt'];	}		if(null==wCal.calendariLoaded || false==wCal.calendariLoaded){		alert("No se puede mostrar el calendario.\nPor favor, actualiza la página.");		return;	}	if (eTrig == 0) {		if ("sopsSearch"==fr)wCal.showCalendar(window.document.cal1via, dMin, dMax, campo,fr);		else		if ("hotelsSearch"==fr) wCal.showCalendar(window.document.cal21hot, dMin, dMax, campo,fr);		else wCal.showCalendar(window.document.cal1bt, dMin, dMax, campo,fr);	} else {		if ("hotelsSearch"==fr)wCal.showCalendar(window.document.cal2hot, dMin, dMax, campo,fr);		else wCal.showCalendar(window.document.cal2bt, dMin, dMax, campo,fr);	}}function depAp() {	var wAirport = window.frames['depFrameSal'];	if(null==wAirport.airportDepLoaded || false==wAirport.airportDepLoaded){		alert("No se pueden mostrar las ciudades de origen.\nPor favor, actualiza la página.");		return;	}	wAirport.showCity(window.parent.frames['0'].dbCity, 0);} function hotAp() {	var wAirport=window.frames['hotFrame'];	if(null==wAirport.airportDepLoaded || false==wAirport.airportDepLoaded){		alert("No se pueden mostrar los Hoteles.\nPor favor, actualiza la página.");		return;	}	wAirport.showCity(window.parent.frames['0'].abCity, 1);}function arrAp() {	var wAirport=window.frames['depFrameArr'];	if(null==wAirport.airportDepLoaded || false==wAirport.airportDepLoaded){		alert("No se pueden mostrar las ciudades de destino.\nPor favor, actualiza la página.");		return;	}    wAirport.showCity(document.getElementById("adCity"), 1);}function takeYear(theDate){	x = theDate.getYear();	var y = x % 100;	y += (y < 38) ? 2000 : 1900;	return y;}function anyadirDias(pDate,pTotalDias,ptipo){	fecha= new Date(pDate.substring(3,5) + "/" + pDate.substring(0,2)+ "/" + pDate.substring(6));	fecha.setTime(fecha.getTime()+(pTotalDias*24*60*60*1000));	dia = fecha.getDate();	if (dia<10) dia = "0" + dia;	mes = fecha.getMonth()+1; if (mes<10) mes = "0" + mes;	return (ptipo=='data') ? dia+"/"+mes+"/"+takeYear(fecha) : takeYear(fecha)+""+mes+""+dia;}// -------------------------------------- BOOKMARK THIS PAGE ------------------------------------ //function bookmark(url, description){netscape="Netscape User's hit CTRL+D to add a bookmark to this site."if (navigator.appName=='Microsoft Internet Explorer'){window.external.AddFavorite(url, description);}else if (navigator.appName=='Netscape'){alert(netscape);}} // <a href="javascript:bookmark(' http://www.edreams.es ',' Edreams ');">Bookmark this Site</A>// -------------------------------------- FORM VALIDATION ------------------------------------ //// ----------------------------------- Validate Flights Search ------------------------------- //function checkSearchHomeForm(form) {// check passengers	var nadults = parseInt(form.adults.value,"10");	var nchilds = parseInt(form.childs.value,"10");	var ninfants = parseInt(form.infants.value,"10");	var ntotpax=0;	ntotpax = nadults + nchilds+ninfants;		if (ntotpax > 9) {		alert("The maximun number of passengers is nine.");		return false;	}		if (ntotpax < 1) {		alert("Please select the number of passengers");		return false;	}	if ((nchilds+ninfants) > (nadults*2)) {		alert("Maximun of two children per adult.");		return false;	}	if ((ninfants) > nadults) {		alert("Maximun of one baby only per adult.");		return false;	}	// check cities	if (form.departureCity.value == "" || form.departureCity.value == "Escribe tu ciudad") {		alert("Please enter a departure airport.");		form.departureCity.focus();		return false;	}	if (form.departureCity.value.search(/\d/) != -1) {		alert("The departure city cannot contain numbers.");		form.departureCity.focus();		return false;	}		if (form.arrivalCity.value == "" || form.arrivalCity.value == "Escribe tu ciudad") {		alert("Please enter a destination city.");		form.arrivalCity.focus();		return false;	}		if (form.arrivalCity.value.search(/\d/) != -1) {		alert("Destination city cannot contain numbers.");		form.arrivalCity.focus();		return false;	}// check datesif (form.depDate.value!="Soy flexible" && form.retDate.value!="Soy flexible") {	if (form.depDate.value == "") {		alert("Please enter a departure date");		return false;	}	if ((form.depDate.value.length != 10) || (form.depDate.value.charAt(2) !='/') || (form.depDate.value.charAt(5) != '/'))  {		alert("The correct date format is dd/mm/aaaa. ej. 24/11/2004");		return false;	}	if (form.chkAirportsType.checked) form.AirportsType.value='PRIMARY';	var diafecha, mesfecha, anyofecha;	var d = new Date();	var diasmes = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];	diafecha = form.depDate.value.substring(0, 2);	mesfecha = form.depDate.value.substring(3, 5);	anyofecha = form.depDate.value.substring(6);		idep = parseInt(anyofecha + mesfecha + diafecha);	if (isNaN(diafecha) || isNaN(mesfecha) || isNaN(anyofecha)) {		alert("El formato de la fecha de salida correcto es dd/mm/aaaa. ej. 24/11/2004");		return false;	}		if (anyofecha < d.getYear()) {		alert("The departure date must be after today");		return false;	}		if ((mesfecha < 1) || (mesfecha > 12)) {		alert("The correct date format is dd/mm/aaaa. ej. 24/11/2004");		return false;	}	if ((diafecha < 1) || (diafecha > diasmes[mesfecha])) {		alert("The correct date format is dd/mm/aaaa. ej. 24/11/2004");		return false;	}	form.departureDate.value = diafecha + mesfecha + anyofecha;	form.isZapOff.value="0";	form.zapOffPercent.value = 0;	//Tijeretazo	if ((idep >= 20051021) && (idep <= 20051031)) {		if (form.isZapOffdates.value == "1") {			form.isZapOff.value="1";			form.zapOffPercent.value=30;		}	} else {		form.isZapOff.value="0";		form.zapOffPercent.value=0;	}		if (form.trip.value == 1) {		if (form.retDate.value == "") {			alert("Please enter a return date.");			return false;		}			if (form.retDate.value.length != 10) {			alert("The correct date format is dd/mm/aaaa. ej. 24/11/2004");			return false;		}			if ((form.retDate.value.charAt(2) !='/') || (form.retDate.value.charAt(5) != '/'))  {			alert("The correct date format is dd/mm/aaaa. ej. 24/11/2004");			return false;		}		diafecha = form.retDate.value.substring(0, 2);		mesfecha = form.retDate.value.substring(3, 5);		anyofecha = form.retDate.value.substring(6);		if (isNaN(diafecha) || isNaN(mesfecha) || isNaN(anyofecha)) {			alert("The correct date format is dd/mm/aaaa. ej. 24/11/2004");			return false;		}			if (anyofecha < d.getYear()) {			alert("The return date must be after today.");			return false;		}			if ((mesfecha < 1) || (mesfecha > 12)) {			alert("The correct date format is dd/mm/aaaa. ej. 24/11/2004");			return false;		}		if ((diafecha < 1) || (diafecha > diasmes[mesfecha])) {			alert("The correct date format is dd/mm/aaaa. ej. 24/11/2004");			return false;		}		iret = parseInt(anyofecha + mesfecha + diafecha);				if (idep > iret) {			alert("The return date must be after the departure date.");			return false;		}		form.returnDate.value = diafecha + mesfecha + anyofecha;				if (form.searchType.options != null) {			if (idep == iret) {				form.searchType.options[1].selected = true;			}				}		if  ((form.isZapOff.value == "1") && ((iret >= 20051021) && (iret <= 20051115))) {			if (form.isZapOffdates.value == "1") {				form.isZapOff.value="1";			} else {				form.isZapOff.value="0";form.zapOffPercent.value=0;			}					} else {			form.isZapOff.value="0";form.zapOffPercent.value=0;		}	}} else {	document.flightsSearch.action="/edreams/espanol/amadeus3/checkCitys.jhtml";}	waitscreen();track();}function waitscreen() {document.getElementById('search-box').style.display="none";document.getElementById('waitscreen').style.display="block";}function track() {urchinTracker('/edreams_com/seo_flight_search');}// ----------------------------------- Validate Hotels Search ------------------------------- //function checkhotelsSearch() {	if (document.hotelsSearch.city.value=='Escribe aquí la localidad'){		alert('Por favor, escribe tu ciudad de destino');		document.hotelsSearch.cityName.select();document.hotelsSearch.cityName.focus();		return false;	}	if (document.hotelsSearch.city.value=='') {		alert('Debe indicar la ciudad de destino');		return false;	}	if (document.hotelsSearch.city.value.search(/\d/) != -1) {		alert("La ciudad de destino no puede contener números.");		return false;	}		var numAdt = parseInt(document.hotelsSearch.numberOfAdults.value, 10);	var numChd = parseInt(document.hotelsSearch.numberOfChilds.value, 10);		if ((numAdt + numChd) > 4) {		alert('El número máximo de pasajeros por habitación es de 4. Por favor revisa el número de pasajeros.');		return false;	}		if (document.hotelsSearch.arrivalDate.value=='') {		alert('Debe indicar la fecha de llegada');		return false;	}	if (document.hotelsSearch.arrivalDate.value.length!=10) {		alert("El formato de la fecha de llegada es incorrecto.");		return false;	}	if ((document.hotelsSearch.arrivalDate.value.charAt(2)!='/')||(document.hotelsSearch.arrivalDate.value.charAt(5)!='/')) {		alert("El formato de la fecha de llegada es incorrecto.");		return false;	}	if(document.hotelsSearch.departureDate.value=='') {		alert('Debe indicar la fecha de salida');		return false;	}	if(document.hotelsSearch.departureDate.value.length!=10) {		alert("El formato de la fecha de salida es incorrecto.");		return false;	}	if((document.hotelsSearch.departureDate.value.charAt(2)!='/')||(document.hotelsSearch.departureDate.value.charAt(5)!='/')) {		alert("El formato de la fecha de salida es incorrecto.");		return false;	}		var diafecha, mesfecha, anyofecha;	var d = new Date();	var diasmes = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];	diafecha = document.hotelsSearch.arrivalDate.value.substring(0, 2);	mesfecha = document.hotelsSearch.arrivalDate.value.substring(3, 5);	anyofecha = document.hotelsSearch.arrivalDate.value.substring(6);		idep = parseInt(anyofecha + mesfecha + diafecha);	if (isNaN(diafecha) || isNaN(mesfecha) || isNaN(anyofecha)) {		alert("El formato de la fecha de llegada introducida tiene un formato incorrecto.\n El formato correcto es dd/mm/aaaa. ej. 24/11/2005");		return false;	}		if (anyofecha < d.getYear()) {		alert("La fecha de llegada introducida es anterior a la fecha de hoy.\nPor favor introduce una fecha de llegada posterior a la fecha de hoy");		return false;	}		if ((mesfecha < 1) || (mesfecha > 12)) {		alert("El formato de la fecha de llegada introducida tiene un formato incorrecto.\n El formato correcto es dd/mm/aaaa. ej. 24/11/2005");		return false;	}	if ((diafecha < 1) || (diafecha > diasmes[mesfecha])) {		alert("El formato de la fecha de llegada introducida tiene un formato incorrecto.\n El formato correcto es dd/mm/aaaa. ej. 24/11/2005");		return false;	}	diafecha = document.hotelsSearch.departureDate.value.substring(0, 2);	mesfecha = document.hotelsSearch.departureDate.value.substring(3, 5);	anyofecha = document.hotelsSearch.departureDate.value.substring(6);	if (isNaN(diafecha) || isNaN(mesfecha) || isNaN(anyofecha)) {		alert("El formato de la fecha de salida introducida tiene un formato incorrecto.\n El formato correcto es dd/mm/aaaa. ej. 24/11/2005");		return false;	}		if (anyofecha < d.getYear()) {		alert("La fecha de salida introducida es anterior a la fecha de hoy.\nPor favor introduce una fecha de salida posterior a la fecha de hoy");		return false;	}		if ((mesfecha < 1) || (mesfecha > 12)) {		alert("El formato de la fecha de salida introducida tiene un formato incorrecto.\n El formato correcto es dd/mm/aaaa. ej. 24/11/2005");		return false;	}	if ((diafecha < 1) || (diafecha > diasmes[mesfecha])) {		alert("El formato de la fecha de salida introducida tiene un formato incorrecto.\n El formato correcto es dd/mm/aaaa. ej. 24/11/2005");		return false;	}	iret = parseInt(anyofecha + mesfecha + diafecha);			if (idep >= iret) {		alert("La fecha de salida introducida es anterior o igual a la fecha de llegada.\nPor favor introduce una fecha de salida posterior a la fecha de llegada.");		return false;	}		var today = new Date();	var maxDate = new Date(Date.parse((today.getFullYear()+1) + "/" +(parseInt(today.getMonth(),10))+ "/" + today.getDate()));	var md = parseInt(maxDate.getFullYear().toString() + ((maxDate.getMonth()+1)<10 ?("0"+(maxDate.getMonth()+1).toString()) : (maxDate.getMonth()+1).toString()) + (maxDate.getDate()<10?("0"+maxDate.getDate().toString()):maxDate.getDate().toString())); 	var em = anyadirDias(document.hotelsSearch.arrivalDate.value,30,'integer')	if (iret > em) {		alert("La estancia máxima es de 30 dias. Por favor revisa tu fecha de salida.");		return false;	}	if (iret > md) {		alert("La fecha de salida no puede ser posterior a " + maxDate.getDate() + "/" + (maxDate.getMonth()+1) + "/" + maxDate.getFullYear() + ". Por favor revisa la fecha de salida.");		return false;	}// ---- Swoosh -- // 	top.frames.hideLayer('edreamsScreen');	top.frames.showLayer('waitScreen');	window.scrollTo(1,1);	return true;}// ----------------------------------- Validate Playas/Hotels Search ------------------------------- //function checkplayasSearch() {	// Check Destination	if (document.getElementById('destination').value==''){		alert('Por favor, selecciona tu destino');		return false;	}		// Check dates	var diafecha, mesfecha, anyofecha;	var d = new Date();	var diasmes = [0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];	diafecha = document.getElementById('arrivalDate').value.substring(0, 2);	mesfecha = document.getElementById('arrivalDate').value.substring(3, 5);	anyofecha = document.getElementById('arrivalDate').value.substring(6);		idep = parseInt(anyofecha + mesfecha + diafecha);		diafecha = document.getElementById('departureDate').value.substring(0, 2);	mesfecha = document.getElementById('departureDate').value.substring(3, 5);	anyofecha = document.getElementById('departureDate').value.substring(6);	iret = parseInt(anyofecha + mesfecha + diafecha);			if (idep > iret) {		alert("La fecha de salida introducida es anterior a la fecha de llegada.\nPor favor introduce una fecha de salida posterior a la fecha de llegada.");		return false;	}		var today = new Date();	var maxDate = new Date(Date.parse((today.getFullYear()+1) + "/" +(parseInt(today.getMonth(),10))+ "/" + today.getDate()));	var md = parseInt(maxDate.getFullYear().toString() + ((maxDate.getMonth()+1)<10 ?("0"+(maxDate.getMonth()+1).toString()) : (maxDate.getMonth()+1).toString()) + (maxDate.getDate()<10?("0"+maxDate.getDate().toString()):maxDate.getDate().toString())); 	var em = anyadirDias(document.getElementById('arrivalDate').value,30,'integer')	if (iret > em) {		alert("La estancia máxima es de 30 dias. Por favor revisa tu fecha de salida.");		return false;	}	if (iret > md) {		alert("La fecha de salida no puede ser posterior a " + maxDate.getDate() + "/" + (maxDate.getMonth()+1) + "/" + maxDate.getFullYear() + ". Por favor revisa la fecha de salida.");		return false;	}			// Check number of people per room (max 4 inc children)	numadults = parseInt(document.getElementById('idnumadults').value);	numchildren = parseInt(document.getElementById('idnumchildren').value);	numpeoplehab = numadults + numchildren;		if (numpeoplehab > 4)  { 		alert("Máxima de 4 personas por habitación incluso niños.");		return false;	}			if (document.hotelsSearch.msie != null) {		if (document.hotelsSearch.msie.value == '1') {		top.frames.hideLayer('edreamsScreen');		top.frames.showLayer('waitScreen');		window.scrollTo(1,1);		}}		return true;}// ----------------------------------- End FORM VALIDATION ------------------------------- //function fixElement(element, message) {	alert(message);	element.focus();}function isMailReady(form) {	var passed = false;	if (form.email.value.indexOf("@") == -1 || form.email.value.indexOf(".") == -1) {		fixElement(form.email, "El formato del email tiene que ser usuario@dominio.com.");	} else {		form.submit();	}}function readCookie(cookieName) {    var theCookie=""+document.cookie;    var ind=theCookie.indexOf(cookieName);    if (ind==-1 || cookieName=="") return "";    var ind1=theCookie.indexOf(';',ind);    if (ind1==-1) ind1=theCookie.length;    return unescape(theCookie.substring(ind+cookieName.length+1,ind1));}function deleteCookie(name) {	if (ReadCookie(name)) {    	document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";	}}function setCookie(cookieName,cookieValue,nDays, path, domain) {	var today = new Date();	var expire = new Date();	if (nDays==null || nDays==0) nDays=1;	expire.setTime(today.getTime() + 3600000*24*nDays);	var cookieString = cookieName+"="+escape(cookieValue) + ";expires="+expire.toGMTString();	if (domain) {    	cookieString += ";domain=" + domain;	}	if (path) {    	cookieString += ";path=" + path;	}	//alert(cookieString);	document.cookie = cookieString;}function defaultBox(obj) {	dCityBox = document.getElementById('defCityBox');	// suggest list    dCityBoxShim = document.getElementById('defCityBoxShim');	// workaround: msie div over select		dCityBox.width = '160px';	dCityBox.style.border = "#000 1px solid";        dCityBox.style.top = findOffsetTop(document.getElementById(obj)) - 235 + 'px';    dCityBox.style.left = findOffsetLeft(document.getElementById(obj)) + 50 + 'px';		dCityBoxShim.width = dCityBox.width;	//dCityBoxShim.height = dCityBox.height;	dCityBoxShim.style.top = dCityBox.style.top;	dCityBoxShim.style.left = dCityBox.style.left;	dCityBoxShim.style.zIndex = dCityBox.style.zIndex - 1;	dCityBox.style.display = 'inline';	if (_sbShowBGIframe()) {       	dCityBoxShim.style.display = 'inline';	}}function closeDefault() { 	if (document.getElementById("defCityBox")) document.getElementById("defCityBox").style.display = 'none';	if (document.getElementById("defCityBoxShim")) document.getElementById("defCityBoxShim").style.display = 'none';}function _sbShowBGIframe() {    return ( window.opera ) ? false : true;}function selectDef(des) {	setCookie('dfCityOffers', des, 30,'/');	closeDefault();	//window.location.href = window.location.href;	window.location.reload(true);}function findOffsetLeft(element) {    return findOffset(element, "offsetLeft");}function findOffsetTop(element) {    return findOffset(element, "offsetTop");}function findOffset(element, type) {    var os = 0;    while(element) {        os += element[type];        element = element.offsetParent;    }    return os;}