/** * Funcion que hace casting de los parámetros de un vuelo * VARIABLES GLOBALES: * - "_auxDatosAdicionales" campos adicionales a añadir * - "_llegadaDistintoDia" variable donde vamos a indicar si hay vuelos que lleguen el día siguiente para pedir una nueva dispo de hoteles */ function castingVuelos(vuelo){ // Comprobación de las variables globales if( typeof(_auxDatosAdicionales)=='undefined' )_auxDatosAdicionales={}; if( typeof(_llegadaDistintoDia)=='undefined' )_llegadaDistintoDia=false; // Casting de los datos vuelo.precio = parseFloat(vuelo.precio); vuelo.soloIda = vuelo.soloIda=='true'; vuelo.adultos = parseInt(vuelo.adultos,10); vuelo.ninos = parseInt(vuelo.ninos,10); vuelo.bebes = parseInt(vuelo.bebes,10); // Por si buscamos por varios destinos para que ponga el código IATA cogemos el IATA del trayecto que estamos haciendo vuelo.iataSalidaOrigen = vuelo.escalas[0].IDAeropuertoSalida; if( vuelo.tipoVuelo=='ida' || vuelo.tipoVuelo=='vuelta' ){ vuelo.iataSalidaOrigen = vuelo.escalas[0].IDAeropuertoSalida; vuelo.iataSalidaDestino = vuelo.escalas[vuelo.escalas.length-1].IDAeropuertoLlegada; } $.each(vuelo.escalas, function(iEscala,escala){ // Por si buscamos por varios destinos para que ponga el código IATA cogemos el IATA del trayecto que estamos haciendo if( vuelo.tipoVuelo=='idaVuelta' && escala.tipoVuelo=='Ida' && escala.primeraEscala=='true' )vuelo.iataSalidaOrigen = escala.IDAeropuertoSalida; if( vuelo.tipoVuelo=='idaVuelta' && escala.tipoVuelo=='Vuelta' && escala.primeraEscala=='true' )vuelo.iataSalidaDestino = escala.IDAeropuertoSalida; // Calculo de la estancia en la escala if( vuelo.escalas[iEscala+1] && vuelo.escalas[iEscala+1].tipoVuelo==escala.tipoVuelo ){ var horaIni = escala.horaLlegada.split(':'); var minIni = parseFloat(horaIni[0])*60 + parseFloat(horaIni[1]); var horaFin = vuelo.escalas[iEscala+1].horaSalida.split(':'); var minFin = parseFloat(horaFin[0])*60 + parseFloat(horaFin[1]); numeroMaletas = escala.numeroMalesta; var duracion = 0; if( minFin < minIni )duracion = 1440-minIni + minFin; else duracion = minFin-minIni; escala.duracionEscala = duracion; } }); } /** * Función que devuelve el precio de un vuelo o grupo de vuelos (ida + vuelta) */ function getPrecioVuelo(vuelo){ var precioVuelo = 0; if( !vuelo )precioVuelo = 0; else if( vuelo.precio )precioVuelo = vuelo.precio; else if(vuelo.length==1 && vuelo[0])precioVuelo = vuelo[0].precio; else if(vuelo.length==2 && vuelo[0] && vuelo[1])precioVuelo = (vuelo[0].precio + vuelo[1].precio); precioVuelo = parseFloat(precioVuelo); precioVuelo = parseFloat( precioVuelo.toFixed(2) ); return precioVuelo; } /** * Función que devuelve la fecha de ida y vuelta de un vuelo */ function getFechasVuelo(vuelo, tipo){ if( tipo==undefined )tipo=='idaVuelta'; var fechas = {}; if( !vuelo )return fechas; if(vuelo.fechaSalidaIda && vuelo.horaSalidaIda){ fechas['fechaIda'] = vuelo.fechaSalidaIda; fechas['horaIda'] = vuelo.horaSalidaIda; fechas['fechaIdaLlegada'] = vuelo.fechaLlegadaIda; fechas['horaIdaLlegada'] = vuelo.horaLlegadaIda; } if(vuelo.fechaSalidaVuelta && vuelo.horaSalidaVuelta){ fechas['fechaVuelta'] = vuelo.fechaSalidaVuelta; fechas['horaVuelta'] = vuelo.horaSalidaVuelta; fechas['fechaVueltaLlegada'] = vuelo.fechaLlegadaVuelta; fechas['horaVueltaLlegada'] = vuelo.horaLlegadaVuelta; } if(vuelo.length==1){ fechas['fechaIda'] = vuelo[0].fechaSalidaIda; fechas['horaIda'] = vuelo[0].horaSalidaIda; fechas['fechaIdaLlegada'] = vuelo[0].fechaLlegadaIda; fechas['horaIdaLlegada'] = vuelo[0].horaLlegadaIda; if(vuelo[0].fechaSalidaVuelta && vuelo[0].horaSalidaVuelta){ fechas['fechaVuelta'] = vuelo[0].fechaSalidaVuelta; fechas['horaVuelta'] = vuelo[0].horaSalidaVuelta; fechas['fechaVueltaLlegada'] = vuelo[0].fechaLlegadaVuelta; fechas['horaVueltaLlegada'] = vuelo[0].horaLlegadaVuelta; } } if(vuelo.length==2){ fechas['fechaIda'] = vuelo[0].fechaSalidaIda; fechas['horaIda'] = vuelo[0].horaSalidaIda; fechas['fechaIdaLlegada'] = vuelo[0].fechaLlegadaIda; fechas['horaIdaLlegada'] = vuelo[0].horaLlegadaIda; fechas['fechaVuelta'] = vuelo[1].fechaSalidaIda; fechas['horaVuelta'] = vuelo[1].horaSalidaIda; fechas['fechaVueltaLlegada'] = vuelo[1].fechaLlegadaIda; fechas['horaVueltaLlegada'] = vuelo[1].horaLlegadaIda; } if( tipo=='ida' ){ delete( fechas['fechaVuelta'] ); delete( fechas['horaVuelta'] ); delete( fechas['fechaVueltaLlegada'] ); delete( fechas['horaVueltaLlegada'] ); }else if( tipo=='vuelta' ){ delete( fechas['fechaIda'] ); delete( fechas['horaIda'] ); delete( fechas['fechaIdaLlegada'] ); delete( fechas['horaIdaLlegada'] ); } return fechas; } function getNumeroMaletas(nMaletas){ switch( nMaletas ){ case 0: return 'Sin maletas'; case 1: return nMaletas +' bagagem'; default: return nMaletas +' bagagens'; } } /** * Función que devuelve las escalas de un vuelo */ function getEscalasVuelo(vuelo, tipoEscala){ var tipoVueloFiltrar = null; if( vuelo.tipoVuelo=='idaVuelta' ){ if( vuelo.escalas ){ tipoVueloFiltrar = (tipoEscala=="ida" || tipoEscala=='ida') ?'Ida' :'Volta'; }else{ tipoVueloFiltrar = ( (tipoEscala=="ida" || tipoEscala=='ida') || ( (tipoEscala=="vuelta" || tipoEscala=='volta') && vuelo.length==2) )?'Ida' :'Volta'; } }else{ tipoVueloFiltrar = 'Ida'; } if( !tipoVueloFiltrar )return []; var vueloFiltrarEscalas = null; if( vuelo.escalas )vueloFiltrarEscalas = vuelo else vueloFiltrarEscalas = tipoEscala=='ida'?vuelo[0]:vuelo.length==2?vuelo[1]:vuelo[0]; var escalasMostrarProximo = vueloFiltrarEscalas.escalas.filter(function(el){ return el.tipoVuelo==tipoVueloFiltrar; }); return escalasMostrarProximo; } /** * Función que devuelve la duración de un vuelo (pasa de minutos a horas y minutos) */ function duracionVuelo(minutos){ var horas = Math.floor(minutos/60); var mins = (minutos%60); return (horas>0?horas +'h':'')+(mins>0?' '+mins+'min':''); } /** * Función que devuelve el html de las maletas */ function htmlMaletas(maletas){ return maletas +' '; // var html = ''; // switch( maletas.toString() ){ // case '0': html += 'Sin maletas'; break; // case '1': html += maletas +' bagagem'; break; // default: html += maletas +' bagagens'; break; // } // return html; } /** * Función que devuelve el html de las maletas */ function htmlEscalas(escalas){ var html = ''; switch( escalas ){ case 0: html = 'direto'; // + ' '; break; case 1: html = '1 escala'; // + ' '; break; default: html = ''+ escalas +' escalas'; // + ' '; break; } return html; } function htmlPlazas(plazas){ if( !plazas )return ''; var html = ''; if( plazas==1 ){ html = plazas +' plaza'; }else if( plazas<9 ){ html = plazas +' plazas'; }else{ html = 'Há lugares'; } return html; } // Función que obtiene el vuelo de ida de un vuelo seleccionado function getVueloIda(vuelo){ return vuelo[0]; } // Función que obtiene el vuelo de vuelta de un vuelo seleccionado function getVueloVuelta(vuelo){ if( vuelo.length==2 )return vuelo[1]; else if( vuelo[0].tipoVuelo=='idaVuelta' )return vuelo[0]; return null; } /***** FUNCIONES DISPO DIA SIGUIENTE *****/ /** * Funcion que obtiene la dispo de hoteles del día siguiente a la dispo actual */ PIDIENDO_DISPO_DIA_SIGUIENTE = false; DISPO_HOTEL_DIA_SIGUIENTE = []; function obtenerDispoHotelDiaSiguiente(){ PIDIENDO_DISPO_DIA_SIGUIENTE = true; var diaOrig = $("#D1").val(); var mesAnoOrig = $("#MA1").val(); var vMesAnoOrig = mesAnoOrig.split('_'); var f = new Date(parseInt(vMesAnoOrig[1]), parseInt(vMesAnoOrig[0])-1, parseInt(diaOrig)); f.setDate(f.getDate()+1); // Obtenemos la dispo del dia siguiente urlPeticion = location.href.split('#')[0]; urlPeticion = urlPeticion.replace('D1='+diaOrig,'D1='+f.getDate()); urlPeticion = urlPeticion.replace('MA1='+mesAnoOrig,'MA1='+(f.getMonth()+1)+'_'+f.getFullYear()); urlPeticion = urlPeticion +'&aj=h&t='+ (new Date()).getTime(); $.ajax({ type: 'POST', url: urlPeticion, async: false, dataType: "json", success: function(data){ // Guardamos la dispo obtenida DISPO_HOTEL_DIA_SIGUIENTE = []; $.each(data,function(i,el){ if( el ){ if( i=='obj' )OBJ_BUSQUEDA_DIA_SIGUIENTE=el[0]; else if( typeof(el)=="object" )DISPO_HOTEL_DIA_SIGUIENTE.push(el); } }); // Guardamos el obj de la dispo $('#objBusquedaDiaSiguiente').val( OBJ_BUSQUEDA_DIA_SIGUIENTE ); // Actualizamos los datos seleccionados if( GESTOR_VUELOS ){ GESTOR_VUELOS.mostrarVueloSeleccionado('#datosVueloSeleccionado'); // Cambiamos la dispo si es necesario if( VUELO_SELECCIONADO[0].hotelDiaSiguiente )usarDispoDiaSiguiente(); } PIDIENDO_DISPO_DIA_SIGUIENTE = false; } }); } /* Funciones para intercambiar la dispo */ var MOSTRANDO_DISPO_DIA_SIGUIENTE = false; // Usar la dispo original function usarDispoOrig(){ // Cambiamos la dispo del hotel if( Paginar ){ // Cambios sólo para resultadosBusqueda.php arrayDatosHoteles = JSON.parse( JSON.stringify(DISPO_ORIG_HOTEL) ); objDatosBusqueda = OBJ_BUSQUEDA_ORIG; Paginar(1,$('#versionResultados').val(),1,0); } MOSTRANDO_DISPO_DIA_SIGUIENTE = false; // Actualizamos los datos del paquete seleccionado if( Paginar ){ // Cambios sólo para resultadosBusqueda.php actualizarHotelSeleccionadoUsarDipo(); }else{ // Cambios para detallesConDipos.php mostrarDatosSeleccionados(); if( $('#dispoFichaHotel .table').length==2 ){ $('#dispoFichaHotelDiaSiguiente' ).hide(); $('#dispoFichaHotelOrig' ).show(); } // Actualizamos el precio del resumen del paquete seleccionado con la opción más barata $('#precioReservaCompleta').html( $('#dispoFichaHotelOrig .precioMonedaEuro').html() ); } } function usarDispoDiaSiguiente(){ // Comprobamos que tenemos hoteles con la dispo del día siguiente if( !DISPO_HOTEL_DIA_SIGUIENTE || DISPO_HOTEL_DIA_SIGUIENTE.length==0 )return false; // Cambiamos la dispo del hotel if( Paginar ){ // Cambios sólo para resultadosBusqueda.php arrayDatosHoteles = JSON.parse(JSON.stringify(DISPO_HOTEL_DIA_SIGUIENTE)); objDatosBusqueda = OBJ_BUSQUEDA_DIA_SIGUIENTE; Paginar(1,"normal",1,0); } MOSTRANDO_DISPO_DIA_SIGUIENTE = true; // Actualizamos los datos del paquete seleccionado if( Paginar ){ // Cambios sólo para resultadosBusqueda.php actualizarHotelSeleccionadoUsarDipo(); }else{ // Cambios para detallesConDipos.php mostrarDatosSeleccionados(); if( $('#dispoFichaHotel .table').length==2 ){ $('#dispoFichaHotelDiaSiguiente' ).show(); $('#dispoFichaHotelOrig' ).hide(); } // Actualizamos el precio del resumen del paquete seleccionado con la opción más barata $('#precioReservaCompleta').html( $('#dispoFichaHotelDiaSiguiente .precioMonedaEuro').html() ); } } /* * Función que busca el hotel que tenemos actualmente seleccionado en la dispo del día siguiente */ function getPosiblesPreciosHotelSeleccinado(){ if( !HOTEL_SELECCIONADO )return null; var idHotel = HOTEL_SELECCIONADO.ID; var datosAloj = HOTEL_SELECCIONADO.habitaciones[0].alojamientos[0].DATOS; var precioOrig=0, precioAgenciaOrig=0; var precioDiaSiguitente=0, precioAgenciaDiaSiguitente=0; var hoteles = JSON.parse( JSON.stringify(DISPO_ORIG_HOTEL) ); for(var iH=0, nH=hoteles.length; iH1 ){ // Calculamos la distancia al hotel seleccionado var aeropuertosDistancia = []; $.each(filtrosDisponibles['aeropuertosLlegada'], function(iata, datos){ var datosAeropuerto = IATA_AEROPUERTO[iata]; var distancia = '-'; if( datosAeropuerto ){ var latVuelo = parseFloat( datosAeropuerto.latitud ); var longVuelo = parseFloat( datosAeropuerto.longitud ); var latHotel = parseFloat( HOTEL_SELECCIONADO.latitud ); var longHotel = parseFloat( HOTEL_SELECCIONADO.longitud ); distancia = harvestine( latVuelo, longVuelo, latHotel, longHotel ); datos.iata = iata; datos.distancia = distancia; datos.nombre = datosAeropuerto.name[0]; aeropuertosDistancia.push(datos); } }); if( aeropuertosDistancia.length>1 ){ // Ordenamos los hoteles por distancia aeropuertosDistancia.sort(function(a,b){ return a.distanciaSeleccione um dos seguintes aeroportos de destino: ' + '' + ''; popUpMesaje('', html); } } } } /* * Función que aplica la opción seleccionada del popup de multiaeropuerto */ function aplicarFiltroVuelosInicial(filtro, valor){ mostrarPestana('Vuelos'); if( valor=='' ){ $('li[id^='+ filtro +']').addClass( "active" ); $('input[name^='+ filtro +']').prop( "checked",0 ); $('#chkMismoAeropuerto2').prop( "checked",0 ); }else{ $('input[name^='+ filtro +']').prop( "checked",0 ); $('li[id^='+ filtro +']').removeClass( "active" ); $('input[name^='+ filtro + valor +']').prop( "checked",1 ); $('li[id^='+ filtro + valor +']').addClass( "active" ); $('#chkMismoAeropuerto2').prop( "checked",1 ); } GESTOR_VUELOS.aplicarFiltros(); GESTOR_VUELOS.setVueloSeleccionado( GESTOR_VUELOS.minPrecioVuelo() ); mostrarPestana('Hoteles'); $('div[id^=popupMesaje]').remove(); } /** * Función que muestra la cabecera de los detalles de las escalas de un vuelo */ function mostrarCabeceraEscalaDetallesVuelosHora(iEscala, escala,numeroEscalas){ var html = ''; html += '
'; html += ''; //version movil html += '
'; html += ''; html += ''; html += ''; html += ''; html += ''; html += ''; html += '
'; html += 'Tramo '+ iEscala+' '; html += ''+formatFechaDDMMYYYY(escala.fechaSalida)+''; html += '
'; html += '
'; html += '
'; return html; } /** * Funcion que muestra los datos de las escalas de un vuelo */ function mostrarEscalaDetallesVuelosHoraTable(escala){ var html = ''; html += '
'; html += ''; html += '
'; html += ''; html += ''; html += mostrarEscalaDetallesVuelosHora_movil(escala); html += ''; html += '
'; html += '
'; html += '
'; return html; } function mostrarEscalaDetallesVuelosHora(escala){ html = '\ \ \
'+ escala.lineaAerea +' '+ escala.IDLineaAerea + escala.numeroVuelo +'
'; if( escala.IDLineaAereaOperadora!=escala.IDLineaAerea){ html +='
Operado por: '+ escala.lineaAereaOperadora +'
' } html += '\ \ '+ escala.salidaOrigenCiudad +' ('+ escala.IDAeropuertoSalida +')\
\ '+ escala.horaSalida +'\ '+ (escala.terminalSalida?'
\ Terminal '+escala.terminalSalida+'':'') +'\ \ \ '+ duracionVuelo(escala.duracion) +'\ \ \ '+ escala.salidaDestinoCiudad +' ('+ escala.IDAeropuertoLlegada +')\
\ '+ escala.horaLlegada +''; if( escala.fechaLlegada!=escala.fechaSalida )html += ' (+1 dia/s)'; html += (escala.terminalLlegada?'
Terminal '+escala.terminalLlegada+'':''); html += '\ \ ' +escala.clase +'\
\ '+ escala.codigoTarifaBase +'\
\ \ '+ htmlMaletas( escala.numeroMaletas ) +'\ \ \ '; return html; } function mostrarEscalaDetallesVuelosHora_movil(escala){ var html = ''; html += ''; html += ''; html += ''+ escala.lineaAerea +''; html += '
'; html += ''+ escala.lineaAerea +' '+ escala.numeroVuelo +''; html += ''; html += ''; html += 'Saída:'; html += escala.salidaOrigenCiudad +' ('+ escala.IDAeropuertoSalida +')'; html += ', '+ (escala.terminalSalida!=''?escala.terminalSalida +',':''); html += ''+ escala.horaSalida +''; html += '
'; html += 'Chegada:'; html += escala.salidaDestinoCiudad +' ('+ escala.IDAeropuertoLlegada +')'; html += ', '+ (escala.terminalLlegada!=''?escala.terminalLlegada +',':''); html += ''+ escala.horaLlegada +''; if(escala.fechaLlegada!=escala.fechaSalida)html += '+1 dia/s'; html += '
'; html += escala.clase +', '+ htmlMaletas( escala.numeroMaletas ); html += '
'; html += ' '+ duracionVuelo(escala.duracion) +''; html += ''; html += ''; return html; } /** * Funcion que muestra los datos seleccionados (Vuelo, hotel) */ function mostrarDatosSeleccionados(){ var html = ''; html = '
'; $('#datosPaqueteSeleccionado').html(html); /* html += '
' + '
' + '
' + '
' + '
' + 'Preço final por pessoa' + ''; if( TIPO_CABECERA_AGENCIA=='Vuelo+Hotel' ){ html += ' (inclui taxas, custos de gestão e seguro obrigatório)' } html += '
' + '
' + '
'; if (IDMinorista!=17 || (IDMinorista==17 && UserAgencia)){ //Si no es click o está logueada html += '' + '
' + '
' + '
' + '
' + '
'; if( TIPO_CABECERA_AGENCIA=='Vuelo+Hotel' )html += '
' if( TIPO_CABECERA_AGENCIA=='Tren+Hotel' )html += '
' html += '
' // html += '
' // + '
' // + '
' // + '' // + '
' // + '
'; + '
' + '
' + '
'; $('#datosPaqueteSeleccionado').html(html); */ if( GESTOR_VUELOS ){ // Si hay un vuelo seleccionado (cambiar vuelo formulario reserva) if( typeof(VUELO_SELECCIONADO)!='undefined' && VUELO_SELECCIONADO ){ GESTOR_VUELOS.agruparVuelos(); var vueloIda = getVueloIda(VUELO_SELECCIONADO); var vueloVuelta = getVueloVuelta(VUELO_SELECCIONADO); GESTOR_VUELOS.selVueloHora('ida', vueloIda.mismoVueloIda, vueloVuelta.mismoVueloVuelta); GESTOR_VUELOS.mostrarSeleccionarVuelo('#divPestanaVuelos'); } GESTOR_VUELOS.mostrarVueloSeleccionado('#datosVueloSeleccionado'); mostrarResumenBusquedaVuelo('#resumenBusquedaVuelo'); vuelo = GESTOR_VUELOS.getVueloSeleccionado(); if( vuelo && hotel ){ vuelo = vuelo[0] var datosAeropuerto = IATA_AEROPUERTO[vuelo.iataSalidaDestino]; if( datosAeropuerto ){ var latVuelo = parseFloat( datosAeropuerto.latitud ); var longVuelo = parseFloat( datosAeropuerto.longitud ); var latHotel = parseFloat( hotel.latitud ); var longHotel = parseFloat( hotel.longitud ); var distancia = harvestine( latVuelo, longVuelo, latHotel, longHotel ); $('#distanciaAeropuertoHotel').html(' (Distância ao hotel: '+ distancia + ' km.)'); } } } if( GESTOR_TRENES ){ GESTOR_TRENES.mostrarSeleccionado('#datosTrenSeleccionado'); } // [PARCHE detallesConDispo.php] // Cuando estamos en detallesConDispo.php (no existe Paginar) y no hay un hotel seleccionado nos esperamos porque no tenemos el array con toda la dispo (DATOS_HOTELES) ya que es una dispo por hotel if( !Paginar && !HOTEL_SELECCIONADO )return; // Si hay un hotel seleccionado (cambiar hotel formulario reserva) if( HOTEL_SELECCIONADO )hotel = HOTEL_SELECCIONADO; else{ if( typeof(DATOS_HOTELES)=="undefined" || DATOS_HOTELES.length==0 )DATOS_HOTELES = JSON.parse( JSON.stringify(DISPO_ORIG_HOTEL) ); var hotel = null; for(var iHotelSel=0, nHotelSel=DATOS_HOTELES.length; iHotelSel' + 'Reservar' + ''); } // Mostramos el precio del paquete seleccionado actualizarPrecioCompleto(); } function actualizarPrecioCompleto(){ if( !$('#hotelSeleccionado').length )return false; var ocupacion=ADULTOS+NINOS+BEBES; var precioMostrar=getPrecioPaquete()/ocupacion; var htmlPrecio = ' '; var htmlPrecioMultirate = ''; if( CLASE_PRECIO.hayCambioMoneda() ){ htmlPrecioMultirate = CLASE_PRECIO.getPrecio(precioMostrar); htmlPrecio += ''+ CLASE_PRECIO.getPrecioPrincipal(precioMostrar) +''; htmlPrecio += ' ('+ CLASE_PRECIO.getPrecioSecundario(precioMostrar) +')'; }else{ htmlPrecioMultirate = CLASE_PRECIO.getPrecio(precioMostrar);; htmlPrecio += ''+ CLASE_PRECIO.getPrecio(precioMostrar) +''; } $('#precioReservaCompleta').html(htmlPrecio); $('#precioReservaCompletaLat').html(htmlPrecio); $('#precioReservaCompletaMultirate').html(htmlPrecioMultirate); } function confirmarCambioVuelo(tipo, mismoVueloIdaSel, mismoVueloVueltaSel){ selVueloHora(null, tipo, mismoVueloIdaSel, mismoVueloVueltaSel, false) $('#popupMesaje').remove(); } function getPathLogosAerolineas(aita, logosNombres){ var logosNombres = logosNombres || false; var rutaLogos = "https://cdn.veturis.com/vtw/vuelos/images/logosAerolineas/logos/"; var extension = ".png"; if(logosNombres=='nombre'){ rutaLogos = "https://cdn.veturis.com/vtw/vuelos/images/logosAerolineas/logosNombre/"; extension = ".gif"; } var logo = "https://cdn.veturis.com/vtw/vuelos/images/logosAerolineas/default.png"; if(logosNombres=='nombre'){ if(LOGOS_AEROLINEAS_NOMBRES[aita])logo = rutaLogos+aita+extension; }else{ if(LOGOS_AEROLINEAS[aita])logo = rutaLogos+aita+extension; } return location.protocol +'//'+ location.hostname + logo; } /** * Funcion que obtiene la posición del resumen lateral */ function anchoContainer(){ var ancho = 0; $('.container').each(function(iEl, el){ if( $(el).width()>ancho ){ ancho = $(el).width(); } }); return ancho; } function getPositionResumenLateral(){ $('#contenedorPrincipal').show(); $('#divDatosPaqueteSeleccionado').show(); $('#datosPaqueteSeleccionado').show(); var ancho = Math.round( ($(window).width() - anchoContainer())/2 -10); var alto = $(window).height(); var left = ancho + anchoContainer() + 18; var top = Math.round( $('#datosPaqueteSeleccionado').offset().top ); return{ ancho: ancho, alto: alto, left: left, top: top } } function comprobarMostrarResumenLateral(){ var posResumen = getPositionResumenLateral(); var ancho = posResumen.ancho; var alto = posResumen.alto; var left = posResumen.left; var top = posResumen.top; if( ancho<200 || alto<$('#resumenLateral').height() ){ $('#datosPaqueteSeleccionado').show(); $('#resumenLateral').hide(); }else{ $('#datosPaqueteSeleccionado').hide(); $('#resumenLateral').show(); } $('#datosPaqueteSeleccionado').width( anchoContainer() ); } /** * Función que muestra el resumen lateral */ function iniciarResumenLateral(){ var posResumen = getPositionResumenLateral(); $('#datosPaqueteSeleccionado').hide(); var ancho = posResumen.ancho; var alto = posResumen.alto; var left = posResumen.left; var top = posResumen.top; $('#resumenLateral').css({ "width": ancho+"px", "top": top+"px", "left": left+"px" }); $('#resumenLateral').attr("data-top", top); comprobarMostrarResumenLateral(); // Evento que coloca correctamente el resumen lateral $(document).bind("scroll",function(){ var div = $('#resumenLateral'); if( div.length ){ var top = parseInt( div.attr("data-top"), 10); if( top > $(document).scrollTop() ){ div.css({ "position": "absolute", "top": top +"px" }); }else{ div.css({ "position": "fixed", "top": "10px" }); } } var div = $('#datosPaqueteSeleccionado'); div.width( anchoContainer() ); var divPadre = div.parent(); divPadre.css("height",""); if( div.length ){ var top = parseInt( div.offset().top, 10); var topPadre = parseInt( divPadre.offset().top, 10); var resta=0; if ($('#resumenLateral:visible').length==0){ resta=400; } if( topPadre>$(document).scrollTop() - resta){ div.css({ "position": "relative", }); mostrarResumenPaquete(); }else{ div.css({ "position": "fixed", "top": "-1px" }); ocultarResumenPaquete(); } } }); $(window).bind("resize", function(){ $('#datosPaqueteSeleccionado').width( $('#resumenDispo').width() ); comprobarMostrarResumenLateral(); }); } function mostrarResumenPaquete(){ var div = $('#datosPaqueteSeleccionado'); if( div.length ){ var divPadre = div.parent(); divPadre.css("height",""); div.find('.detallesResumenHorizontal').show("fast"); div.find('hr').css("margin", "8px 0"); div.find('h5').css("margin-bottom", "10px"); div.find('resumenHorizontal').css({"padding":"", "margin":""}); div.find('#mostarOcultarDetallesPaquete').html( '' + ' OCULTAR OPÇÕES SELECIONADAS ' + '' ); } } function ocultarResumenPaquete(){ var div = $('#datosPaqueteSeleccionado'); if( div.length ){ var divPadre = div.parent(); if( div.find('.detallesResumenHorizontal:visible').length ){ divPadre.css( "height", (div.innerHeight() + ($(document).scrollTop()-divPadre.offset().top)) +"px" ); } div.find('.detallesResumenHorizontal').hide("fast", function(){ // setTimeout(function(){ var div = $('#datosPaqueteSeleccionado'); var divPadre = div.parent(); if( div.find('.detallesResumenHorizontal:visible').length ){ divPadre.css( "height", (div.innerHeight() + ($(document).scrollTop()-divPadre.offset().top)) +"px" ); } // },1); }); div.find('hr').css("margin", "0px"); div.find('h5').css("margin", "5px"); div.find('resumenHorizontal').css({"padding":"0px", "margin":"0px"}); div.find('#mostarOcultarDetallesPaquete').html( '' + ' MOSTRAR OPÇÕES SELECIONADAS ' + '' ); } } function mostrarOcultarResumenPaquete(){ var div = $('#datosPaqueteSeleccionado'); if( div.length ){ if( div.find('.fa-chevron-down').length )mostrarResumenPaquete(); else ocultarResumenPaquete(); } } /** * Función para cambiar los criterios de ordenación de los vuelos */ function ordenarPor(valor, orden){ if(typeof(GESTOR_VUELOS)!='undefined' && GESTOR_VUELOS)GESTOR_VUELOS.setOrden(valor, orden); if(typeof(GESTOR_TRENES)!='undefined' && GESTOR_TRENES)GESTOR_TRENES.setOrden(valor, orden); } function getPrecioPaquete(){ var precio = 0; if( typeof(HOTEL_SELECCIONADO)!="undefined" && HOTEL_SELECCIONADO ){ if( typeof(HOTEL_SELECCIONADO.habitaciones[0].alojamientos[0].precioAgencia)=="string" ){ precio += parseFloat( obtenerPrecio( (UserAgencia==1 && mostrarPVP=='0') ?HOTEL_SELECCIONADO.habitaciones[0].alojamientos[0].precioAgencia.replace(',','.') :HOTEL_SELECCIONADO.habitaciones[0].alojamientos[0].precio )); }else{ precio += obtenerPrecio( (UserAgencia==1 && mostrarPVP=='0') ?HOTEL_SELECCIONADO.habitaciones[0].alojamientos[0].precioAgencia :HOTEL_SELECCIONADO.habitaciones[0].alojamientos[0].precio ); } } if( typeof(TREN_SELECCIONADO)!="undefined" && TREN_SELECCIONADO ){ precio += getPrecioTrayecto( TREN_SELECCIONADO ); } if( typeof(VUELO_SELECCIONADO)!="undefined" && VUELO_SELECCIONADO ){ precio += getPrecioVuelo( VUELO_SELECCIONADO ); } precio += SEGURO_BASE_PRECIO_PASAJERO_AGENCIA * (ADULTOS+NINOS+BEBES); return parseFloat( (precio).toFixed(2) ); } function getPrecioPaquetePasajeros(){ var ocupacion=ADULTOS+NINOS+BEBES; return parseFloat( (getPrecioPaquete()/ocupacion).toFixed(2) ); } function seleccionarVueloPrecio(e, keyPrecio,seleccionar){ if( typeof(seleccionar)=="undefined" )seleccionar = true; if( !seleccionar ) return false; var tokenMismo = getMismoTokenPrecio(keyPrecio); if( tokenMismo.mismoVueloIda && (TIPO_VUELO=='ida' || tokenMismo.mismoVueloVuelta) ){ GESTOR_VUELOS.selVueloHora('ida', tokenMismo.mismoVueloIda, tokenMismo.mismoVueloVuelta, false); if( TIPO_CABECERA_AGENCIA=="Vuelos" ){ $('#divEstamosFlash').show(); $('#formReservarHV').submit(); }else{ mostrarDatosSeleccionados(); $('.flights-results-container .vueloSeleccionado').removeClass('vueloSeleccionado'); $('.flights-results-container button.btn-primary').html('Seleccionar'); $('#'+ keyPrecio +' input[type=radio]:checked').closest('ul').addClass('vueloSeleccionado'); $('#'+ keyPrecio +' button.btn-primary').html('Seleccionado'); } } } function getMismoTokenPrecio(keyPrecio){ var mismoVueloIda=null, mismoVueloVuelta=null; $( '#'+keyPrecio ).first().find('input[type=radio]:checked').each(function(i,el){ if( !mismoVueloIda ) mismoVueloIda = $(el).val(); else if( !mismoVueloVuelta ) mismoVueloVuelta = $(el).val(); }); return { mismoVueloIda: mismoVueloIda, mismoVueloVuelta: mismoVueloVuelta } } function seleccionarTarifaPopUp( token ){ var vuelo = HASH_VUELOS[token]; var flightData = $('#tarifasPopUp input[type=radio]:checked').first().attr('flight-data'); if( vuelo && flightData ){ flightData = JSON.parse( flightData ); actualizarObjeto(vuelo, flightData); switch( vuelo.tipoVuelo ){ case 'idaVuelta': VUELOS_IDA_VUELTA_ORIG.push(vuelo); break; case 'ida': VUELOS_IDA_ORIG.push(vuelo); break; case 'vuelta': VUELOS_VUELTA_ORIG.push(vuelo); break; } delete(GESTOR_VUELOS); GESTOR_VUELOS = new gestorVuelos(VUELOS_IDA_VUELTA_ORIG, VUELOS_IDA_ORIG, VUELOS_VUELTA_ORIG); GESTOR_VUELOS.setVueloSeleccionado([vuelo]); mostrarDatosSeleccionados(); GESTOR_VUELOS.mostrarSeleccionarVuelo( $('#divPestanaVuelos').length?'#divPestanaVuelos':'#divListaVuelos' ); } // GESTOR_VUELOS. $('#popupMesaje').remove(); GESTOR_VUELOS.selVueloHora('ida', vuelo.mismoVueloIda, vuelo.mismoVueloVuelta, false); if( TIPO_CABECERA_AGENCIA=="Vuelos" ){ $('#divEstamosFlash').show(); $('#formReservarHV').submit(); } } function seleccionarTarifaPopUpVue( vueloMultirate ){ if( TIPO_CABECERA_AGENCIA=="Vuelos" ){ $('#divEstamosFlash').show(); $('#formReservarHV').submit(); } } function actualizarObjeto(objAct, objDatos){ $.each(objDatos, function(key,val){ if( val!==null ){ if( typeof(val)=='object' ){ if( !objAct[key] )objAct[key] = JSON.parse(JSON.stringify( objDatos[key] )); actualizarObjeto(objAct[key], objDatos[key]) }else{ if( val ){ objAct[key] = val; } } } }); }