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("Debe introducir el destino"); $('#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("El número máximo de personas permitido es 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("No es posible realizar una reserva de vuelo con menos de 48 horas de antelación, para cualquier consulta contacte con nosotros 922 21 50 12"); 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("El número máximo de personas permitido es 9"); return false; } }else{ if (totalOcupacion>9){ alertPopUp("El número máximo de personas permitido es 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() + " no tiene estación de tren. Seleccione de nuevo la búsqueda"); $('#txtTren').focus(); return false; } if( $('#aer_origen_name').length && $('#aer_origen_name').val()=="" ){ if( $('#aer_origen_name').val()=='' )alertPopUp("Debes introducir el aeropuerto de origen"); 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("Debes introducir el aeropuerto de origen"); $('#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("Debe seleccionear al menos una habitación"); 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("Debe rellenar todas las edades de los niños"); return false; } if (parseInt($('#edadNino'+i+'_'+j).val())>=edadMaxNinos){ alertPopUp("Las edades de los menores han de ser menor de 18 años."); 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("Debe rellenar todas las edades de los niños"); edadCorrecta = false; } switch(TIPO_CABECERA_AGENCIA){ case "Trenes": if( edadNino<4 || edadNino>13 ){ alertPopUp("Las edades de los menores tienen que estar entre 4 y 13 años."); edadCorrecta = false; } break; case "Vuelos": if( edadNino<2 || edadNino>12 ){ alertPopUp("Las edades de los menores tienen que estar entre 2 y 12 años."); 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 = "

Debido a restricciones con las distintas aerolíneas el número de bebés no puede ser superior al de adultos.

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

La cantidad total de pasajeros, no puede ser superior a 9.

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

Sólo se permite un bebé gratis por cada pasajero adulto sin ocupar asiento, para poder reservar dos bebés con un adulto, uno de los niños deberá comprar un billete de niño.

" + "
" + 'Aceptar'; 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("No se permiten búsquedas con salida y llegada dentro del mismo destino. Por favor modifique los parámetros de la búsqueda"); } 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("Si necesitas más de "+numeroMaxHab+" habitaciones, por favor contáctanos a "+emailGrupos); $.ajax({ type: 'GET', method: 'GET', url: '/presupuestoGrupos.php?lang=SPA', encode: true }).done(function(data) { popUpMesaje('Información Grupos', 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]=" el domingo";arrSem[1]=" el lunes";arrSem[2]=" el martes";arrSem[3]=" el miércoles";arrSem[4]=" el jueves";arrSem[5]=" el viernes";arrSem[6]=" el sábado"; 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="Hoy, ";}} else if(diasDiferencia==1){if(objCapa==null){txtDiferencia="Mañana, ";}} else if(diasDiferencia==2){if(objCapa==null){txtDiferencia="Pasadomañana, ";}} else if(diasDiferencia<7){txtDiferencia2="Dentro de "+diasDiferencia+" dí­as ";} else if(diasDiferencia<28){var semanas=parseInt(diasDiferencia/7);var resto=parseInt(diasDiferencia%7);txtDiferencia2="Dentro de "+semanas;if(semanas==1){txtDiferencia2=txtDiferencia2+" semana ";} else{txtDiferencia2=txtDiferencia2+" semanas ";} 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='¡Atención! La fecha de salida ha de ser mayor que la fecha de entrada'; if (annoSalidaAceptar y actualizar\ Continuar sin actualizar\ "; 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: "/tumejorhotel/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.

" + "Aceptar"; 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: "/tumejorhotel/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: { "Buscar": 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 = "

Los menores de 4 años, viajan gratis y no ocupan asiento, en caso de querer ocupar asiento, deberá comprar un billete, indicando en la edad que es mayor de 4 años.

" + "
" + "Aceptar"; 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 = "

Los menores de 4 años, viajan gratis y no ocupan asiento, en caso de querer ocupar asiento, deberá comprar un billete, indicando en la edad que es mayor de 4 años.

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

El número de bebés no puede superar al de adultos ya que estos siempre deben ir acompañados.

" + "
" + "Aceptar"; popUpMesaje('', html, false); $('#Vbebes').val($('#adultos').val()); } } function pintaComboPaises(pais){ idioma="SPA"; var idagencia="638"; 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: '/tumejorhotel/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+=' adultos'; }else{ txtOcupacion+=' adulto'; } if( jovenes>0 ){ txtOcupacion+=', '+jovenes; if (jovenes>1){ txtOcupacion+=' jóvenes'; }else{ txtOcupacion+=' joven'; } } if (ninos>0){ txtOcupacion+=', '+ninos; if (ninos>1){ txtOcupacion+=' niños'; }else{ txtOcupacion+=' niño'; } } if (bebes>0){ txtOcupacion+=', '+bebes; if (bebes>1){ txtOcupacion+=' bebés'; }else{ txtOcupacion+=' bebé'; } } $('#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("", "Debido a restricciones con las distintas aerolíneas el número de bebés no puede ser superior al de adultos" + 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("", "El número máximo de personas permitido es 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 += '
' + '