var info_vuelo = null;
var info_hotel = null;
var info_hotel_full = null;

function procesar_info_vuelo(respuesta) {
    info_vuelo = respuesta;
    //respuesta.VxlTxRS.OTATxList[0].OTATx[0].OTA_AirLowFareSearchRS_1[0].PricedItineraries;
    $("#contenedor_resultados").setTemplateURL('./templates/vuelos/priced.html');
    $("#contenedor_resultados").show();
    $("#contenedor_galeria_principal").hide();
    $("#contenedor_resultados").processTemplate(respuesta.VxlTxRS.OTATxList[0]);
    $('#buscando_vuelos').jqmHide();
}

function procesar_info_hotel(data) {
    info_hotel = data;
    $("#contenedor_resultados").show();
    $("#contenedor_galeria_principal").hide();
    $("#contenedor_resultados").setTemplateURL('./templates/hoteles/res_busqueda_tourico.html');
    $("#contenedor_resultados").processTemplate(data.TWS_HotelList);
    $('#buscando_hoteles').jqmHide();
}

function detalle_hotel(HotelCode, CodProvider) {
    $("#info_hotel_completo").dialog({ bgiframe: false,
        height: 500, width: 500, modal: false,
        overlay: {
            backgroundColor: '#FFFFFF',
            opacity: 1
        }
    }
                );
    $.getJSON("hoteles/cargar_info_hotel.aspx", { CodProvider: CodProvider, HotelCode: HotelCode }, function(respuesta) {
        info_hotel_full = respuesta;
        $("#info_hotel_completo").show();
        $("#info_hotel_completo").setTemplateURL('./templates/hoteles/hotel_completo.html');
        $("#info_hotel_completo").processTemplate(respuesta.TWS_HotelDetails.Hotel[0]);
    });

}

//activar las casillas de las edades de los niņos segun el numero de habitacion
function activar_edades_ninos(rn) {
    cantidad_ninos = parseInt($('#hotel_room' + rn + '_chd').val());

    if (parseInt($('#hotel_room' + rn + '_chd').val()) != 0)
        $('#div_room' + rn + '_ch_age').show();
    else
        $('#div_room' + rn + '_ch_age').css("display", "none");

}

function params2json(d) {
    if (d.length <= 0) {
        return "{}";
    }
    var json = "{";
    var data = d;
    var parejas = new Array();
    parejas = data.split('&');
    for (var i = 0; i < parejas.length; i++) {
        var info = new Array();
        info = parejas[i].split('=');
        json = json + "\"" + info[0] + "\":\"" + info[1] + "\",";
    }
    json = json.substring(0, json.length - 1);
    json = json + "}";
    return json;
}



