﻿ function CallFlightBack()
         {
               //定义并取值
               var fromcityid=$("#FromCityId").val();
               var tocityid=$("#ToCityId").val();
               var flighttype=$("#Flight_Type").val();
               var fromcitytext=$("#FromCityId option[@selected]").text()
               var tocitytext=$("#ToCityId option[@selected]").text()
                   
                 $("[@id=ready1]").remove();
                 $("#load").show(); 
                 $.ajax({
                        type: "get",
                        dataType: "json",
                        url: "/jquery/ashx/flight.ashx",
                        data: "RequestType=1&pageIndex=1&PageCount=30&FromCityID="+fromcityid +"&Flight_Type="+flighttype+"&ToCityId="+tocityid+"&OrderByStr=City_Name",
                        success: function(data){
                                 if (data.DataCounts=="0") //如果返回记录数为0
                                 {
                                     alert("没有查询到有关航班，请重新选择筛选条件查询！")
                                     $("#load").hide(); // 隐藏loading
                                     return false;
                                 }
                                 else
                                 {
                                      var datastr = data.Table;
                                      $.each(datastr, function(i, n){
                                        var row = $("#temptr1").clone();
                                        if  (fromcityid !="0" && tocityid !="0") //同时选择2项
                                        {
                                         row.find("#temptd1").html("<font color=#ff0000>●</font>" + fromcitytext + "-" + tocitytext +"");
                                        }
                                        else
                                        {
                                          if ( tocityid !="0") //只选抵达城市
                                          {
                                            row.find("#temptd1").html("<font color=#ff0000>●</font> "+n.City_Name+"-" + tocitytext + ""); 
                                          }
                                          else
                                          {
                                           row.find("#temptd1").html("<font color=#ff000000>●</font>"+n.City_Name+"出发"); 
                                          }
                                        } 
                                        $.ajax({ 
                                                type: "get",
                                                dataType: "text",
                                                url: "/jquery/ashx/flight.ashx",
                                                data: "RequestType=2&FromCityId="+n.City_ID+"&Flight_Type="+flighttype+"&ToCityId="+tocityid+"",
                                                success: function(data){
                                                            row.find("#FlightList").html(data) //取得该城市的机票列表
                                                            tb_init('a.thickbox, area.thickbox, input.thickbox'); //重新载入tb_init,以便可实现thickbox的弹出浏览图片效果
                                                          }
                                                     });         
                                        row.attr("id","ready1");
                                        row.appendTo("#datas1"); 
                                        });  
                                 }
                              $("[@id=temptr1]").hide();
                              $("[@id=ready1]").show(); 
                              $("#load").hide(); 
                              
                           }
                     }); 
                }
                $(document).ready(function(){
                   CallFlightBack() 
                    $("#SubmitButton").click(function() { 
                        CallFlightBack();
                     });
                })