<?php require_once(APPPATH.'views/diy_tour/public/header.php');?>
<title>International Flights Search Result</title>
<meta name="keywords" content="china flights, china flight, flights china"/>
<meta name="description" content="internal air ticket availability for flights within China"/>
<link type="text/css" rel="stylesheet" href="/min/f=/css/bootstrap/css/flight.css,/css/bootstrap/css/jquery-ui-1.10.0.custom.css,/css/bootstrap/css/jquery.suggest.css" />
<?php require_once(APPPATH.'views/diy_tour/public/nav.php');?>

<div id="content" class="container-fluid">
  <div class="row">
    
    <div class="col-sm-5 hidden-xs">
      <div class="col-xs-24 btn-lg"></div>
      <h4><legend>Filter</legend></h4>
      <div class="col-xs-24 nopadding flight_filter">
        <strong>Stops</strong> 
        <div class="checkbox" data-flightitem="stop">
          <label>
            <input type="checkbox" value="Nonstop" class="checkbox_stop"> Nonstop
          </label>
          <label>
            <input type="checkbox" value="1 stop" class="checkbox_stop"> 1 Stop
          </label>
        </div>
      </div>
      <legend></legend>
      <div class="col-xs-24 nopadding flight_filter <?php if(empty($airline_arr[0])) echo 'hidden';?>">
        <strong>Airline</strong> 
        <div class="checkbox" data-flightitem="airline">
          <?php foreach ($airline_arr as $a) { ?>
            <label>
              <input type="checkbox" class="checkbox_airline" value="<?php echo translate_lang('AirlineList',$a); ?>"> <?php echo translate_lang('AirlineList',$a); ?>
            </label>
          <?php } ?>
        </div>
      </div>
      <legend></legend>
      <div class="col-xs-24 nopadding flight_filter">
        <strong>Departure time</strong> 
        <div class="checkbox" data-flightitem="departuretime">
          <label>
            <input type="checkbox" value="6" class="checkbox_departure"> 00:00-06:00
          </label>
          <label>
            <input type="checkbox" value="12" class="checkbox_departure"> 06:00-12:00
          </label>
          <label>
            <input type="checkbox" value="18" class="checkbox_departure"> 12:00-18:00
          </label>
          <label>
            <input type="checkbox" value="24" class="checkbox_departure"> 18:00-24:00
          </label>
        </div>
      </div>
      <legend></legend>
      <div class="col-xs-24 nopadding flight_filter">
        <strong>Arrival time</strong> 
        <div class="checkbox" data-flightitem="arrivaltime">
          <label>
            <input type="checkbox" value="6" class="checkbox_arrival"> 00:00-06:00
          </label>
          <label>
            <input type="checkbox" value="12" class="checkbox_arrival"> 06:00-12:00
          </label>
          <label>
            <input type="checkbox" value="18" class="checkbox_arrival"> 12:00-18:00
          </label>
          <label>
            <input type="checkbox" value="24" class="checkbox_arrival"> 18:00-24:00
          </label>
        </div>
      </div>
    </div>
    <div class="col-sm-19" id="flight_container" style="background:#f3f5f7;margin-top:15px;">
      <div class="col-xs-24 btn-sm"></div>

      <div class="col-sm-24 flight_search_pagebox hidden-xs" style="background:#fff;">
      <form class="flight_search_form" role="form" method="post" action="/index.php/thirdparty/flight/flight/search">
          <!-- Single button -->
          <div class="btn-group col-sm-3 nopadding-L">
            <button type="button" class="btn btn-default dropdown-toggle form-control" data-toggle="dropdown" style="font-size: 12px;padding-left: 3px;padding-right: 3px;">
              <span class="round_trip_btn"><?php if($return_date) { echo 'Round trip';}else{ echo 'One way'; } ?></span> <span class="caret"></span>
            </button>
            <ul class="dropdown-menu" role="menu">
              <li><a href="javascript:void(0)" onclick="$('.round_trip_btn').text($(this).text());$('#return_date').val('');">One way</a></li>
              <li><a href="javascript:void(0)" onclick="$('.round_trip_btn').text($(this).text());">Round trip</a></li>
            </ul>
          </div>

        <div class="form-group col-xs-5 nopadding-L flight_auto_complete" id="auto-complete">
          <div class="input-group flight_inputgroup" id="from_city_box">
            <span class="input-group-addon">From:</span>
            <input type="text" class="form-control" id="form_city" name="form_city" value="<?php echo $form_city; ?>">
            <input type="hidden" id="form_city_code" name="form_city_code" value="<?php echo $form_city_code; ?>">
          </div>
        </div>
        <div class="form-group col-xs-5 nopadding-L flight_auto_complete" id="auto-complete2">
          <div class="input-group flight_inputgroup" id="to_city_box">
            <span class="input-group-addon">To:</span>
            <input type="text" class="form-control" id="to_city" name="to_city" value="<?php echo $to_city; ?>">
            <input type="hidden" id="to_city_code" name="to_city_code" value="<?php echo $to_city_code; ?>">
          </div>
        </div>
        <div class="form-group col-xs-4 nopadding-L">
          <input type="text" class="form-control" id="departing_date" name="flight_date" placeholder="Departing" value="<?php echo $flight_date; ?>">
        </div>
        <div class="form-group col-xs-4 nopadding-L">
          <input type="text" class="form-control" id="return_date" name="return_date" placeholder="Return date" value="<?php echo $return_date; ?>">
        </div>
        <button type="submit" class="btn btn-danger col-sm-3" onclick="loading_img();">Search!</button>
      </form>
</div>


      <div class="col-xs-24 flight_sort bg-success">
        <span><strong>Sort by:</strong></span>
        <a class="sort_trigger" href="javascript:void(0);" data-ordername="DepartureTime" data-ordertype="ASC" >Departure</a> 
        <a class="sort_trigger" href="javascript:void(0);" data-ordername="FlightDuration" data-ordertype="ASC" >Flight Duration</a> 
        <a class="sort_trigger" href="javascript:void(0);" data-ordername="ArrivalTime" data-ordertype="ASC" >Arrival</a> 
        <a class="sort_trigger" href="javascript:void(0);" data-ordername="Price" data-ordertype="ASC" >Price</a> 
        <form id="form_flight_sort" name="form_flight_sort" method="post">
          <input type="hidden" name="from_city" value="<?php echo $form_city; ?>">
          <input type="hidden" name="to_city" value="<?php echo $to_city; ?>">
          <input type="hidden" name="form_city_code" value="<?php echo $form_city_code; ?>">
          <input type="hidden" name="to_city_code" value="<?php echo $to_city_code; ?>">
          <input type="hidden" name="flight_date" value="<?php echo $flight_date; ?>">
          <input type="hidden" name="return_date" value="<?php echo $return_date; ?>">
          <input type="hidden" id="order_name" name="order_name" value="<?php echo $order_name; ?>">
          <input type="hidden" id="order_type" name="order_type" value="<?php echo $order_type; ?>">
          <input type="hidden" id="route_rearch_token" name="route_rearch_token" value="">
        </form>
      </div>
      <div class="col-xs-24 text-center hidden"><img src="http://www.diychinatours.com/image/loading.gif" id="search-loading-img"></div>
      <div id="flight_list_container">
        <table class="table table-condensed" id="flight_list">        
          <?php 
          foreach ($flight_group as $flight) { 
            if (!empty($flight)) {
            $first_price=array_shift($flight->PriceList->Price);
            $first_priceUnitID=$first_price->PriceUnitID;
          ?>
          <tbody 
            class="flight_item" 
            data-stop="<?php echo $flight->flight_type;?>" 
            data-airline="<?php echo translate_lang('AirlineList',$flight->AirlineName); ?>" 
            data-departuretime="<?php echo date('G.i',$flight->TakeoffDateTime); ?>" 
            data-arrivaltime="<?php echo date('G.i',$flight->ArrivalDateTime); ?>" 
            style="border:none;border-bottom:15px solid #f3f5f7;background:#fff;">
          <tr>
            <td>
              <p style="line-height:30px;">
                <span class="pull-left">
                  <img style="width:30px;padding-right:5px;" src="/image/airline_logos/<?php echo $flight->AirlineIcon;?>.png" >
                </span>
                <span class="pull-left" ><?php echo translate_lang('AirlineList',$flight->AirlineName); ?></span>
              </p>
              <p class="flight_details"><a class="toggle_flight_detail text-info" href="javascript:void(0)" >Flight details<span class="caret"></span></a></p>
            </td>
            <td><?php echo date('H:i',$flight->TakeoffDateTime); ?><br> <?php echo $flight->DeparturePortCode; ?></td>
            <td><?php echo date('H:i',$flight->ArrivalDateTime); ?></br> <?php echo $flight->ArrivalPortCode; ?></td>
            <td><?php //echo $flight->Duration ?>  <?php echo $flight->flight_type;?></td>
            <td><?php echo translate_lang($flight_price['PriceUnitID'.$first_priceUnitID]->web_CabinClass); if(is_numeric($first_price->seat_count) && $first_price->seat_count<10){echo '<br><span class="text-warning">('.$first_price->seat_count.' seats left)</span>';} ?></td>
            <td><strong class="text-danger">$<?php echo $this->currency->GetSiteMoney($flight_price['PriceUnitID'.$first_priceUnitID]->PriceInfoList->PriceInfo->OriginalPriceDetail->SalePrice); ?></strong></td>
            <td width="85">
              <button class="btn btn-danger btn-sm flight_order_btn" data-route="<?php echo $first_price->RouteSearchToken;?>">Book</button>
            </td>
          </tr>
          <tr class="flight_detail" style="display:none;">
            <td colspan="7" style="border:none;">
              <?php foreach ($flight->FlightSegmentList->FlightSegment as $key_air => $plane) { ?>
                <?php if($key_air>0 && $plane->OrigDestSeqID==$flight->FlightSegmentList->FlightSegment[($key_air-1)]->OrigDestSeqID) {?>
                    <div class="col-xs-24 bg-info">
                      <div class="col-sm-2 hidden-xs" style="border-top:1px dashed green;margin-top:9px;"></div>
                      <div class="col-sm-12 col-xs-24 text-center" style="border: 1px dashed green;border-radius: 10px;"> Stopover in <strong><?php echo $flight_list['FlightID'.$plane->FlightID]->DepartureCity->CityNameEN;?></strong>  <?php $stopover = ($flight_list['FlightID'.$plane->FlightID]->TakeoffDateTime-$flight_list['FlightID'.$flight->FlightSegmentList->FlightSegment[($key_air-1)]->FlightID]->ArrivalDateTime)/60; echo floor($stopover/60).'h'.($stopover%60).'m'; ?> </div>
                      <div class="col-sm-3 hidden-xs" style="border-top:1px dashed green;margin-top:9px;"></div>
                    </div>
                <?php } ?>
                <?php if($plane->OrigDestSeqID == '2' && $flight->FlightSegmentList->FlightSegment[($key_air-1)]->OrigDestSeqID=='1') {?>
                    <div class="col-xs-24 btn-lg"></div>
                <?php } ?>
                <div class="col-xs-24 flight_detail_box bg-info">
                  <p>
                      <?php echo translate_lang('AirlineList',$flight_list['FlightID'.$plane->FlightID]->Carrier->AirlineName).' '; ?>
                      <span><?php echo $flight_list['FlightID'.$plane->FlightID]->FlightNumber.' '.$flight_list['FlightID'.$plane->FlightID]->EquipmentCode; ?></span>
                  </p>
                  <div class="col-xs-24 nopadding">
                    <div class="col-sm-2 hidden-xs nopadding" style="width:50px !important;padding-top: 18px !important;">
                      <span class="text-muted"><?php echo floor($flight_list['FlightID'.$plane->FlightID]->Duration/60).'h'.($flight_list['FlightID'.$plane->FlightID]->Duration%60).'m'; ?></span>
                    </div>
                    <div class="col-xs-1 nopadding" style="width:15px !important;"><img src="/css/images/flight_stop.png"></div>
                    <div class="col-xs-18 text-muted">
                      <p style="line-height:12px;height:35px;">
                        <span><strong><?php echo date('D M d H:i',$flight_list['FlightID'.$plane->FlightID]->TakeoffDateTime); ?></strong></span>
                        <?php $flight_port_nameEN=ucfirst(strtolower($flight_list['FlightID'.$plane->FlightID]->DepartureAirport->PortNameEN));?>
                        <?php if(strtolower($flight_port_nameEN)!=strtolower($flight_list['FlightID'.$plane->FlightID]->DepartureCity->CityNameEN)) echo '<span>'.$flight_list['FlightID'.$plane->FlightID]->DepartureCity->CityNameEN.'</span>';?>
                        <span><?php echo $flight_port_nameEN.' International Airport '.$flight_list['FlightID'.$plane->FlightID]->DepartureAirport->Terminal;?></span> 
                      </p>
                      <p style="line-height:12px;">
                        <span><strong><?php echo date('D M d H:i',$flight_list['FlightID'.$plane->FlightID]->ArrivalDateTime);?></strong></span>
                        <?php $ArrivalPortNameEN = ucfirst(strtolower($flight_list['FlightID'.$plane->FlightID]->ArrivalAirport->PortNameEN));?>
                        <span><?php if(strtolower($ArrivalPortNameEN)!=strtolower($flight_list['FlightID'.$plane->FlightID]->ArrivalCity->CityNameEN)) echo $flight_list['FlightID'.$plane->FlightID]->ArrivalCity->CityNameEN;?></span>
                        <span><?php echo $ArrivalPortNameEN.' International Airport '.$flight_list['FlightID'.$plane->FlightID]->ArrivalAirport->Terminal;?></span>
                      </p>
                    </div>
                  </div>
                </div>
              <?php } ?>
            </td>
          </tr>
          <?php foreach ($flight->PriceList->Price as $k=>$price) { ?>
          <tr class="price_detail hidden">
            <td colspan="4" style="border:none;"></td>
            <td style="border:none;"><?php echo translate_lang($flight_price['PriceUnitID'.$price->PriceUnitID]->web_CabinClass);if(is_numeric($price->seat_count) && $price->seat_count<10){echo '<br><span class="text-warning">('.$price->seat_count.' seats left)</span>';} ?></td>
            <td style="border:none;"><strong class="text-danger">$<?php echo $this->currency->GetSiteMoney($flight_price['PriceUnitID'.$price->PriceUnitID]->PriceInfoList->PriceInfo->OriginalPriceDetail->SalePrice); ?> </strong></p></td>
            <td style="border:none;"><button class="btn btn-danger btn-sm flight_order_btn" data-route="<?php echo $price->RouteSearchToken;?>">Book</button></td>
          </tr>
          <?php } ?>
          <tr>
            <td colspan="5" style="border:none;"></td>
            <td style="border:none;"><span class="text-danger">$<?php echo $this->currency->GetSiteMoney($flight_price['PriceUnitID'.$first_priceUnitID]->PriceInfoList->PriceInfo->OriginalPriceDetail->Tax+$flight_price['PriceUnitID'.$first_priceUnitID]->PriceInfoList->PriceInfo->OriginalPriceDetail->FuelSurCharge); ?></span> taxes</td>
            <td style="border:none;">
              <?php if (count($flight->PriceList->Price)>0) { ?>
                <a class="toggle_price" href="javascript:void(0);" data-flag="false">More Price<span class="caret"></span></a>
              <?php } ?>
            </td>
          </tr>
          
        </tbody>
        <?php }} ?>
        
      </table>
      </div>
      
    </div>
  </div>
</div>

<div id="hot_city">
  <div id="top_destination" class="panel panel-default hidden" style="border:none; top: 34px !important;left: 0px !important;position: absolute;z-index: 10;width: 350px;background:none;">
    <div class="col-xs-24 nopadding">
    <div class="panel-body" style="padding-top:0;border:1px solid #ddd;-moz-box-shadow:3px 5px 5px #969696;
        -webkit-box-shadow:3px 5px 5px #969696;
       box-shadow:3px 5px 5px #969696;background:#fff;">
      <div style="padding:5px 0;margin-bottom:5px;margin-top:8px;"><strong>Top Destination</strong><a class="pull-right" href="javascript:void(0);" onclick="$(this).parents('#top_destination').remove();">X</a></div>
      <table class="table table-bordered" style="margin-bottom:0;">
        <tbody id="hot_city_td">
          <tr>
            <td><a href="javascript:void(0);" data-code="BJS">Beijing</a></td>
            <td><a href="javascript:void(0);" data-code="HKG">Hong Kong</a></td>
            <td><a href="javascript:void(0);" data-code="TYO">Tokyo</a></td>
          </tr>
          <tr>
            <td><a href="javascript:void(0);" data-code="SHA">Shanghai</a></td>
            <td><a href="javascript:void(0);" data-code="NYC">New York</a></td>
            <td><a href="javascript:void(0);" data-code="LAX">Los Angeles</a></td>
          </tr>
          <tr>
            <td><a href="javascript:void(0);" data-code="SIA">Xian</a></td>
            <td><a href="javascript:void(0);" data-code="HNL">Honolulu</a></td>
            <td><a href="javascript:void(0);" data-code="LON">London</a></td>
          </tr>
          <tr>
            <td><a href="javascript:void(0);" data-code="CAN">Guangzhou</a></td>
            <td><a href="javascript:void(0);" data-code="PAR">Paris</a></td>
            <td><a href="javascript:void(0);" data-code="SYD">Sydney</a></td>
          </tr>
          <tr>
            <td><a href="javascript:void(0);" data-code="KWL">Guilin</a></td>
            <td><a href="javascript:void(0);" data-code="SIN">Singapore</a></td>
            <td><a href="javascript:void(0);" data-code="YVR">Vancouver</a></td>
          </tr>
        </tbody>
      </table>      
    </div>
    </div>
  </div>
</div>

<?php require_once(APPPATH.'views/diy_tour/public/footer.php');?>

<script type="text/javascript" src="/min/f=/css/bootstrap/js/jquery-ui-1.10.0.custom.min.js,/css/bootstrap/js/jquery.suggest.js"></script>    
<script type="text/javascript">
$(document).ready(function()
{
  $('#departing_date,#return_date').datepicker({
        inline: true,
        minDate: "<?php echo date("m/d/Y",strtotime("+3 day")); ?>",
        dateFormat: 'mm/dd/yy'
  });
  $("#form_city").suggest("/index.php/thirdparty/flight/flight/get_flight_city_list",{
        container: '#auto-complete',
        onSelect: function() {},
        selectClass: '',
        matchClass: 'active',
        resultsClass: 'list-unstyled',
        hiddenInput: '#form_city_code'
  });
  $("#to_city").suggest("/index.php/thirdparty/flight/flight/get_flight_city_list",{
        container: '#auto-complete2',
        onSelect: function() {},
        selectClass: '',
        matchClass: 'active',
        resultsClass: 'list-unstyled',
        hiddenInput: '#to_city_code'
  });
  $("#return_date").change(function(){
    if ($(this).val()!='') {
      $(".round_trip_btn").text('Round trip');
    }else{
      $(".round_trip_btn").text('One way');
    }
  });

  //航班详情显示隐藏
  $("#flight_container").on("click",".toggle_flight_detail",function(){
    $(this).parents('tbody').children('.flight_detail').eq(0).toggle();
    if ($(this).children('.caret').length>0) {
      $(this).children('.caret').removeClass('caret').addClass('caret_up');
    }else{
      $(this).children('.caret_up').removeClass('caret_up').addClass('caret');
    }
  });
  
  //价格列表显示隐藏
  $("#flight_container").on("click",".toggle_price",function(){
    var price_toggle_flag=$(this).attr('data-flag');
    if (price_toggle_flag=='false') {
      $(this).parents('tbody').children('.price_detail').removeClass('hidden');
      $(this).attr('data-flag','true');
      $(this).children('.caret').removeClass('caret').addClass('caret_up');
    }else{
      $(this).parents('tbody').children('.price_detail').addClass('hidden');
      $(this).attr('data-flag','false');
      $(this).children('.caret_up').removeClass('caret_up').addClass('caret');
    }
  });
  //航班排序
  $(".sort_trigger").click(function(){
    $("#flight_list").fadeOut();
    loading_img();
    $("#order_name").val($(this).attr('data-ordername'));
    $("#order_type").val($(this).attr('data-ordertype'));
    var data=$("#form_flight_sort").serialize();
    $("#flight_list_container").load("/index.php/thirdparty/flight/flight/search #flight_list",data,function(){
      filter_flight();
      hide_loading_img();
      $("#flight_list").fadeIn();
    });
  });
  
  //帅选航班  是否中转、航空公司、起飞时间、到达时间
  $(".flight_filter>.checkbox>label>input").click(function(){
    filter_flight();
  });

  $("#content").on("click",".flight_order_btn",function(){
    var route_rearch_token=$(this).attr('data-route');
    $("#route_rearch_token").val(route_rearch_token);
    var url='/index.php/thirdparty/flight/flight/order';
    $("#form_flight_sort").attr('action',url);
    $("#form_flight_sort").submit();
  });

  //热门城市提示
  var input_box='';
  $("#form_city,#to_city").click(function() {
    var html=$("#hot_city").html();
    var parentbox=$(this).parent('div').attr('id');
    $(html).appendTo("#"+parentbox);
    $("#"+parentbox+">#top_destination").removeClass('hidden');
    input_box=$(this).attr('id');
    if (input_box=='form_city') {
      var parentbox=$("#to_city").parent('div').attr('id');
      $("#"+parentbox+">#top_destination").remove();
    }else if(input_box=='to_city'){
      var parentbox=$("#form_city").parent('div').attr('id');
      $("#"+parentbox+">#top_destination").remove();
    }
  });
  $("#form_city,#to_city").keyup(function(){
    var parentbox=$(this).parent('div').attr('id');
    $("#"+parentbox+">#top_destination").remove();
  });
  $(".flight_search_form").on('click','#hot_city_td a',function() {
    $("#"+input_box+"_code").val($(this).attr('data-code'));
    $("#"+input_box).val($(this).text());
    $(this).parents('#top_destination').remove();
  });
});
function filter_flight() {
  var stop_arr=new Array();
  var airline_arr=new Array();
  var departure_arr=new Array();
  var arrival_arr=new Array();
  var stop_num=air_num=dep_num=arrival_num=airline_num=0;
  //选中的中转次数
  $(".checkbox_stop").each(function(){
    if ($(this).attr('checked')) {
      stop_arr[stop_num]=$(this).val();
      stop_num++;
    };
  });
  //选中的起飞时间
  $(".checkbox_departure").each(function(){
    if ($(this).attr('checked')) {
      departure_arr[dep_num]=$(this).val();
      dep_num++;
    };
  });
  //选中的到达时间
  $(".checkbox_arrival").each(function(){
    if ($(this).attr('checked')) {
      arrival_arr[arrival_num]=$(this).val();
      arrival_num++;
    };
  });
  //选中的航空公司
  $(".checkbox_airline").each(function(){
    if ($(this).attr('checked')) {
      airline_arr[airline_num]=$(this).val();
      airline_num++;
    };
  });
  //拼接过滤条件
  $(".flight_item").each(function(){
    //过滤条件有“中转”
    var stop_flag=false;
    if(stop_arr.length==0) {
      stop_flag=true;
    }else{
      for(var i=0;i<stop_arr.length;i++){
        if (i==0 && $(this).attr('data-stop')==stop_arr[i]) {
          stop_flag=true;
        }else if(i>0 && (stop_flag || $(this).attr('data-stop')==stop_arr[i])){
          stop_flag=true;
        }
      }
    }
    //过滤条件有“航空公司”
    var air_flag=false;
    if(airline_arr.length==0) {
      air_flag=true;
    }else{
      for(var i=0;i<airline_arr.length;i++){
        if (i==0 && $(this).attr('data-airline')==airline_arr[i]) {
          air_flag=true;
        }else if(i>0 && (air_flag || $(this).attr('data-airline')==airline_arr[i])){
          air_flag=true;
        }
      }
    }
    //过滤条件中有起飞时间
    var dep_flag=false;
    if(departure_arr.length==0) {
      dep_flag=true;
    }else{
      for(var i=0;i<departure_arr.length;i++){
        var lg = Number(departure_arr[i]);
        var sm = Number(departure_arr[i])-6;
        var departuretime = Number($(this).attr('data-departuretime'));
        if (i==0 && (departuretime>sm && departuretime<=lg)) {
          dep_flag=true;
        }else if(i>0 && (dep_flag || (departuretime>sm && departuretime<=lg))){
          dep_flag=true;
        }
      }
    }

    //过滤条件中有到达时间
    var arrival_flag=false;
    if(arrival_arr.length==0) {
      arrival_flag=true;
    }else{
      for(var i=0;i<arrival_arr.length;i++){
        var lg = Number(arrival_arr[i]);
        var sm = Number(arrival_arr[i])-6;
        var arrivaltime = Number($(this).attr('data-arrivaltime'));
        if (i==0 && (arrivaltime>sm && arrivaltime<=lg)) {
          arrival_flag=true;
        }else if(i>0 && (arrival_flag || (arrivaltime>sm && arrivaltime<=lg))){
          arrival_flag=true;
        }
      }
    }

    if (stop_flag && dep_flag && arrival_flag && air_flag) {
      $(this).show();
    }else{
      $(this).hide();
    }

  });

};
 function loading_img(){
    $("#flight_list_container").hide();
    $("#search-loading-img").parent().removeClass('hidden');
 }
 function hide_loading_img(){
    $("#search-loading-img").parent().addClass('hidden');
    $("#flight_list_container").show();
 }
</script>