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 = "