﻿var AirMotorUC = new (function () {

    /* Atributo setado no .aspx */
    this.PesqIncAereo = undefined;

    this.IsRoundTrip = true;
    this.MultiDestination = true;

    this.Adults = 0;
    this.Children = 0;
    this.Baby = 0;

    this.Origin = "";
    this.Destination = "";
    this.CabinFilter = "";
    this.NonStop = false;
    this.StartTimeOut = 0;
    this.EndTimeOut = 0;
    this.StartTimeIn = 0;
    this.EndTimeIn = 0;

    this.CiaCodeList = [];

    this.Origins = [];
    this.Destinations = [];
    this.Dates = [];
    this.StartTime = [];
    this.EndTime = [];
    this.CabinType = [];
    this.CiaCode = [];

    this.OptionDatePicker = {
        showAnim: '',
        numberOfMonths: 2,
        showButtonPanel: true,
        dateFormat: 'dd/mm/yy',
        minDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate()), //Seta como data minima a data atual
        maxDate: new Date(new Date().getFullYear() + 1, new Date().getMonth(), new Date().getDate()), //Seta como data minima a data atual
        dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado', 'Domingo'],
        dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S', 'D'],
        dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'],
        monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
        monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'],
        nextText: 'Próximo',
        prevText: 'Anterior',
        closeText: 'Fechar',
        currentText: 'Mês Atual',
        ShowCurrentRule: function (drawDates, inst) {

            var currentMonth = (new Date()).getMonth() + 1;
            var currentYear = (new Date()).getFullYear();

            if (drawDates.any(currentMonth + "/" + currentYear)) {
                return false;
            }
            else {
                return true;
            }
        }
    };


    this.InputOriginDestination;

    this.ItemsForSearch = 5;
    this.ItemsStartedForSearch = 3;

    this.OnSearch = function () { }
    this.OnSearchLocationComplete = function () { }

    this.Initialize = function () {

        $("#txtDataIda").datepicker(Clone_Object(AirMotorUC.OptionDatePicker));
        $("#txtDataVolta").datepicker(Clone_Object(AirMotorUC.OptionDatePicker));

        $("#dtF1").datepicker(Clone_Object(AirMotorUC.OptionDatePicker));
        $("#dtF2").datepicker(Clone_Object(AirMotorUC.OptionDatePicker));
        $("#dtF3").datepicker(Clone_Object(AirMotorUC.OptionDatePicker));
        $("#dtF4").datepicker(Clone_Object(AirMotorUC.OptionDatePicker));
        $("#dtF5").datepicker(Clone_Object(AirMotorUC.OptionDatePicker));

        $("#imgDataIda").click(function () {
            $("#txtDataIda").datepicker("show");
        });
        $("#imgDataVolta").click(function () {
            $("#txtDataVolta").datepicker("show");
        });

        $("#imgData1").click(function () {
            $("#dtF1").datepicker("show");
        });
        $("#imgData2").click(function () {
            $("#dtF2").datepicker("show");
        });
        $("#imgData3").click(function () {
            $("#dtF3").datepicker("show");
        });
        $("#imgData4").click(function () {
            $("#dtF4").datepicker("show");
        });
        $("#imgData5").click(function () {
            $("#dtF5").datepicker("show");
        });

        if (AirMotorUC.PesqIncAereo == 'GLOBAL') {

            var pesqIncConfig = {

                IsCity: true,
                IsAirport: true,
                HasIata: true,
                HasHotelCode: false,

                clientCache: Global.LocationsCache,
                controllers: {
                    locationsController: Global.LocationsController
                }
            }

            $("#txtOrigem").focus().locationsFinder(pesqIncConfig);
            this.InputOriginDestination = "txtOrigem";
            $("#txtOrigem").keyup(AirMotorUC.OnSearchLocationComplete);

            $("#txtDestino").focus().locationsFinder(pesqIncConfig);
            this.InputOriginDestination = "txtDestino";
            $("#txtDestino").keyup(AirMotorUC.OnSearchLocationComplete);

            $("#originTextF1").focus().locationsFinder(pesqIncConfig);
            $("#DestinationTextF1").focus().locationsFinder(pesqIncConfig);
            $("#originTextF2").focus().locationsFinder(pesqIncConfig);
            $("#DestinationTextF2").focus().locationsFinder(pesqIncConfig);
            $("#originTextF3").focus().locationsFinder(pesqIncConfig);
            $("#DestinationTextF3").focus().locationsFinder(pesqIncConfig);
            $("#originTextF4").focus().locationsFinder(pesqIncConfig);
            $("#DestinationTextF4").focus().locationsFinder(pesqIncConfig);
            $("#originTextF5").focus().locationsFinder(pesqIncConfig);
            $("#DestinationTextF5").focus().locationsFinder(pesqIncConfig);
        }
        else if (AirMotorUC.PesqIncAereo == 'B2W')
        {
            $("#txtOrigem").focus().autocomplete(cities);
            this.InputOriginDestination = "txtOrigem";
            $("#txtOrigem").keyup(AirMotorUC.OnSearchLocationComplete);

            $("#txtDestino").focus().autocomplete(cities);
            this.InputOriginDestination = "txtDestino";
            $("#txtDestino").keyup(AirMotorUC.OnSearchLocationComplete);

            $("#originTextF1").focus().autocomplete(cities);
            $("#DestinationTextF1").focus().autocomplete(cities);
            $("#originTextF2").focus().autocomplete(cities);
            $("#DestinationTextF2").focus().autocomplete(cities);
            $("#originTextF3").focus().autocomplete(cities);
            $("#DestinationTextF3").focus().autocomplete(cities);
            $("#originTextF4").focus().autocomplete(cities);
            $("#DestinationTextF4").focus().autocomplete(cities);
            $("#originTextF5").focus().autocomplete(cities);
            $("#DestinationTextF5").focus().autocomplete(cities);
        } 
        else 
        {
            $("#txtOrigem").pesqInc("Air");

            $("#txtDestino").pesqInc("Air");

            $("#originTextF1").pesqInc("Air");
            $("#DestinationTextF1").pesqInc("Air");
            $("#originTextF2").pesqInc("Air");
            $("#DestinationTextF2").pesqInc("Air");
            $("#originTextF3").pesqInc("Air");
            $("#DestinationTextF3").pesqInc("Air");
            $("#originTextF4").pesqInc("Air");
            $("#DestinationTextF4").pesqInc("Air");
            $("#originTextF5").pesqInc("Air");
            $("#DestinationTextF5").pesqInc("Air");
        }

        $('#remakeSearch_btnSearch').click(function () {
            openPopunder();
            AirMotorUC.OnSearch();

        });

        $('#remakeSearch_btnSearchMulti').click(function () {
            openPopunder();
            AirMotorUC.OnSearch();
        });

        if (!isB2B()) {
            var url = window.location.toString();
            var aAux = url.split("?");

            if (aAux.length == 1) {
                CreateHintBoxy($("#remakeSearch"), "#spanRefacaPesquisa", false, "absolute", true, true);
            }
        }
    }

    this.Show = function () {
        $("#remakeSearch").show();
        $(".info_fechar").hide();
    }

    this.SearchRules = function (sender) {

        var arrMensagem = [];
        var today = new Date();
        var today_year = today.getFullYear();
        var today_mes = today.getMonth();
        var today_dia = today.getDate();


        if ($("#chkSomenteIda").is(':checked')) {
            $("#lblDataVolta").css("visibility", "hidden");
            $("#txtDataVolta").css("visibility", "hidden");
            $("#spnDtRetorno").css("visibility", "hidden");
            $("#imgDataVolta").css("visibility", "hidden");
            $("#drpEndTime").css("visibility", "hidden");
            $("#spnHorarioVolta").css("visibility", "hidden");
            $("#tabMulti").css("display", "none");
            $("#tabIdaVolta").css("display", "block");
            $("#tabIdaVolta").css("float", "left");
            $("#add-trajeto").css("display", "none");
            $("#remove-trajeto").css("display", "none");
            $("#remakeSearch_content").css("height", "255px");
            $("#remakeSearch_content").css("*height", "255px");
        }

        if ($("#chkIdaVolta").is(':checked')) {
            $("#lblDataVolta").css("visibility", "visible");
            $("#txtDataVolta").css("visibility", "visible");
            $("#spnDtRetorno").css("visibility", "visible");
            $("#imgDataVolta").css("visibility", "visible");
            $("#drpEndTime").css("visibility", "visible");
            $("#spnHorarioVolta").css("visibility", "visible");
            $("#tabMulti").css("display", "none");
            $("#tabIdaVolta").css("display", "block");
            $("#tabIdaVolta").css("float", "left");
            $("#add-trajeto").css("display", "none");
            $("#remove-trajeto").css("display", "none");
            $("#remakeSearch_content").css("height", "255px");
            $("#remakeSearch_content").css("*height", "255px");
        }

        if ($("#chkMulti").is(':checked')) {

            var ListAirtrips = null;

            if ($("#tabMulti").css("display") == "none") {
                ListAirtrips = AirTripView.LoadAirTrips();
                if (ListAirtrips == null || ListAirtrips.length == 0) {
                    AirTripView.AddAirTrips();
                    AirTripView.AddAirTrips();
                    AirTripView.AddAirTrips();
                } else {

                    $("#remakeSearch_content").css("height", "705px").css("*height", "705px");
                }
            }

            $("#tabMulti").css("display", "block");
            $("#tabIdaVolta").css("display", "none");

            if (ListAirtrips != null) {
                if (ListAirtrips.length == 1) {
                    $("#add-trajeto").css("display", "block");
                    $("#remove-trajeto").css("display", "none");
                }
                else if (ListAirtrips.length == 5) {
                    $("#add-trajeto").css("display", "none");
                    $("#remove-trajeto").css("display", "block");
                    $("#remakeSearch_content").css("height", "725px").css("*height", "725px");

                }
                else {
                    $("#add-trajeto").css("display", "block");
                    if (ListAirtrips.length > 3)
                        $("#remove-trajeto").css("display", "block");
                }
            }
        }

        var nErros = AirMotorUC.ItemsForSearch;

        if (sender == undefined || sender == null) {
            if (!$("#chkMulti").is(':checked')) {
                if ($("#txtOrigem").val() == "")
                    arrMensagem.push("Preencha o campo Origem e tente novamente.");

                if ($("#txtDestino").val() == "")
                    arrMensagem.push("Preencha o campo Destino e tente novamente.");

                if ($("#txtOrigem").val() == $("#txtDestino").val())
                    arrMensagem.push("A Origem não pode ser igual ao Destino.");

                if ($("#txtDataIda").val() == "")
                    arrMensagem.push("Preencha a Data de Ida e tente novamente.");

                if ($("#txtDataVolta").val() == "" && !$("#chkSomenteIda").is(':checked'))
                    arrMensagem.push("Preencha a Data de Volta ou marque a opção Somente Ida para continuar.");
            } else {
                for (var i = 1; i <= AirMotorUC.ItemsForSearch; i++) {

                    if (($("#originTextF" + i).val() == "" && $("#DestinationTextF" + i).val() == "" && $("#dtF" + i).val() == "")) {
                        nErros--;
                    } else {
                        if ($("#originTextF" + i).val() == "")
                            arrMensagem.push("Trajeto " + i + ": Preencha o campo Origem e tente novamente.");

                        if ($("#DestinationTextF" + i).val() == "")
                            arrMensagem.push("Trajeto " + i + ": Preencha o campo Destino e tente novamente.");

                        if ($("#originTextF" + i).val() == $("#DestinationTextF" + i).val())
                            arrMensagem.push("Trajeto " + i + ": A Origem não pode ser igual ao Destino.");

                        if ($("#dtF" + i).val() == "")
                            arrMensagem.push("Trajeto " + i + ": Preencha a Data e tente novamente.");

                    }
                }
            }
        }

        if (nErros == 0) {
            arrMensagem.push("Preencha os dados para efetuar a busca");
        }

        if (!$("#chkSomenteIda").is(':checked')) {
            $("#lblDataVolta").css("visibility", "visible");
            $("#txtDataVolta").css("visibility", "visible");
            $("#spnDtRetorno").css("visibility", "visible");
            $("#imgDataVolta").css("visibility", "visible");
            $("#drpEndTime").css("visibility", "visible");
            $("#spnHorarioVolta").css("visibility", "visible");

            if ($("#txtDataIda").val() != "" && $("#txtDataVolta").val() != "")



                if ($("#txtDataIda").datepicker("getDate") > $("#txtDataVolta").datepicker("getDate")) {
                    $("#txtDataVolta").val($("#txtDataIda").val());
                    if (sender == undefined || sender == null)
                        arrMensagem.push("Preencha a Data de Ida maior que a Data de Volta.");
                }


            if ($("#txtDataIda").val() != "") {




                var dataIda = $("#txtDataIda").datepicker("getDate");
                dataIda = new Date(dataIda.getTime() + (1000 * 60 * 60 * 23 + (1000 * 60 * 59)));

                if (dataIda <= (new Date())) {
                    arrMensagem.push("A data de volta não pode ser menor que a data de ida.");
                    $("#txtDataIda").datepicker("setDate", (new Date()));
                }
            }

            if ($("#txtDataIda").val() != "")
                if ($("#txtDataIda").datepicker("getDate") > (new Date(today_year + 1, today_mes, today_dia)) || $("#txtDataVolta").datepicker("getDate") > (new Date(today_year + 1, today_mes, today_dia))) {
                    arrMensagem.push("A pesquisa deve ser inferior a 1 ano");
                    $("#txtDataIda").datepicker("setDate", (new Date(today_year + 1, today_mes, today_dia)));
                }

        }

        if ((parseInt($("#drpQtdADT").val()) + parseInt($("#drpQtdCHD").val()) + parseInt($("#drpQtdINF").val())) > 9) {
            arrMensagem.push("Algumas companhias aéreas não permitem a compra acima de 9 passagens em um mesmo pedido. Favor adquirir as passagens em dois pedidos diferentes ou entrar em contato com a Central de Vendas pelo telefone 4003-9888.");
            $("#drpQtdADT").val(1);
            $("#drpQtdCHD").val(0);
            $("#drpQtdINF").val(0);
        }


        if ($("#drpQtdADT").val() < $("#drpQtdINF").val()) {
            arrMensagem.push("O número de adultos deve ser maior ou igual ao número de bebês.");
            $("#drpQtdINF").val($("#drpQtdADT").val());
        }

        if (arrMensagem.length > 0) {
            //thisView.ShowMessage(strMensagem);
            var strMensagem = "";
            for (var iMsg = 0; iMsg < arrMensagem.length; iMsg++) {
                strMensagem += arrMensagem[iMsg];
                strMensagem += "\n";
            }
            alert(strMensagem);
            return false
        }
        else
            return true;

    }

    this.ApplyInBoundCalendarMinDate = function (idObject, index) {
        if (idObject != undefined && idObject.toUpperCase().indexOf("DTF") >= 0) {
            $("#dtF" + index).datepicker("option", "minDate", $("#" + idObject).datepicker("getDate"));
        } else {
            $("#txtDataVolta").datepicker("option", "minDate", $("#txtDataIda").datepicker("getDate"));
        }
    }

    this.Update = function () {
        $("#txtOrigem").autocomplete(cities);
        $("#txtDestino").autocomplete(cities);
    }

    this.ShowMoreTrips = function () {
        var ultimo = 0;
        for (var i = 1; i <= AirMotorUC.ItemsForSearch; i++) {
            if ($("#tabTrip" + i).css("display") == "none") {
                ultimo = i;
                break;
            }
        }

        $("#titTrip" + ultimo).css("display", "block");
        $("#tabTrip" + ultimo).css("display", "block");
        AirMotorUC.ClearTrips(ultimo);
    }

    this.HideMoreTrips = function () {
        var ultimo = 0;
        for (var i = 5; i >= 0; i--) {
            if ($("#tabTrip" + i).css("display") == "block") {
                ultimo = i;
                break;
            }
        }

        $("#titTrip" + ultimo).css("display", "none");
        $("#tabTrip" + ultimo).css("display", "none");

        AirMotorUC.ClearTrips((ultimo - 1));
    }

    this.ShowStartedTrips = function () {
        for (var i = 1; i <= AirMotorUC.ItemsForSearch; i++) {
            if (i < AirMotorUC.ItemsStartedForSearch) {
                $("#titTrip" + i).css("display", "block");
                $("#tabTrip" + i).css("display", "block");
            } else {
                $("#titTrip" + i).css("display", "none");
                $("#tabTrip" + i).css("display", "none");
            }
        }
        AirMotorUC.ClearTrips(AirMotorUC.ItemsStartedForSearch);
    }

    this.ClearTrips = function (ultimo) {
        if (ultimo > AirMotorUC.ItemsStartedForSearch) {
            $("#remove-trajeto").css("display", "block");
        } else {
            $("#remove-trajeto").css("display", "none");
        }

        if (ultimo == AirMotorUC.ItemsForSearch) {
            $("#add-trajeto").css("display", "none");
        } else {
            $("#add-trajeto").css("display", "block");
        }

        if (ultimo <= AirMotorUC.ItemsStartedForSearch) {
            $("#remakeSearch_content").css("height", "535px");
            $("#remakeSearch_content").css("*height", "545px");
        } else {
            $("#remakeSearch_content").css("height", "775px");
            $("#remakeSearch_content").css("*height", "775px");
        }
    }

    this.ResetData = function () {
        AirMotorUC.IsRoundTrip = true;
        AirMotorUC.MultiDestination = true;

        AirMotorUC.Adults = 0;
        AirMotorUC.Children = 0;
        AirMotorUC.Baby = 0;

        AirMotorUC.Origin = "";
        AirMotorUC.Destination = "";
        AirMotorUC.CabinFilter = "";
        AirMotorUC.NonStop = false;
        AirMotorUC.StartTimeOut = 0;
        AirMotorUC.EndTimeOut = 0;
        AirMotorUC.StartTimeIn = 0;
        AirMotorUC.EndTimeIn = 0;

        AirMotorUC.CiaCodeList = [];

        AirMotorUC.Origins = [];
        AirMotorUC.Destinations = [];
        AirMotorUC.Dates = [];
        AirMotorUC.StartTime = [];
        AirMotorUC.EndTime = [];
        AirMotorUC.CabinType = [];
        AirMotorUC.CiaCode = [];
    }

    this.LoadData = function () {
        var nErros = AirMotorUC.ItemsForSearch;

        AirMotorUC.ResetData();

        if ($("#chkMulti").is(':checked')) {

            AirMotorUC.IsRoundTrip = false;
            AirMotorUC.MultiDestination = true;

            var arrCiaCode = [];
            for (var i = 1; i <= AirMotorUC.ItemsForSearch; i++) {

                arrCiaCode = [];
                var dataViagem = $("#dtF" + i).val();
                var destinoViagem = $("#DestinationTextF" + i).val();
                var origemViagem = $("#originTextF" + i).val();

                if (!origemViagem && !destinoViagem && !dataViagem) {
                    nErros--;
                } else {

                    if (origemViagem)
                        AirMotorUC.Origins.push(origemViagem);

                    if (destinoViagem)
                        AirMotorUC.Destinations.push(destinoViagem);

                    if (dataViagem) {
                        AirMotorUC.Dates.push(StringToDateValues(dataViagem));
                    }

                    AirMotorUC.StartTime.push($("#hrInicioF" + i).val());
                    AirMotorUC.EndTime.push($("#hrInicioF" + i).val());
                    AirMotorUC.CabinType.push($("#drpClassF" + i).val());

                    if ($("#drpCiaCodeF" + i).val().indexOf(",") >= 0) {
                        arrCiaCode = $("#drpCiaCodeF" + i).val().split(",");
                    }
                    else {
                        arrCiaCode.push($("#drpCiaCodeF" + i).val());
                    }

                    AirMotorUC.CiaCode.push(arrCiaCode);
                    AirMotorUC.CiaCodeList.push(arrCiaCode);
                }
            }
        }
        else {

            AirMotorUC.IsRoundTrip = !$("#chkSomenteIda").attr("checked");
            AirMotorUC.MultiDestination = false;

            AirMotorUC.Origin = $("#txtOrigem").val().replaceAll("(", "--").replaceAll(")", "---");
            AirMotorUC.Destination = $("#txtDestino").val().replaceAll("(", "--").replaceAll(")", "---");

            if (AirMotorUC.IsRoundTrip) {
                var hOrigins = AirMotorUC.Origin + "|" + AirMotorUC.Destination
                var hDestinations = AirMotorUC.Destination + "|" + AirMotorUC.Origin

                AirMotorUC.Origins = hOrigins.split("|");
                AirMotorUC.Destinations = hDestinations.split("|");
            }
            // Somamos 2 horas nas datas do request pois o fuso tira uma hora
            var dataIda = $("#txtDataIda").val();

            AirMotorUC.Dates.push(StringToDateValues(dataIda));

            var dataVolta = $("#txtDataVolta").val();
            if (dataVolta)
                AirMotorUC.Dates.push(StringToDateValues(dataVolta));

            AirMotorUC.CabinFilter = $("#selCabin").val();
            AirMotorUC.NonStop = $("#chkSemParada").attr("checked");

            AirMotorUC.StartTimeOut = $("#drpStartTime").val();
            AirMotorUC.EndTimeOut = $("#drpStartTime").val();

            AirMotorUC.StartTimeIn = $("#drpEndTime").val();
            AirMotorUC.EndTimeIn = $("#drpEndTime").val();
        }

        AirMotorUC.Adults = $("#drpQtdADT").val();
        AirMotorUC.Children = $("#drpQtdCHD").val();
        AirMotorUC.Baby = $("#drpQtdINF").val();

        if ($("#drpCia").val().indexOf(",") >= 0) {
            AirMotorUC.CiaCodeList = $("#drpCia").val().split(",");
            AirMotorUC.CiaCode = $("#drpCia").val().split(",");
        }
        else {
            AirMotorUC.CiaCodeList.push($("#drpCia").val());
            AirMotorUC.CiaCode.push($("#drpCia").val());
        }
    }

    this.SetValues = function (searchParameter) {
        if (searchParameter.MultiDestination) {
            $("#chkSomenteIda").attr("checked", !searchParameter.MultiDestination);
            $("#chkMulti").attr("checked", searchParameter.MultiDestination);

            $("#drpQtdADT").val(searchParameter.Adults);
            $("#drpQtdCHD").val(searchParameter.Children);
            $("#drpQtdINF").val(searchParameter.Baby);

            $("#chkSemParada").attr("checked", searchParameter.NonStop);

            for (var i = 0; i < searchParameter.Origins.length; i++) {
                var j = i + 1;
                $("#dtF" + j).datepicker("setDate", DateValuesToDate(searchParameter.Dates[i]));
                $("#dtF" + j).val(FormatSimpleDateValues(searchParameter.Dates[i]))
                $("#DestinationTextF" + j).val(searchParameter.Destinations[i].toString());
                $("#originTextF" + j).val(searchParameter.Origins[i].toString());
                $("#hrInicioF" + j).val(searchParameter.StartTime[i].toString());
                $("#drpCiaCodeF" + j).val(searchParameter.CiaCode[i][0].toString());
                $("#tabTrip" + j).css("display", "block");
                $("#titTrip" + j).css("display", "block");
            }
            if ($("#tabTrip4").css("display") == "block") {
                $("#remakeSearch_content").css("height", "775px");
                $("#remakeSearch_content").css("*height", "775px");
                $("#tabTrip5").css("display", "block");
                $("#titTrip5").css("display", "block");
            }
        }
        else {
            $("#chkSomenteIda").attr("checked", !searchParameter.IsRoundTrip);

            $("#txtOrigem").val(searchParameter.Origin);
            $("#txtDestino").val(searchParameter.Destination);

            if (searchParameter.Dates.length > 0 && searchParameter.Dates[0] != undefined) {
                $("#txtDataIda").datepicker("setDate", DateValuesToDate(searchParameter.Dates[0]));
                $("#txtDataIda").val(FormatSimpleDateValues(searchParameter.Dates[0]))
            }
            if (searchParameter.Dates.length > 1 && searchParameter.Dates[1] != undefined) {
                $("#txtDataVolta").datepicker("setDate", DateValuesToDate(searchParameter.Dates[1]));
                $("#txtDataVolta").val(FormatSimpleDateValues(searchParameter.Dates[1]))
            }

            $("#drpQtdADT").val(searchParameter.Adults);
            $("#drpQtdCHD").val(searchParameter.Children);
            $("#drpQtdINF").val(searchParameter.Baby);

            $("#chkSemParada").attr("checked", searchParameter.NonStop);

            $("#drpStartTime").val(searchParameter.StartTimeOut);
            $("#drpEndTime").val(searchParameter.StartTimeIn);

            $("#selCabin").val(searchParameter.CabinFilter);
        }

        $("#NumberADTs").val(searchParameter.Adults);
        $("#NumberCHDs").val(searchParameter.Children);
        $("#NumberINFs").val(searchParameter.Baby);
    }
})();

