var AVISO_ASIENTO_BEBE_TREN = false; var AVISO_ASIENTO_BEBES_ADULTOS = false; document.cookie = "IDOfertaSel=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; function getNumeroMaximoNoches(){ var numeroMaximoNoches = 31; switch(TIPO_CABECERA_AGENCIA){ case "Vuelos": numeroMaximoNoches = 365; break; } return numeroMaximoNoches; } function validarFormBusqueda() { document.cookie="IDOfertaSel=;"; if( $( "#txtDestino" ).length && (!$( "#txtDestino" ).val() || $( "#txtDestino" ).val()=="") ){ alertPopUp("Enter destination"); $('#txtDestino').focus(); return false; } var idDestino = $("#txtDestino_id").val(); if( !idDestino ){ idDestino = $("#list_id").val(); } if( IDAgencia==25253 && idDestino.indexOf('Z_')!=-1 ){ alertPopUp("Esta agencia solo puede hacer búsquedas por hotel"); $('#txtDestino').focus(); return false; } DaysOfStay=getDaysOfStay($("#datetimepicker1").val(),$("#datetimepicker2").val()); if (DaysOfStay > getNumeroMaximoNoches()) { alertPopUp("Atención: El número máximo de noches es: 31"); return false; } if( document.getElementById('H') ){ var totalOcupacion=0; for(i=1;i<=document.getElementById('H').value;i++){ var personasSelec=document.getElementById('O'+i).value; var adultos=parseInt(personasSelec.substr(0, 1)); var ninos=parseInt(personasSelec.substr(2, 1)); totalOcupacion+=(adultos+ninos); } if (totalOcupacion>19){ alertPopUp("The maximum number of people permitted is 19"); return false; } } if (TIPO_CABECERA_AGENCIA=="Vuelos"){ var arrayFecha = $("#datetimepicker1").val().split('/'); var dia=arrayFecha[0]; var mes = arrayFecha[1]; var anio = arrayFecha[2]; var fechaSalida = new Date(anio, mes-1, dia); var hoy = new Date(); var diffTime = Math.abs(fechaSalida - hoy); var diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); if(diffDays<=2){ alertPopUp("It is not possible to make a flight reservation with less than 48 hours notice, for any queries please contact us. 910781904"); return false; } } if (TIPO_CABECERA_AGENCIA=="Vuelos" || TIPO_CABECERA_AGENCIA=="Vuelo+Hotel"){ if (TIPO_CABECERA_AGENCIA=="Vuelos"){ var adultosV=parseInt($('#adultos').val()); var ninosV=parseInt($('#menores').val()); if ((adultosV+ninosV)>9){ alertPopUp("The maximum number of people permitted is 9"); return false; } }else{ if (totalOcupacion>9){ alertPopUp("The maximum number of people permitted is 9"); return false; } } } if( $('#txtTren_id').length && $('#txtTren_id').val()=="" ){ if( $('#txtTren').val()=='' )alertPopUp("Debes introducir la estación de origen"); else alertPopUp( $('#txtTren').val() + " does not have a railway station. Please modify your search."); $('#txtTren').focus(); return false; } if( $('#aer_origen_name').length && $('#aer_origen_name').val()=="" ){ if( $('#aer_origen_name').val()=='' )alertPopUp("Please insert the departure airport"); else alertPopUp( $('#aer_origen_name').val() +" no tiene aeropuerto. Seleccione de nuevo la búsqueda"); $('#aer_origen_name').focus(); return false; } if( $('#aer_origen_value').length && $('#aer_origen_value').val()=='' ){ alertPopUp("Please insert the departure airport"); $('#aer_origen_value').val(''); $('#aer_origen_value').focus(); return false; } if( $('#aer_origen_value').length && $('#aer_destino_value').length && $('#aer_origen_value').val() && $('#aer_destino_value').val()!='' && $('#aer_origen_value').val()==$('#aer_destino_value').val() ){ alertPopUp("El aeropuerto de origen tiene que ser distinto del de destino"); $('#aer_destino_value').val(''); $('#aer_destino_value').focus(); return false; } if( $('#aer_destino_name:visible').length && $('#aer_destino_name:visible').val()=="" && TIPO_CABECERA_AGENCIA!='Vuelo+Hotel'){ if( $('#aer_destino_name').val()=='' )alertPopUp("Debes introducir el aeropuerto de destino"); else alertPopUp($('#aer_destino_name').val() +" no tiene aeropuerto. Seleccione de nuevo la búsqueda"); $('#aer_destino_name').focus(); return false; } if( $('#aer_destino_name:visible').length && $('#aer_destino_value').val()=="" && TIPO_CABECERA_AGENCIA!='Vuelo+Hotel'){ alertPopUp("Debes introducir el aeropuerto de destino"); $('#aer_destino_name').val(''); $('#aer_destino_name').focus(); return false; } if( $('#tren_origen_name').length && ($('#tren_origen_name').val()=="" || $('#tren_origen_value').val()=='') ){ if( $('#tren_origen_name').val()=='' )alertPopUp("Debes introducir la estación de origen"); $('#tren_origen_name').focus(); return false; } if( $('#tren_destino_name').length && ($('#tren_destino_name').val()=="" || $('#tren_destino_value').val()=='') ){ if( $('#tren_destino_name').val()=='' )alertPopUp("Debes introducir la estación de destino"); $('#tren_destino_name').focus(); return false; } compruebaFechasCorrectas(); for (i=1;i<=2;i++){ var campoFecha=eval("document.f.datetimepicker"+i+".value"); if(campoFecha){ var DDMMAAAA=campoFecha.split("/"); var dia=parseInt(DDMMAAAA[0],10); var mes=parseInt(DDMMAAAA[1],10); var ano=parseInt(DDMMAAAA[2],10); $('#D'+i).val(dia); $('#MA'+i).val(mes+'_'+ano); } } var habitaciones=$("#H").val(); if (habitaciones=="") { alertPopUp("You must select at least one bedroom"); return false; } if(TIPO_CABECERA_AGENCIA!='Trenes'){ for(i=1;i<=numeroMaxHab;i++){ for (j=1;j<=3;j++){ if ($('#edadNino'+i+'_'+j).is(':visible')){ if ($('#edadNino'+i+'_'+j).val()==""){ alertPopUp("All the children\'s ages must be filled in"); return false; } if (parseInt($('#edadNino'+i+'_'+j).val())>=edadMaxNinos){ alertPopUp("Children must be under the age of 18 years old."); return false; } } } } } if(TIPO_CABECERA_AGENCIA!='Trenes'){ if( $('#menores').length && parseInt($('#menores').val(),10)>0 ){ var nNinos = parseInt($('#menores').val(),10); var edadCorrecta = true; for(var iNino=1; iNino<=nNinos; iNino++){ if( $('#edadNino'+iNino).length ){ var edadNino = parseInt($('#edadNino'+iNino).val(),10); if( $('#edadNino'+iNino).val()=="" ){ alertPopUp("All the children\'s ages must be filled in"); edadCorrecta = false; } switch(TIPO_CABECERA_AGENCIA){ case "Trenes": if( edadNino<4 || edadNino>13 ){ alertPopUp("The ages of the children must be between 4 and 13 years old."); edadCorrecta = false; } break; case "Vuelos": if( edadNino<2 || edadNino>12 ){ alertPopUp("The ages of the children must be between 2 and 12 years old."); edadCorrecta = false; } break; } } } if( !edadCorrecta ){ $('#edadNino'+iNino).focus(); return false; } } } if( $('#tarjetaDorada').length ){ var tarjetasDoradas = parseInt($('#tarjetaDorada').val() ,10); var adultos = parseInt($('#adultos').val(), 10); if( tarjetasDoradas>adultos ){ alertPopUp("No puede haber más tarjetas doradas que pasajeros adultos."); return false; } } var estacionOrigen=$("#txtTren_id").val(); var zonaDestino =$("#list_id").val(); if( !zonaDestino )zonaDestino=$("#txtDestino_id").val(); if( $('#estTren_destino_value').val()!='' ){ zonaDestino=$('#estTren_destino_value').val(); if( estacionOrigen!=zonaDestino ){ $('#frmBuscar').submit(); return true; } } var nHab = parseInt($('#H').val(), 10); var nAdultos = 0; var nNinos = 0; var nBebes = 0; for(var iHab=1; iHab<=nHab; iHab++){ var ocupacionesHab = $('#O'+ iHab +':visible'); $.each(ocupacionesHab, function(iEl, el){ var ocupacion = $(el).val(); var vOcupacion = ocupacion.split('A'); nAdultos += parseInt(vOcupacion[0],10); }); var inputEdades = $('input[id*=edadNino'+ iHab +']:visible'); $.each(inputEdades, function(iEl, el){ if( TIPO_CABECERA_AGENCIA=='Vuelo+Hotel' ){ if( $(el).val()<2 )nBebes++; else nNinos++; }else if( TIPO_CABECERA_AGENCIA=='Tren+Hotel' ){ if( $(el).val()<4 )nBebes++; else nNinos++; } }); } if( TIPO_CABECERA_AGENCIA=='Vuelo+Hotel' ){ if( nAdultos < nBebes ){ var html = "

Due to restrictions with the different airlines, the number of babies can not be higher than that of adults.

" + "
" + 'Accept'; popUpMesaje('', html, false); return false; } } var distancia = 20; if (estacionOrigen && zonaDestino){ if( nAdultos+nNinos+nBebes>9 ){ var html = "

The total number of passengers should not exceed 9.

" + "
" + 'Accept'; popUpMesaje('', html, false); return false; } if( !AVISO_ASIENTO_BEBES_ADULTOS ){ if( nBebes>nAdultos ){ var html = "

One baby per passenger may travel for free only if they do not occupy a seat, for reservations for two babies travelling with one adult, a child\'s ticket must be purchased for one of the children.

" + "
" + 'Accept'; popUpMesaje('', html, false); AVISO_ASIENTO_BEBES_ADULTOS = true; return false; } } $.ajax({ type: "POST", async: false, dataType: "text", url: "checkEstacionZona.php", data: {'estacionOrigen': estacionOrigen, 'zonaDestino': zonaDestino, 'distancia': distancia}, success: function (data) { var respuesta=JSON.parse(data); if (respuesta['respuesta']=='KO'){ alertPopUp("Departure and Destination points cannot be the same. Please change your search criteria."); } else{ $("html, body").animate({ scrollTop: 0 }, "fast"); $("body").css('overflow-y','hidden'); $("section").css('z-index','-1'); $(".ui-autocomplete").css('z-index','-1'); //////////////////////////////////////////// $("#divEstamosFlash").css({width:$(window).width(),height:$(window).height()}); $("#divEstamosFlash").css('display','block'); $('#divEstamosFlash').fadeIn('fast'); $('#frmBuscar').submit(); } } }); } else if (IDMinorista==17){ var list_id=$("#list_id").val(); var txtDestino=$("#txtDestino").val(); var permitirVentaEnPais; $.ajax({ type: "POST", url: "inc/funcionesAjax.php", data: "ID=2&list_id=" + list_id+"&txtDestino="+txtDestino, async: false, success: function(html) { permitirVentaEnPais=html; } }); var partes=permitirVentaEnPais.split("|||"); permitirVentaEnPais=partes[0]; if (permitirVentaEnPais=="N"){ alertPopUp(partes[1]); return false; } var necesitaVisado; $.ajax({ type: "POST", url: "inc/funcionesAjax.php", data: "ID=1&list_id=" + list_id+"&txtDestino="+txtDestino, async: false, success: function(html) { necesitaVisado=html; } }); var partes=necesitaVisado.split("|||"); necesitaVisado=partes[0]; if (necesitaVisado=="X"){ valor=dialogVisadosPaisSinVisados(); }else if (necesitaVisado=="Y"){ valor=dialogVisados(); }else{ $("html, body").animate({ scrollTop: 0 }, "fast"); $("body").css('overflow-y','hidden'); $("section").css('z-index','-1'); $(".ui-autocomplete").css('z-index','-1'); //////////////////////////////////////////// $("#divEstamosFlash").css({width:$(window).width(),height:$(window).height()}); $("#divEstamosFlash").css('display','block'); $('#divEstamosFlash').fadeIn('fast'); setTimeout($('#frmBuscar').submit(),500); } } else{ $("html, body").animate({ scrollTop: 0 }, "fast"); $("body").css('overflow-y','hidden'); $("section").css('z-index','-1'); $(".ui-autocomplete").css('z-index','-1'); //////////////////////////////////////////// $("#divEstamosFlash").css({width:$(window).width(),height:$(window).height()}); $("#divEstamosFlash").css('display','block'); $('#divEstamosFlash').fadeIn('fast'); setTimeout($('#frmBuscar').submit(),500); } } $("#buscarDispo").click( validarFormBusqueda ); function popupInfoGruposBuscador(){ // alertPopUp("If you require more than "+numeroMaxHab+" rooms, please contact us at "+emailGrupos); $.ajax({ type: 'GET', method: 'GET', url: '/presupuestoGrupos.php?lang=ENG', encode: true }).done(function(data) { popUpMesaje('Information for Groups', data, true, 'width:825px;') }); } $("#infoGrupos").click(popupInfoGruposBuscador); var maxFecha = fechaUltimoDiaMes(sumaRestaFecha(getFechaHoy(), "+18","m")); if( TIPO_CABECERA_AGENCIA=='Tren+Hotel' || TIPO_CABECERA_AGENCIA=='Trenes' ){ maxFecha = sumaRestaFecha(getFechaHoy(), "+365","d"); } var NUMERO_MESES = !isMobileOrTablet() ? 2 : 1; $( "#datetimepicker1" ).datepicker({ dateFormat: "dd/mm/yy", monthNames: meses, monthNamesShort: mesescortos, dayNamesMin: nomdias, changeMonth: true, changeYear: true, numberOfMonths: NUMERO_MESES, firstDay: 1, minDate: getFechaHoy(), maxDate: maxFecha, beforeShow: function( input ) { if ($("#datetimepicker1").val() && $("#datetimepicker2").val()) { DaysOfStay=getDaysOfStay($("#datetimepicker1").val(),$("#datetimepicker2").val()); } setTimeout(function(){ $('.ui-datepicker').css('z-index', 9999); }, 0); }, onClose: function( selectedDate ) { reconfigurarCalendarios("#datetimepicker1",selectedDate); } }); var maxFecha = fechaUltimoDiaMes(sumaRestaFecha(getFechaHoy(), "+18","m")); if( TIPO_CABECERA_AGENCIA=='Tren+Hotel' || TIPO_CABECERA_AGENCIA=='Trenes' ){ maxFecha = sumaRestaFecha(getFechaHoy(), "+365","d"); } switch( TIPO_CABECERA_AGENCIA ){ case 'Vuelo+Hotel': sumaRestaFecha(fechaManana, "+15"); break; case 'Tren+Hotel': sumaRestaFecha(fechaManana, "+30"); break; } $( "#datetimepicker2" ).datepicker({ defaultDate: "+1d", monthNames: meses, monthNamesShort: mesescortos, dayNamesMin: nomdias, dateFormat: "dd/mm/yy", changeMonth: true, changeYear: true, numberOfMonths: NUMERO_MESES, firstDay: 1, minDate: fechaManana, maxDate: maxFecha, //sumaRestaFecha(fechaManana, "+30"), beforeShow: function( input ) { setTimeout(function(){ $('.ui-datepicker').css('z-index', 9999); }, 0); }, onClose: function( selectedDate ) { reconfigurarCalendarios("#datetimepicker2",selectedDate); } }); $("#datetimepickerCalendar1").click(function() { $( "#datetimepicker1" ).datepicker('show'); }); $("#datetimepickerCalendar2").click(function() { $( "#datetimepicker2" ).datepicker('show'); }); $("#datetimepicker2").change(function() { compruebaFechasCorrectas(); }); function reconfigurarCalendarios(campo, selectedDate){ if(campo=='#datetimepicker1'){ var minDate = TIPO_CABECERA_AGENCIA=='Trenes' || TIPO_CABECERA_AGENCIA=='Vuelos'?selectedDate:sumaRestaFecha(selectedDate, "+1"); $( "#datetimepicker2" ).datepicker( "option", "minDate", minDate); if( TIPO_CABECERA_AGENCIA=='Vuelo+Hotel' ){ if( IDMinorista!=17 )$( "#datetimepicker2" ).datepicker( "option", "maxDate", sumaRestaFecha(selectedDate, "+16") ); } if( TIPO_CABECERA_AGENCIA=='Tren+Hotel' || TIPO_CABECERA_AGENCIA=='Trenes' ){ $( "#datetimepicker2" ).datepicker( "option", "maxDate", sumaRestaFecha(selectedDate, "+31") ); } if (DaysOfStay && DaysOfStay==1) { $( "#datetimepicker2" ).datepicker( "setDate", sumaRestaFecha(selectedDate, "+"+DaysOfStay) ); } PonerDiaSemana('FechaInicio'); PonerDiaSemana('FechaFin'); }else{ PonerDiaSemana('FechaFin'); } } function getFechaHoy(){ var today=new Date(), dia=today.getDate(), mes=today.getMonth()+1, anio=today.getFullYear(); dia = dia.toString().length==1?"0"+dia.toString():dia; mes = mes.toString().length==1?"0"+mes.toString():mes; return dia+'/'+mes+'/'+anio; } function getDaysOfStay(strStartDate,strEndDate) { var arrayFecha = strStartDate.split('/'); var dia=arrayFecha[0]; var mes = arrayFecha[1]; var anio = arrayFecha[2]; var date1 = new Date(anio, mes - 1, dia); var arrayFecha = strEndDate.split('/'); var dia = arrayFecha[0]; var mes = arrayFecha[1]; var anio = arrayFecha[2]; var date2 = new Date(anio, mes - 1, dia); var diffDays = parseInt((date2 - date1) / (1000 * 60 * 60 * 24)); return diffDays; } function sumaRestaFecha(fecha, intervalo, dma) { if(!fecha){ fecha=fechaHoy; } var arrayFecha = fecha.split('/'); var dia = arrayFecha[0]; var mes = arrayFecha[1]; var anio = arrayFecha[2]; var fechaInicial = new Date(anio, mes - 1, dia); var fechaFinal = fechaInicial; if(dma=="m"){ fechaFinal.setMonth(fechaInicial.getMonth()+parseInt(intervalo)); }else if(dma=="y" || dma=="Y"){ fechaFinal.setFullYear(fechaInicial.getFullYear()+parseInt(intervalo)); }else{ fechaFinal.setDate(fechaInicial.getDate()+parseInt(intervalo)); } dia = fechaFinal.getDate(); mes = fechaFinal.getMonth() + 1; anio = fechaFinal.getFullYear(); dia = (dia.toString().length == 1) ? "0" + dia.toString() : dia; mes = (mes.toString().length == 1) ? "0" + mes.toString() : mes; return dia + "/" + mes + "/" + anio; } function fechaPrimerDiaMes(fecha){ var arrayFecha = fecha.split('/'); var dia = arrayFecha[0]; var mes = arrayFecha[1]; var anio = arrayFecha[2]; return "01/"+mes+""+anio; } function fechaUltimoDiaMes(fecha){ var arrayFecha = fecha.split('/'); var dia = arrayFecha[0]; var mes = arrayFecha[1]; var anio = arrayFecha[2]; var arrayDiasMeses=new Array("31",((anio%4=='0')?"29":"28"),"31","30","31","30","31","31","30","31","30","31"); return arrayDiasMeses[(mes-1)]+"/"+mes+"/"+anio; } function PonerDiaSemana(campo){ var arrSem=new Array(7);arrSem[0]=" on Sunday";arrSem[1]=" on Monday";arrSem[2]=" on Tuesday";arrSem[3]=" on Wednesday";arrSem[4]=" on Thursday";arrSem[5]=" on Friday";arrSem[6]=" on Saturday"; if(campo=='FechaInicio'){ var idx=1; } else if(campo=='FechaFin'){ var idx=2; } if(idx){ var campoFecha=eval("document.f.datetimepicker"+idx+".value"); if(campoFecha){ var DDMMAAAA=campoFecha.split("/"); var dia=parseInt(DDMMAAAA[0],10); var mes=parseInt(DDMMAAAA[1],10); var ano=parseInt(DDMMAAAA[2],10); var fsalida=new Date(ano,mes-1,dia); var isem=fsalida.getDay();fechaActual=new Date(anoActual,mesActual,diaActual);var mesPoner=mes-1;var diaPoner=dia;if(mesPoner<10){mesPoner='0'+mesPoner;} if(diaPoner<10){diaPoner='0'+diaPoner;} fecha=new Date(ano,mesPoner,diaPoner);diasDiferencia=diferenciaFechas(fecha,fechaActual);var objCapa="";var txtDiferencia="";var txtDiferencia2="";if(diasDiferencia<0){txtDiferencia="";} else if(diasDiferencia==0){if(objCapa==null){txtDiferencia="Today, ";}} else if(diasDiferencia==1){if(objCapa==null){txtDiferencia="Morning, ";}} else if(diasDiferencia==2){if(objCapa==null){txtDiferencia="Pasadomañana, ";}} else if(diasDiferencia<7){txtDiferencia2="In "+diasDiferencia+" dí­as ";} else if(diasDiferencia<28){var semanas=parseInt(diasDiferencia/7);var resto=parseInt(diasDiferencia%7);txtDiferencia2="In "+semanas;if(semanas==1){txtDiferencia2=txtDiferencia2+" week ";} else{txtDiferencia2=txtDiferencia2+" weeks ";} if(resto>0){txtDiferencia2=txtDiferencia2+"y "+resto+" dí­as ";}} if(idx==1){ if(MM_findObj('fe_dsem')!=null){ //$('#fe_dsem').html(txtDiferencia+arrSem[isem]) } if(MM_findObj('fe_dsem2')!=null){ document.f.fe_dsem2.innerHTML=txtDiferencia2;} } else if(idx==2){ if(MM_findObj('fs_dsem')!=null){ //$('#fs_dsem').html(txtDiferencia+arrSem[isem]) } if(MM_findObj('fs_dsem2')!=null){document.f.fs_dsem2.innerHTML=txtDiferencia2;} } }} return; } function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);} if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i105) && (e.keyCode<48 || e.keyCode>57) ) e.preventDefault(); }); $("#menores").change(CompruebaNinosVuelos); } function CompruebaNinos() { $("#txtEdadesNinos").hide(); $("#txtEdadesNinos2").hide(); $("[id^=txtEdadesNinos]").hide(); $("[id^=habitacion]").hide(); $("[id^=edadesNinos]").hide(); $("[id^=edadNino]").hide(); // $("[id^=bebes]").hide(); $("[id^=bebes] option").hide(); var nHab = parseInt($("#H").val()) + 1; for(var iHab=1; iHab<11; iHab++){ if(iHab < nHab){ $("#habitacion"+iHab).show(); var ocuHab = $("#O"+iHab).val(); $("#edadesNinos"+ iHab).show(); if( $("#O"+iHab).length ){ var nNinos=ocuHab.charAt(2); if( nNinos>0 ){ if (iHab ==1 || $(window).width() < 700){ $("#txtEdadesNinos"+ iHab).show(); } else{ $("#txtEdadesNinos1").show(); } if ( TIPO_CABECERA_AGENCIA!="Vuelo+Hotel"){ $("#txtEdadesNinos"+ iHab).show(); } $("#txtEdadesNinos").show(); $("#txtEdadesNinosH").show(); // $("#bebes"+ iHab).show(); var optionsBebes = $("#bebes"+ iHab +" option"); var nBebes = $("#bebes"+iHab).length?$("#bebes"+iHab).val():0; $( optionsBebes[0] ).show(); for(iNino=1; iNino<=3; iNino++){ if( iNino<=nNinos ){ $( optionsBebes[iNino] ).show(); if( iNino>nBebes ){ $("#edadNino"+iHab+"_"+iNino).show(); //if( $("#edadNino"+iHab+"_"+iNino).val()==0 )$("#edadNino"+iHab+"_"+iNino).val(""); }else $("#edadNino"+iHab+"_"+iNino).val(0); }else{ $("#edadNino"+iHab+"_"+iNino).hide(); $("#edadNino"+iHab+"_"+iNino).val(""); } } }else $("[id^=edadNino"+iHab+"]").val(""); } }else $("[id^=edadNino"+iHab+"]").val(""); } $("[id^=edadNino]:hidden").val(""); establecerTabIndex("frmBuscar"); } function CompruebaNinosVuelos(){ var numeroMenores=$('#menores').val(); if (numeroMenores>0){ $('#txtEdadesNinos').show(); $('#txtEdadesNinos2').show(); var inputNinos = $("input[id^=edadNino]"); for(var i=1; i<=inputNinos.length; i++){ if (i<=numeroMenores)$('#edadNino'+i).show(); else $('#edadNino'+i).hide(); } }else{ $('#txtEdadesNinos').hide(); $('#txtEdadesNinos2').hide(); $("input[id^=edadNino]").hide(); } } function compruebaFechasCorrectas(){ var entrada=$("#datetimepicker1").val(); var arrayEntrada=entrada.split("/"); var diaEntrada=arrayEntrada[0]; var mesEntrada=arrayEntrada[1]; var annoEntrada=arrayEntrada[2]; var salida=$("#datetimepicker2").val(); var arraySalida=salida.split("/"); var diaSalida=arraySalida[0]; var mesSalida=arraySalida[1]; var annoSalida=arraySalida[2]; var error='Notice! The date of exit must be major than the date of entry'; if (annoSalidaAccept and update\ Continue without updating\ "; popUpMesaje(title, html); } function establecerTabIndex(idForm){ $("#"+idForm).find("input:visible, select:visible, textarea:visible, button:visible, a:visible").each(function(i,el){ $(el).attr("tabindex", i*20+100); }); $("[id^=habitacion] select:visible").each(function(i,elHab){ var tabIndex = parseInt($(elHab).attr("tabindex"),10); $("[id^=edadNino"+ (i+1) +"_]:visible").each(function(j,elEdad){ $(elEdad).attr("tabindex", tabIndex+j+1); }); }); if( $("#aer_destino_name:visible").length && $("#txtDestino").length ){ $("#aer_destino_name:visible").attr("tabindex", parseInt($("#txtDestino").attr("tabindex"),10)+1); } } establecerTabIndex("frmBuscar"); function seleccionarAeropuertoDestino(e){ if( $(e.target).prop('checked') ){ $('#divAeropuertoDestino').css('display', 'block'); }else{ $('#divAeropuertoDestino').css('display', 'none'); $('#aer_destino_name').val(''); $('#aer_destino_value').val(''); } establecerTabIndex("frmBuscar"); } AEROPUERTOS_SUGERIDOS = []; ULTIMO_ID_AEROPUERTOS_SUGERIDOS = null; function mostrarIconAeropuertosCercanos(){ if( $("#list_id").val()!='' ){ if( $('#iconAeropuertosSugeridos').length==0 || ULTIMO_ID_AEROPUERTOS_SUGERIDOS!=$("#list_id").val() ){ ULTIMO_ID_AEROPUERTOS_SUGERIDOS = $("#list_id").val(); AEROPUERTOS_SUGERIDOS = []; $.ajax({ url: "/spaintravel/js/ajax/getAirportsZone.php?IDZone="+ $("#list_id").val(), dataType: "json", success: function(aeropuertos) { AEROPUERTOS_SUGERIDOS = aeropuertos; if(aeropuertos && aeropuertos.length>1){ var idZone = $('#list_id').val(); idZone = parseInt(idZone.replace('Z_',''),10); var encontradaZona = false; var minDistancia = 10000; $.each(aeropuertos, function(i, aer){ if( aer.IDZona==idZone )encontradaZona = true; var distanciaAer = parseFloat(aer.distancia); if( distanciaAer50 ){ var html = "

No se ha encontrado un aeropuerto en la zona solicitada, buscaremos los aeropuertos más cercanos a esta zona.

" + "Accept"; if( $('#titNoEncontradoAero').length==0 )popUpMesaje('', html, false); } $('#iconAeropuertosSugeridos').remove(); var html = '\ \ '; $("#txtDestino").closest("div").append(html); } // comprobarResidente(); } }); } }else{ setTimeout(mostrarIconAeropuertosCercanos,50); } } function mostrarAeropuertosCercanosZona(){ if( AEROPUERTOS_SUGERIDOS && AEROPUERTOS_SUGERIDOS.length ){ var html = ''; html += ''; $("html").append(html); } } function clickAeropuertosCercanosZona(nombre, iata){ $('#cargandoBackground').remove(); $('#cargandoContent').remove(); $('#aer_destino_name').val(nombre); $('#aer_destino_value').val(iata); $("#divAeropuertoDestino").show(); if( !$("#aeropuertoDestino").prop("checked",true) )$("#aeropuertoDestino").trigger("click"); } if( $("#txtDestino").length && $("#aer_destino_value").length ){ $("#txtDestino").bind("blur",function(){ mostrarIconAeropuertosCercanos(); }); $("#txtDestino").bind("keydown",function(){ $("#iconAeropuertosSugeridos").remove(); // $('#aer_destino_name').val(''); // $('#aer_destino_value').val(''); }); } RADIO_BUSCAR_ESTACIONES = 50; ESTACIONES_TREN_SUGERIDAS = []; ULTIMO_ID_ESTACIONES_TREN_SUGERIDAS = null; function mostrarIconEstacionesTrenCercanas(){ if( $("#list_id").val()!='' ){ if( $('#iconEstacionesTrenSugeridas').length==0 || ULTIMO_ID_ESTACIONES_TREN_SUGERIDAS!=$("#list_id").val() ){ ULTIMO_ID_ESTACIONES_TREN_SUGERIDAS = $("#list_id").val(); ESTACIONES_TREN_SUGERIDAS = []; $.ajax({ url: "/spaintravel/js/ajax/getTrainStationsZone.php?ID="+ $("#list_id").val() +'&d='+ RADIO_BUSCAR_ESTACIONES + ($('#txtTren_id').val()!=''?'&o='+$('#txtTren_id').val():''), dataType: "json", success: function(estaciones) { if(estaciones && estaciones.length>1){ ESTACIONES_TREN_SUGERIDAS = estaciones; var mostrarSugeridorEstaciones = true; var IdZonaBuscador = null; var vIdZonaBuscador = ULTIMO_ID_ESTACIONES_TREN_SUGERIDAS.split('_'); var nombreZonaBuscador = ( $('#txtDestino').val() ).toLowerCase(); var nombreProvincia = nombreZonaBuscador.indexOf('provincia')!=-1; if( vIdZonaBuscador[0]=='Z' ){ var IdZonaBuscador = vIdZonaBuscador[1]; $.each(estaciones, function(iEstacion, estacion){ var nombreEstacion = estacion.nombre.toLowerCase(); if( estacion.idZona==IdZonaBuscador // || (!nombreProvincia && (nombreEstacion.indexOf(nombreZonaBuscador)!=-1 || nombreZonaBuscador.indexOf(nombreEstacion)!=-1) ) )mostrarSugeridorEstaciones = false; }); } if( vIdZonaBuscador[0]=='H' ){ var IdZonaBuscador = vIdZonaBuscador[1]; $.each(estaciones, function(iEstacion, estacion){ if( estacion.distancia<=10 )mostrarSugeridorEstaciones = false; }); } if( mostrarSugeridorEstaciones ){ $('#iconEstacionesTrenSugeridas').remove(); var html = '\ \ '; $("#txtDestino").closest("div").append(html); $("#estTren_radio").val(RADIO_BUSCAR_ESTACIONES); } } } }); } }else{ setTimeout(mostrarIconEstacionesTrenCercanas,50); } } function mostrarEstacionesTrenCercanasZona(){ if( ESTACIONES_TREN_SUGERIDAS && ESTACIONES_TREN_SUGERIDAS.length ){ var html = ''; html += '
' + '' + '
'; $("html").append(html); } } function clickEstacionTrenCercanasZona(nombre, idEstacion){ $('#cargandoBackground').remove(); $('#cargandoContent').remove(); $('#estTren_destino_name').val(nombre); $('#estTren_destino_value').val(idEstacion); $("#divEstacionTrenDestino").show(); $("#estTren_radio").val('0'); if( !$("#aeropuertoDestino").prop("checked",true) )$("#aeropuertoDestino").trigger("click"); } if( $("#txtDestino").length && $("#estTren_destino_value").length ){ $("#txtDestino").bind("blur",function(){ mostrarIconEstacionesTrenCercanas(); }); $("#txtDestino").bind("keydown",function(){ $("#iconEstacionesTrenSugeridas").remove(); $('#estTren_destino_name').val(''); $('#estTren_destino_value').val(''); $("#estTren_radio").val(''); $("#divEstacionTrenDestino").hide(); }); } function dialogVisados() { $("#dialog-confirm-visados").css("display", "block"); $("#dialog-confirm-visados").dialog({ resizable: false, height:140, modal: true, buttons: { "Si": function() { $( this ).dialog( "close" ); $("#necesitaVisado").val('Y'); $("html, body").animate({ scrollTop: 0 }, "fast"); $("body").css('overflow-y','hidden'); $("section").css('z-index','-1'); $(".ui-autocomplete").css('z-index','-1'); //////////////////////////////////////////// $("#divEstamosFlash").css({width:$(window).width(),height:$(window).height()}); $("#divEstamosFlash").css('display','block'); $('#divEstamosFlash').fadeIn('fast'); $('#frmBuscar').submit(); }, "No": function() { $( this ).dialog( "close" ); $("#necesitaVisado").val('N'); $("html, body").animate({ scrollTop: 0 }, "fast"); $("body").css('overflow-y','hidden'); $("section").css('z-index','-1'); $(".ui-autocomplete").css('z-index','-1'); //////////////////////////////////////////// $("#divEstamosFlash").css({width:$(window).width(),height:$(window).height()}); $("#divEstamosFlash").css('display','block'); $('#divEstamosFlash').fadeIn('fast'); $('#frmBuscar').submit(); } } }); $("#dialog-confirm-visados").dialog("option", "position", "center"); ajusteDialogVisado(); } function dialogVisadosPaisSinVisados() { $("#dialog-confirm-visados-pais-sin-visado").css("display", "block"); $("#dialog-confirm-visados-pais-sin-visado").dialog({ resizable: false, modal: true, buttons: { "Search": function() { $( this ).dialog( "close" ); $("#necesitaVisado").val('N'); $("html, body").animate({ scrollTop: 0 }, "fast"); $("body").css('overflow-y','hidden'); $("section").css('z-index','-1'); $(".ui-autocomplete").css('z-index','-1'); //////////////////////////////////////////// $("#divEstamosFlash").css({width:$(window).width(),height:$(window).height()}); $("#divEstamosFlash").css('display','block'); $('#divEstamosFlash').fadeIn('fast'); $('#frmBuscar').submit(); } } }); $("#dialog-confirm-visados-pais-sin-visado").dialog("option", "position", "center"); ajusteDialogVisado(); } function ajusteDialogVisado(){ $('.ui-dialog.ui-widget.ui-widget-content.ui-corner-all').css("position","absolute"); $('.ui-dialog.ui-widget.ui-widget-content.ui-corner-all').css("top","150px"); $('html').scrollTop(0); $('body').scrollTop(0); } var AVISO_ASIENTO_BEBE_TREN = false; if( TIPO_CABECERA_AGENCIA=='Tren+Hotel' ){ $('input[id*=edadNino]').change(function(e){ if( !AVISO_ASIENTO_BEBE_TREN && $(e.target).val()<4 ){ var html = "

Children under 4 years old travel for free and do not occupy a seat. In the case where a seat is required, a ticket should be purchased indicating the age of the child as over 4 years old..

" + "
" + "Accept"; popUpMesaje('', html, false); AVISO_ASIENTO_BEBE_TREN = true; } }); } if( TIPO_CABECERA_AGENCIA=='Trenes' ){ $('#bebes').blur(function(e){ if( !AVISO_ASIENTO_BEBE_TREN && $(e.target).val()<4 ){ var html = "

Children under 4 years old travel for free and do not occupy a seat. In the case where a seat is required, a ticket should be purchased indicating the age of the child as over 4 years old..

" + "
" + "Accept"; popUpMesaje('', html, false); AVISO_ASIENTO_BEBE_TREN = true; } }); } function compruebaBebes(){ if ($('#adultos').val()<$('#Vbebes').val()){ var html = "

The number of babies must not be more than the number of adults given than they should always be accompanied..

" + "
" + "Accept"; popUpMesaje('', html, false); $('#Vbebes').val($('#adultos').val()); } } function pintaComboPaises(pais){ idioma="ENG"; var idagencia="923"; if (!pais){ if (idioma=="CHI"){ pais=79; }else if (idioma=="PT"){ pais=34; }else{ pais=15; } if (idagencia=='10270'){ pais=35; } } $.each(jsonPaises, function(i, j){ var row = ''; $(row).appendTo("#paisSel"); }); if( !pais || pais==0 )pais = ''; $("#paisSel option[value='" + pais +"']").attr("selected",true); } $(document).ready(function() { pintaComboPaises(pais); }); function muestraSelectorOcupacion(){ var datosBusqueda = { "adultos" : $('#adultos').val(), "jovenes" : $('#jovenes').val(), "menores" : $('#menores').val(), "bebes" : $('#Vbebes').val() }; var html ='' + '
' + '
' + '' + '
' + '
' + ''; $('#popUpDetallesHotelBackground').remove(); $('#popUpDetallesHotel').remove(); $('body').append(html); var altoMenu = $("#menuDetallesHotelPopUp").height(); var altoMaximo = $(window).height() - 130 - altoMenu + (altoMenu>50?30:0); $("#divContentPopup").css("max-height", altoMaximo); $('#SelecOcupacion').remove(); jQuery('
+
-
').insertAfter('.quantity input'); jQuery('.quantity').each(function(){ var spinner = jQuery(this), input = spinner.find('input[type="number"]'), btnUp = spinner.find('.quantity-up'), btnDown = spinner.find('.quantity-down'), min = input.attr('min'), max = input.attr('max'); btnUp.click(function() { var oldValue = parseFloat(input.val()); if( oldValue>=max ){ var newVal = oldValue; }else{ var newVal = oldValue + 1; } spinner.find("input").val(newVal); spinner.find("input").trigger("change"); }); btnDown.click(function() { var oldValue = parseFloat(input.val()); if( oldValue<=min ){ var newVal = oldValue; }else{ var newVal = oldValue - 1; } spinner.find("input").val(newVal); spinner.find("input").trigger("change"); }); }); } function muestraSelectorOcupacionAjax(){ var datosBusqueda = { "adultos" : $('#adultos').val(), "jovenes" : $('#jovenes').val(), "menores" : $('#menores').val(), "bebes" : $('#Vbebes').val() }; $.ajax({ type: 'GET', url: '/spaintravel/js/ajax/getOcupacion.php', dataType: "html", data:datosBusqueda, success: function(data){ $('body').append('
'+ data +'
'); var html ='' + '
' + '
' + '' + '
' + '
' + ''; $('#popUpDetallesHotelBackground').remove(); $('#popUpDetallesHotel').remove(); $('body').append(html); var altoMenu = $("#menuDetallesHotelPopUp").height(); var altoMaximo = $(window).height() - 130 - altoMenu + (altoMenu>50?30:0); $("#divContentPopup").css("max-height", altoMaximo); $('#SelecOcupacion').remove(); } }); } function estableceOcupacion(){ var adultos=$('#adults').val(); var jovenes=$('#teens').val(); var ninos=$('#childrens').val(); var bebes=$('#babies').val(); $('#adultos').val(adultos); $('#jovenes').val(jovenes); $('#menores').val(ninos); $('#Vbebes').val(bebes); var txtOcupacion=adultos; if (adultos>1){ txtOcupacion+=' adults'; }else{ txtOcupacion+=' adult'; } if( jovenes>0 ){ txtOcupacion+=', '+jovenes; if (jovenes>1){ txtOcupacion+=' youths'; }else{ txtOcupacion+=' youth'; } } if (ninos>0){ txtOcupacion+=', '+ninos; if (ninos>1){ txtOcupacion+=' children'; }else{ txtOcupacion+=' child'; } } if (bebes>0){ txtOcupacion+=', '+bebes; if (bebes>1){ txtOcupacion+=' babies'; }else{ txtOcupacion+=' Infant'; } } $('#ocupacion').val(txtOcupacion); $('#popUpDetallesHotelContent,#popUpDetallesHotelBackground').remove(); } function compruebaOcupacionVuelos(idInputChange){ var adultos=parseInt($('#adults').val(),10); var jovenes=parseInt($('#teens').val(),10); var ninos=parseInt($('#childrens').val(),10); var bebes=parseInt($('#babies').val(),10); var htmlBotonAceptar = '
' + ''; if( bebes>adultos ){ $('#babies').val(adultos); popUpMesaje("", "Due to restrictions with the different airlines, the number of babies can not be higher than that of adults" + htmlBotonAceptar, true); } if( adultos+jovenes+ninos+bebes > 9){ switch(idInputChange){ case 'adults': $('#'+idInputChange).val(adultos-1); break; case 'teens': $('#'+idInputChange).val(jovenes-1); break; case 'childrens': $('#'+idInputChange).val(ninos-1); break; case 'babies': $('#'+idInputChange).val(bebes-1); break; } popUpMesaje("", "The maximum number of people permitted is 9" + htmlBotonAceptar, true); } } function calculaCamposOneWay(){ if(document.getElementById('oneway').checked == true){ document.getElementById('colFechaVuelta').style.display = 'none'; document.getElementById('colHorasVuelta').style.display = 'none'; } else{ document.getElementById('colFechaVuelta').style.display = 'block'; document.getElementById('colHorasVuelta').style.display = 'block'; } } function muestraDestinosNieve(){ var html = ''; html += '
' + '