﻿document.write('<iframe id="AptSelFrm" name="AptSelFrm" frameborder="0" src="../ClientCtrl/AptSel.htm"  style="display:none;position:absolute;z-index:110"></iframe>');

var aryAirports = [
["AKU", "阿克苏", "Akesu", "阿克苏温宿"],
["AAT", "阿勒泰", "Altay", "阿勒泰"],
["AKA", "安康", "Ankang", "安康五里"],
["AQG", "安庆", "Anqing", "安庆"],
["AOG", "鞍山", "Anshan", "鞍山"],
["AVA", "安顺", "Anshun", "安顺黄果树机场"],
["AYN", "安阳", "Anyang", "安阳"],
["BSD", "保山", "Baoshan", "保山"],
["BAV", "包头", "Baotou", "包头"],
["BHY", "北海", "Beihai", "北海"],
["PEK", "北京", "Beijing", "北京首都"],
["NAY", "北京南苑", "Beijing", "北京南苑"],
["BFU", "蚌埠", "Bengbu", "蚌埠"],
["CGQ", "长春", "Changchun", "长春龙嘉"],
["CGD", "常德", "Changde", "常德"],
["BPX", "昌都", "Changdou", "昌都邦达机场"],
["CNI", "长海", "Changhai", "长海"],
["CSX", "长沙", "Changsha", "长沙黄花"],
["LCX", "连城", "LianChen", "连城"],
["CIH", "长治", "Changye", "长治玉村"],
["CZX", "常州", "Changzhou", "常州奔牛"],
["CHG", "朝阳", "Chaoyang", "朝阳"],
["CCC", "潮州", "Chaozhou", "潮州机场"],
["CTU", "成都", "Chengdu", "成都双流"],
["CIF", "赤峰", "Chifeng", "赤峰"],
["CKG", "重庆", "Chongqing", "重庆江北"],
["DAX", "达县", "Dachuan", "达县河市坝"],
["DLU", "大理", "Dali", "大理"],
["DLC", "大连", "Dalian", "大连周水子"],
["DDG", "丹东", "Dandong", "丹东浪头"],
["DQA", "大庆", "Daqing", "大庆"],
["DAT", "大同", "Datong", "大同"],
["DIG", "迪庆", "Diqing", "迪庆香格里拉"],
["DOY", "东营", "Dongying", "东营"],
["DNH", "敦煌", "Dunhuang", "敦煌"],
["ENH", "恩施", "Enshi", "恩施"],
["DSN", "鄂尔多斯", "Eerduoshi", "鄂尔多斯"],
["FUO", "佛山", "Foshan", "佛山"],
["FUG", "阜阳", "Fuyang", "阜阳"],
["FYN", "富蕴", "Fuyun", "富蕴可可托海"],
["FOC", "福州", "Fuzhou", "福州长乐"],
["KOW", "赣州", "Ganzhou", "赣州"],
["GOQ", "格尔木", "Golmud", "格尔木"],
["GYS", "广元", "Guangyuan", "广元"],
["GHN", "广汉", "Guanghan", "广汉"],
["CAN", "广州", "Guangzhou", "广州白云"],
["KWL", "桂林", "Guilin", "桂林两江"],
["KWE", "贵阳", "Guiyang", "贵阳龙洞堡"],
["HAK", "海口", "Haikou", "海口美兰"],
["HLD", "海拉尔", "HaiLar", "海拉尔东山"],
["HMI", "哈密", "Hami", "哈密"],
["HDG", "邯郸", "Handan", "邯郸机场"],
["HGH", "杭州", "Hangzhou", "杭州萧山"],
["HZG", "汉中", "Hanzhong", "汉中西关"],
["HRB", "哈尔滨", "Harbin ", "哈尔滨阎家岗"],
["HFE", "合肥", "Hefei", "合肥骆岗"],
["HEK", "黑河", "Heihe", "黑河"],
["HNY", "衡阳", "Hengyang", "衡阳"],
["HTN", "和田", "Hetian", "和田"],
["HET", "呼和浩特", "Hohhot", "呼和浩特白塔"],
["TXN", "黄山", "Huangshan", "黄山屯溪"],
["HYN", "台州", "Taizhou", "台州路桥"],
["HYN", "黄岩", "Huangyan", "台州路桥"],
["HUZ", "徽州", "Huizhou", "徽州"],
["JMU", "佳木斯", "Jiamusi", "佳木斯"],
["KNC", "吉安", "Ji'an", "吉安"],
["JGN", "嘉峪关", "Jiayuguan", "嘉峪关"],
["JIL", "吉林", "Jilin", "吉林二台子"],
["TNA", "济南", "Jinan", "济南遥墙"],
["JDZ", "景德镇", "Jingdezhen", "景德镇"],
["JNG", "济宁", "Jining", "济宁"],
["JJN", "晋江", "Jinjiang", "泉州晋江"],
["SHS", "荆州", "Jingzhou", "荆州沙市机场"],
["MIG", "绵阳", "Jinyang", "绵阳南郊"],
["JNZ", "锦州", "Jinzhou", "锦州小岭子"],
["JIU", "九江", "Jiujiang", "九江"],
["CHW", "酒泉", "Jiuquan", "酒泉"],
["JZH", "九寨黄龙", "Jiuzhai", "九寨黄龙"],
["KRY", "克拉玛依", "Karamay", "克拉玛依"],
["KHG", "喀什", "Kashi", "喀什"],
["KRL", "库尔勒", "Korla ", "库尔勒"],
["KMG", "昆明", "Kunming", "昆明巫家坝"],
["KCA", "库车", "Kuqa", "库车"],
["LHW", "兰州", "Lanzhou", "兰州中川"],
["LXA", "拉萨", "Lasa", "拉萨贡嘎"],
["LYG", "连云港", "Lianyungang", "连云港白塔阜"],
["LJG", "丽江", "Lijiang", "丽江"],
["LNJ", "临沧", "Lincang", "临沧机场"],
["LXI", "林西", "Linxi", "林西"],
["LYI", "临沂", "Linyi", "临沂"],
["LZH", "柳州", "Liuzhou", "柳州白莲"],
["LYA", "洛阳", "Luoyang", "洛阳北郊"],
["LUZ", "庐山", "Lushan", "庐山"],
["LZO", "泸州", "Luzhou", "泸州兰田坝"],
["LUM", "芒市", "Mangshi", "芒市"],
["NZH", "满洲里", "Manzhouli", "满洲里"],
["MXZ", "梅县", "Meixian", "梅县"],
["MIG", "绵阳", "Mianyang", "绵阳机场"],
["MDG", "牡丹江", "Mudanjiang", "牡丹江海浪"],
["KHN", "南昌", "Nanchang", "南昌昌北"],
["NAO", "南充", "Nanchong", "南充"],
["NKG", "南京", "Nanjing", "南京禄口"],
["NNG", "南宁", "Nanning", "南宁吴墟"],
["NTG", "南通", "Nantong", "南通兴东"],
["NNY", "南阳", "Nanyang", "南阳姜营"],
["NGB", "宁波", "Ningbo", "宁波栎社"],
["PZI", "攀枝花", "Panzhihua", "攀枝花保安营"],
["IQM", "且末", "Qiemo", "且末"],
["TAO", "青岛", "Qingdao", "青岛流亭"],
["IQN", "庆阳", "Qingyang", "庆阳"],
["SHP", "秦皇岛", "Qinhuangdao", "秦皇岛山海关"],
["NDG", "齐齐哈尔", "Qiqihar", "齐齐哈尔三家子"],
["JUZ", "衢州", "Quzhou", "衢州"],
["SYX", "三亚", "Sanya", "三亚凤凰"],
["SHA", "上海", "Shanghai", "上海虹桥"],
["PVG", "上海浦东", "ShanghaiPudong", "上海浦东"],
["SWA", "汕头", "Shantou", "汕头外砂"],
["SHS", "沙市", "Shashi", "沙市"],
["SHE", "沈阳", "Shenyang", "沈阳桃仙"],
["SZX", "深圳", "Shenzhen", "深圳宝安"],
["SJW", "石家庄", "Shijiazhuang", "石家庄正定"],
["SYM", "思茅", "Simao", "思茅"],
["SZV", "苏州", "Suzhou", "苏州"],
["TCG", "塔城", "Tacheng", "塔城"],
["TYN", "太原", "Taiyuan", "太原武宿"],
["TSN", "天津", "Tianjin", "天津滨海"],
["TNH", "通化", "Tonghua", "通化"],
["TGO", "通辽", "Tongliao", "通辽"],
["TEN", "铜仁", "Tongren", "铜仁大兴"],
["HLH", "乌兰浩特", "Ulanhot", "乌兰浩特"],
["URC", "乌鲁木齐", "Urumqi", "乌鲁木齐地窝铺"],
["WXN", "万县", "Wanzhou", "万县梁平"],
["WEF", "潍坊", "Weifang", "潍坊"],
["WEH", "威海", "Weihai", "威海大水泊"],
["WNZ", "温州", "Wenzhou", "温州永强"],
["WUA", "乌海", "Wuhai", "乌海机场"],
["WUH", "武汉", "Wuhan", "武汉天河"],
["WUX", "无锡", "Wuxi", "无锡"],
["WUS", "武夷山", "Wuyishan", "武夷山"],
["WUZ", "梧州", "Wuzhou", "梧州"],
["XMN", "厦门", "Xiamen", "厦门高崎"],
["XIY", "西安", "Xian", "西安咸阳"],
["XFN", "襄樊", "Xiangfan", "襄樊刘集"],
["XIC", "西昌", "Xichang", "西昌青山"],
["XIL", "锡林浩特", "Xilinhot", "锡林浩特"],
["XEN", "兴城", "Xingcheng", "兴城"],
["XIN", "兴宁", "Xingning", "兴宁"],
["XNN", "西宁", "Xining", "西宁曹家堡"],
["JHG", "西双版纳", "XiShuangBanNa", "西双版纳景洪嘎洒"],
["XUZ", "徐州", "Xuzhou", "徐州观音"],
["ENY", "延安", "Yan'an", "延安"],
["YNZ", "盐城", "Yancheng", "盐城"],
["YNJ", "延吉", "Yanji", "延吉朝阳川"],
["YNT", "烟台", "Yantai", "烟台莱山"],
["YBP", "宜宾", "Yibin", "宜宾菜坝"],
["YIH", "宜昌", "Yichang", "宜昌三峡"],
["INC", "银川", "Yinchuan", "银川河东"],
["YIN", "伊宁", "Yining", "伊宁"],
["YIW", "义乌", "Yiwu", "义乌"],
["UYN", "榆林", "Yulin", "榆林"],
["YCU", "运城", "Yuncheng", "运城"],
["DYG", "张家界", "Zhangjiajie", "张家界荷花"],
["ZHA", "湛江", "Zhanjiang", "湛江"],
["ZAT", "昭通", "Zhaotong", "昭通"],
["CGO", "郑州", "Zhengzhou", "郑州新郑"],
["ZHD", "中甸", "Zhongdian", "中甸"],
["HSN", "舟山", "Zhoushan", "舟山普陀山"],
["ZUH", "珠海", "Zhuhai", "珠海三灶"],
["ZYI", "遵义", "Zunyi", "遵义"]];

var aryAirComps =[
["3U", "川航", "四川航空公司"],
["8C", "东星", "东星"],
["8L", "祥鹏", "祥鹏航空"],
["BK", "奥凯", "奥凯航空"],
["CA", "国航", "中国国际航空公司"],
["CN", "新华", "大新华"],
["CX", "国泰", "国泰航空公司"],
["CZ", "南航", "中国南方航空公司"],
["EU", "鹰联", "鹰联航空"],
["FM", "上航", "上海航空公司"],
["G5", "华夏", "中国华夏航空"],
["GS", "新华", "大新华快运"],
["HO", "吉祥", "吉祥航空"],
["HU", "海航", "海南航空公司"],
["KA", "港龙", "香港港龙航空公司"],
["KN", "联合", "中国联合航空"],
["MF", "厦航", "厦门航空公司"],
["MU", "东航", "中国东方航空公司"],
["NS", "华夏", "华夏航空"],
["NX", "澳航", "澳门航空公司"],
["PN", "西部", "西部航空"],
["SC", "山航", "山东航空公司"],
["SZ", "西南", "中国西南航空公司"],
["UO", "快运", "香港快运航空公司"],
["VD", "鲲鹏", "鲲鹏航空"],
["ZH", "深航", "深圳航空公司"]];

function AptSelShow(refID,valueID)
{
	var vFrm = document.getElementById('AptSelFrm');
	var vRef = document.getElementById(refID);
	var vValue = document.getElementById(valueID);
	if (vRef == null || vValue == null)	return;
	vRef.select();

	var nTop = vRef.offsetHeight, nLeft = 0, p = vRef;	
	while (p&&p.tagName!="BODY") {nTop+=p.offsetTop;nLeft+=p.offsetLeft;p=p.offsetParent;}
	if (p != null) {nTop += p.offsetTop; nLeft += p.offsetLeft;}
	
	vFrm.style.top = nTop + 'px';
	vFrm.style.left = nLeft + 'px';
	vFrm.style.width = '196px';
	vFrm.style.height = '278px';

	window.frames.AptSelFrm.InitAptList(aryAirports, vRef, vValue);
	vFrm.style.display = 'block';
}
function AptSelOnKey(obj, vKey)
{
	var vFrm = document.getElementById('AptSelFrm');
	if (vKey == 27)
	{
		AptSelHide(null);
		return false;
	}
	if (vKey != 9 && window.frames.AptSelFrm.vRefObj == obj && vFrm.style.display != 'block')
		vFrm.style.display = 'block';
	return window.frames.AptSelFrm.OnKeyDown(vKey);
}
function AptEatKeys(vKey)
{
	if (vKey == 13) return false;
	return true;
}
function AptSelHide(e)
{
	if (e != null)
	{
		if (e.srcElement == window.frames.AptSelFrm.vRefObj)
			return;
	}
	if (typeof window.frames.AptSelFrm.CheckOnHide != 'undefined')
		window.frames.AptSelFrm.CheckOnHide();
	var v = document.getElementById('AptSelFrm');
	if (v != null) v.style.display = "none";
}
function GetCityByCode(code)
{
	for (var i = 0; i < aryAirports.length; i++)
	{
		if (aryAirports[i][0] == code)
			return aryAirports[i][1];
	}
	return "";
}
function InitCityName(dispID,codeID)
{
	var vc = document.getElementById(codeID);
	var vd = document.getElementById(dispID);
	if (vc == null || vd == null) return;
	if (vc.value.length > 0) vd.value = GetCityByCode(vc.value);
}
if (typeof(addClickListener) != "undefined") addClickListener(AptSelHide);
function FltCheckFind(pid)
{
	var vLastValue;
	if (pid != null) pid = pid + '_'; else pid = '';
	var v = document.getElementById(pid + 'DeptCity');
	if (v.value == '' || v.value == '-')
	{
		alert('请选择出发城市。'); v.focus();
		return false;
	}
	vLastValue = v.value;
	v = document.getElementById(pid + 'ArivCity');
	if (v.value == '' || v.value == '-')
	{
		alert('请选择到达城市。'); v.focus();
		return false;
	}
	if (v.value == vLastValue)
	{
		alert('出发城市和到达城市不能相同，请重新选择。');
		v.focus();
		return false;
	}
	vLastValue = v.value;
	v = document.getElementById(pid + 'ArivCity2');
	var bIsLink = false;
	if (v.value != '' && v.value != '-')
	{
		if (v.value == vLastValue)
		{
			alert('两个出发城市不能相同，请重新选择。');
			v.focus();
			return false;
		}
		bIsLink = true;
	}
	var vNow = new Date();
	var strToday = vNow.format('yyyy-MM-dd');
	v = document.getElementById("DeptDate1");
	if (v.value == '')
	{
		alert('请选择出发日期。');	v.focus();
		return false;
	}
	if (v.value < strToday)
	{
		alert('出发日期不能早于今天。'); v.focus();
		return false;
	}
	vLastValue = v.value;
	v = document.getElementById("DeptDate1");
	if (v.value != '')
	{
		if (v.value < vLastValue)
		{
			alert('第二个出发日期不能晚于第一个出发日期。'); v.focus();
			return false;
		}
	}
	return true;
}

// class CFltList
function CFltList()
{
	this.FltDate = null;
	this.DeptCity = null;
	this.ArivCity = null;
	this.PriceADT = 0;
	this.PriceCHD = 0;
	this.PriceBAB = 0;
	this.aryFlt = null;
	
	this.SelClassType = '';
	this.SelPriceMin = 0;
	this.SelPriceMax = 100000000; 
	this.SelTimeFrom = '00:00';
	this.SelTimeTo = '24:00';
	this.SelAirCode = '';
	
	this.SortType = -1;
	this.SortDesc = false;
}
CFltList.prototype.ClearSelInfo = function()
{
	this.SelClassType = '';
	this.SelPriceMin = 0;
	this.SelPriceMax = 100000000; 
	this.SelTimeFrom = '00:00';
	this.SelTimeTo = '24:00';
	this.SelAirCode = '';
}
CFltList.prototype.ClearSortInfo = function()
{
	this.SortType = -1;
	this.SortDesc = false;
}
CFltList.prototype.GetFltNum = function()
{
	if (this.aryFlt == null) return 0; return this.aryFlt.length; 
}
CFltList.prototype.ParseFltInfo = function (fltInfo)
{
	/*	fltInfo
		base:	FltDate, DeptApt, ArivApt, PriceADT, PriceCHD, PriceBAB, FltNum
		flt:	FltID, FltNo, DeptApt, ArivApt, DeptTime, ArivTime, PlaneType, PlaneDesc, FaxInfo, ClassNum
		class:	FltClass, SeatNum, TktPrice, PriceRate, PolicyID, IsSpecPrice, Profit
	*/
	var NUMOF_BASE_ITEM = 7, NUMOF_FLT_ITEM = 10, NUMOF_CLASS_ITEM = 7;
	
	var aryInfo = fltInfo.split('\n');
	if (aryInfo.length < 1)	{ alert('ERROR: Invalid flight list.'); return false; }
	
	// base info.
	var tmp = aryInfo[0].split(',');
	if (tmp.length != NUMOF_BASE_ITEM) { alert('ERROR: Invalid base flt info - ' + aryInfo[0]); return false; }
	this.FltDate = tmp[0];
	this.DeptCity = tmp[1];
	this.ArivCity = tmp[2];
	this.PriceADT = parseInt(tmp[3], 10);
	this.PriceCHD = parseInt(tmp[4], 10);
	this.PriceBAB = parseInt(tmp[5], 10);
	var nFltNum = parseInt(tmp[6], 10);

	// flight array
	this.aryFlt = new Array(nFltNum);
	var nInfoIdx = 1;
	for (var i = 0; i < nFltNum; i++)
	{
		if (nInfoIdx >= aryInfo.length) break;
		tmp = aryInfo[nInfoIdx].split(',');
		if (tmp.length != NUMOF_FLT_ITEM) { alert('ERROR: Invalid flght info - ' + aryInfo[nInfoIdx]); return false; }
		nInfoIdx++;
		var nClassNum = parseInt(tmp[9], 10);
		if (nClassNum > 0)
		{
			this.aryFlt[i] = {
				FltID :		tmp[0],
				FltNo :		tmp[1],
				AirCode :	tmp[1].substr(0,2),
				DeptApt :	tmp[2],
				ArivApt :	tmp[3],
				DeptTime : 	tmp[4],
				ArivTime :	tmp[5],
				PlaneType :	tmp[6],
				PlaneDesc :	tmp[7],
				FaxInfo :	tmp[8],
				CurClassIdx : -1,
				aryClass :	new Array(nClassNum)
				};
			for (var j = 0; j < nClassNum; j++)
			{
				if (nInfoIdx >= aryInfo.length) break;
				tmp = aryInfo[nInfoIdx].split(',');
				nInfoIdx++;
				if (tmp.length != NUMOF_CLASS_ITEM) { alert('ERROR: Invalid flight class info - ' + aryInfo[nInfoIdx]); return false; }
				this.aryFlt[i].aryClass[j] = {
					FltClass :	tmp[0],
					SeatNum :	parseInt(tmp[1], 10),
					TktPrice :	parseInt(tmp[2], 10),
					PriceRate :	parseInt(tmp[3], 10),
					PolicyID :	tmp[4].trim(),
					IsSpec : tmp[5].trim() == 'Y',
					Profit : parseInt(tmp[6], 10)
					};
			}
		}
		else
		{
			this.aryFlt[i] = {
				FltID :		tmp[0],
				FltNo :		tmp[1],
				AirCode :	tmp[1].substr(0,2),
				DeptApt :	tmp[2],
				ArivApt :	tmp[3],
				DeptTime : 	tmp[4],
				ArivTime :	tmp[5],
				PlaneType :	tmp[6],
				PlaneDesc :	tmp[7],
				FaxInfo :	tmp[8],
				CurClassIdx : -1,
				aryClass :	new Array(1)
				};
			this.aryFlt[i].aryClass[0] = {
				FltClass :	'Y',
				SeatNum :	0,
				TktPrice :	this.PriceADT,
				PriceRate :	100,
				PolicyID :	'',
				IsSpec : false,
				Profit : 0
				};
		}
		this.aryFlt[i].aryClass.sort(this.CompareClassPrice);
	}
	return true;
}
CFltList.prototype.CompareClassPrice = function(n1, n2)
{
	if (n1.TktPrice < n2.TktPrice) return -1;
	if (n1.TktPrice > n2.TktPrice) return 1;
	return 0;
}
CFltList.prototype.MakeDisplayStr = function()
{
	var nFltNum = this.GetFltNum();
	var sb = new StringBuilder();
	sb.append('<table cellpadding="0" cellspacing="0" class="flt_list_tbl">');
	sb.append('<tr><th width="130px"><a href="javascript:FltListSort(0)" title="按航班号排序">航班</a></th><th width="80px"><a href="javascript:FltListSort(1)" title="按出发时间排序">出发</a></th><th width="80px"><a href="javascript:FltListSort(2)" title="按到达时间排序">到达</a></th><th width="50px">机型</th><th width="60px">税费</th><th width="90px"><a href="javascript:FltListSort(5)" title="按价格排序">价格</a></th><th width="60px">&nbsp;</th><th>&nbsp;</th>');
	
	var nLineIdx = 0;
	for (var i = 0; i < nFltNum; i++)
	{
		var flt = this.aryFlt[i];
		var cls = this.SelClassInfo(flt);
		if (cls == null) continue;
		var lineCls = nLineIdx % 2;
		var ctrlID = '';
		nLineIdx++;
		
		sb.append('<tr class="flt_list_line' + lineCls + '">');
		sb.append('<td><img src="../images/icon_logo_' + flt.AirCode + '.gif" align="absmiddle"/>');
			sb.append(this.GetAirCompName(flt.AirCode,flt.AirCode) + '<br/>' + flt.FltNo + '</td>');
		sb.append('<td>' + flt.DeptTime + '<br/>' + this.MakeAptInfo(flt.DeptApt) + '</td>');
		sb.append('<td>' + flt.ArivTime + '<br/>' + this.MakeAptInfo(flt.ArivApt) + '</td>');
		sb.append('<td><span class="flt_list_desc" title="' + flt.PlaneDesc + '">' + flt.PlaneType + '</td>');
		sb.append('<td>' + flt.FaxInfo + '</td>');
		sb.append('<td>' + this.FormatClassInfo(cls,'<br/>') + '</td>');
		ctrlID = 'fltlia_rmk_' + nLineIdx;
		sb.append('<td><a id="' + ctrlID + '" href="' + this.MakeFltSelLink('FltGetRemark', ctrlID, flt, cls) + '">退改签</a><br/>');
		ctrlID = 'fltlia_dtl_' + nLineIdx;
		sb.append('<a id="' + ctrlID + '" href="' + this.MakeFltSelLink('FltGetDetail', ctrlID, flt, cls) + '">全部舱位</a></td>');
		ctrlID = 'fltlia_odr_' + nLineIdx;
		sb.append('<td><a id="' + ctrlID + '" href="' + this.MakeFltSelLink('FltOrderTkt', ctrlID, flt, cls));
		if (cls.IsSpec)
			sb.append('"><font color="#0033FF">申请</font><img src="../images/arrow3_1.gif" align="absmiddle" border="0"/></a></td>');
		else
			sb.append('"><font color="#0033FF">预定</font><img src="../images/arrow3_1.gif" align="absmiddle" border="0"/></a></td>');
		sb.append('</tr>');
	}
	
	sb.append('</table>');
	return sb.toString();
}
CFltList.prototype.SelClassInfo = function(flt)
{
	if (this.SelAirCode != '' && flt.AirCode != this.SelAirCode)	return null;
	if (flt.DeptTime < this.SelTimeFrom || flt.DeptTime > this.SelTimeTo)	return null;
	var nRateMin, nRateMax;
	if (this.SelClassType == 'T')
	{
		for (var i = 0; i < flt.aryClass.length; i++)
		{
			var cls = flt.aryClass[i];
			if (cls.IsSpec)
			{
				flt.CurClassIdx = i;
				return cls;
			}
		}
	}
	else
	{
		switch (this.SelClassType)
		{
			case 'F':	nRateMin = 150; nRateMax = 10000;	break;
			case 'A':	nRateMin = 101; nRateMax = 149; break;
			case 'Y':	nRateMin = 100; nRateMax = 100; break;
			default:	nRateMin = 0; nRateMax = 10000; break;
		}
		for (var i = 0; i < flt.aryClass.length; i++)
		{
			var cls = flt.aryClass[i];
			if (cls.PriceRate >= nRateMin && cls.PriceRate <= nRateMax)
			{
				if (cls.TktPrice >= this.SelPriceMin && cls.TktPrice <= this.SelPriceMax)
				{
					flt.CurClassIdx = i;
					return cls;
				}
			}
		}
	}
	return null;
}
CFltList.prototype.FormatClassInfo = function(cls, sepOfPrice)
{
	if (sepOfPrice == null)
		sepOfPrice = ' ';
	var str;
	var strPrefit = '';
	if (cls.Profit > 0)
		strPrefit = '(' + (cls.TktPrice * cls.Profit / 100) + ')';
	if (!cls.IsSpec)
	{
		if (cls.SeatNum > 0)
		{
			str = 	'<span class="flt_list_price">￥' + cls.TktPrice + strPrefit + sepOfPrice + '<font>' +
				this.FormatClassDesc(cls) + '</font></span>';
		}
		else
		{
			str = 	'<span class="flt_list_priceI">￥' + cls.TktPrice + strPrefit + sepOfPrice + '<font>' +
				this.FormatClassDesc(cls) + '</font></span>';
		}
	}
	else
	{
		str = 	'<span class="flt_list_priceT">￥' + cls.TktPrice + strPrefit + sepOfPrice + '<font>' +
				this.FormatClassDesc(cls) + '</font></span>';
	}
	return str;
}
CFltList.prototype.FormatClassDesc = function(cls)
{
	var str = '';
	if (cls.PriceRate < 100)
	{
		var a = cls.PriceRate / 10;
		str += a + '折,';
	}
	else if (cls.PriceRate == 100)
		str += '全价,';
	else if (cls.PriceRate < 150)
		str += '公务,';
	else
		str += '头等,';
	if (cls.SeatNum < 9)
		return str + cls.SeatNum + '张';
	return str + '至少9张';
}
CFltList.prototype.GetAirCompName = function(airCode, dft)
{
	var tmp = airCode.toUpperCase();
	for (var i = 0; i < aryAirComps.length; i++)
	{
		if (aryAirComps[i][0] == tmp)
			return aryAirComps[i][2];
	}
	return dft;
}
CFltList.prototype.GetAirCompShortName = function(airCode, dft)
{
	for (var i = 0; i < aryAirComps.length; i++)
	{
		if (aryAirComps[i][0] == airCode)
			return aryAirComps[i][1];
	}
	return dft;
}
CFltList.prototype.MakeAptInfo = function(aptCode)
{
	var str = '';
	for (var i = 0; i < aryAirports.length; i++)
	{
		if (aryAirports[i][0] == aptCode)
		{
			if (aryAirports[i][3] != '')
				str = aryAirports[i][3];
			else
				str = aryAirports[i][1];
			break;
		}
	}
	if (str == '')	return aptCode;
	//return '<span class="flt_list_desc" title="' + str + '">' + aptCode + '</span>';
	return '<span class="flt_list_desc" title="' + aptCode + '">' + str + '</span>';
}
CFltList.prototype.MakeFltSelLink = function(act, ctrlID, flt,cls)
{
	return "javascript:" + act + "('" + ctrlID + "','" + flt.FltID + "," + flt.FltNo + "," + cls.FltClass + "')";
}
CFltList.prototype.SortBy = function(sType)
{
	if (this.aryFlt == null)	return;	
	switch (sType)
	{
		case 0:		this.aryFlt.sort(this.CompareFltNo);		break;
		case 1: 	this.aryFlt.sort(this.CompareDeptTime);	break;
		case 2:		this.aryFlt.sort(this.CompareArivTime);	break;
		case 5:		this.aryFlt.sort(this.ComparePrice);		break;
		default:
			return;
	}
	if (this.SortType == sType)
	{
		this.SortDesc = !this.SortDesc;
		if (this.SortDesc)
			this.aryFlt.reverse();
	}
	else
		this.SortDesc = false;
	this.SortType = sType;
}
CFltList.prototype.CompareFltNo = function(f1, f2)
{
	if (f1.FltNo < f2.FltNo)	return -1;
	if (f1.FltNo > f2.FltNo)	return 1;
	return 0;
}
CFltList.prototype.CompareDeptTime = function(f1, f2)
{
	if (f1.DeptTime < f2.DeptTime)	return -1;
	if (f1.DeptTime > f2.DeptTime)	return 1;
	return 0;
}
CFltList.prototype.CompareArivTime = function(f1, f2)
{
	if (f1.ArivTime < f2.ArivTime)	return -1;
	if (f1.ArivTime > f2.ArivTime)	return 1;
	return 0;
}
CFltList.prototype.ComparePrice = function(f1, f2)
{
	var p1 = 0, p2 = 0;
	if (f1.aryClass != null && f1.CurClassIdx >= 0 && f1.CurClassIdx < f1.aryClass.length)
		p1 = f1.aryClass[f1.CurClassIdx].TktPrice;
	if (f2.aryClass != null && f2.CurClassIdx >= 0 && f2.CurClassIdx < f2.aryClass.length)
		p2 = f2.aryClass[f2.CurClassIdx].TktPrice;
	if (p1 < p2)	return -1;
	if (p1 > p2)	return 1;
	return 0;
}
CFltList.prototype.StatByTimeRange = function(timeRange)
{
	if (this.aryFlt == null || timeRange == null)	{ alert('ERROR: invalid context or param.'); return; }
	var aryRange = timeRange.split(',');
	if (aryRange.length <= 1)	{ alert('ERROR: the length of time range error.'); return;}
	var aryStat = new Array((aryRange.length - 1) * 2);
	for (var i = 0; i < aryStat.length; i++)
		aryStat[i] = 0;
	for (var i = 0; i < this.aryFlt.length; i++)
	{
		var flt = this.aryFlt[i];
		if (flt.aryClass == null || flt.aryClass.length <= 0 || flt.DeptTime < aryRange[0]) continue;
		for (var j = 1; j < aryRange.length; j++)
		{
			if (flt.DeptTime < aryRange[j])
			{
				var nStatIdx = (j-1)*2;
				aryStat[nStatIdx] = aryStat[nStatIdx] + 1;
				if (aryStat[nStatIdx+1] == 0 || aryStat[nStatIdx+1] > flt.aryClass[0].TktPrice)
					aryStat[nStatIdx+1] = flt.aryClass[0].TktPrice;
				break;
			}
		}
	}
	return aryStat;
}
CFltList.prototype.StatByAirCode = function()
{
	if (this.aryFlt == null)	{ alert('ERROR: invalid context or param.'); return; }
	var  aryStat = new Array();
	for (var i = 0; i < this.aryFlt.length; i++)
	{
		var flt = this.aryFlt[i];
		if (flt.aryClass == null || flt.aryClass.length <= 0) continue;
		var tmp = null;
		for (var j = 0; j < aryStat.length; j++)
		{
			if (aryStat[j].AirCode == flt.AirCode)
			{
				tmp = aryStat[j];
				tmp.FltNum = tmp.FltNum + 1;
				if (tmp.MinPrice > flt.aryClass[0].TktPrice)
					tmp.MinPrice = flt.aryClass[0].TktPrice;
				break;
			}
		}
		if (tmp == null)
		{
			var strName = this.GetAirCompShortName(flt.AirCode, flt.AirCode);
			tmp = { AirCode: flt.AirCode, AirComp: strName, FltNum: 1, MinPrice: flt.aryClass[0].TktPrice };
			aryStat.push(tmp);
		}
	}
	return aryStat;
}
CFltList.prototype.GetFltByIdx = function(idx)
{
	if (idx < 0 || idx >= this.aryFlt.length)
		return null;
	return this.aryFlt[idx];
}
CFltList.prototype.GetClassInfo = function(fltIdx,cls)
{
	var flt = this.GetFltByIdx(fltIdx);
	if (flt == null || flt.aryClass == null)	return null;
	for (var i = 0; i < flt.aryClass.length; i++)
	{
		if (flt.aryClass[i].FltClass == cls)
			return flt.aryClass[i];
	}
	return null;
}
CFltList.prototype.GetClassRank = function(cls)
{
	if (cls == null) return '';
	if (cls.PriceRate >= 150)	return '头等舱';
	if (cls.PriceRate > 100)	return '公务舱';
	return '经济舱';
}
CFltList.prototype.MakeFltClsDisplay = function(idx)
{
	var flt = this.GetFltByIdx(idx);
	if (flt == null) return 'invalid flight idx = ' + idx;
	var ctrlID;
	var sb = new StringBuilder();
	sb.append('<table cellpadding="0" cellspacing="0" width="100%">');
	for (var i = 0; i < flt.aryClass.length; i++)
	{
		var cls = flt.aryClass[i];
		sb.append('<tr><td>￥' + cls.TktPrice + ' ' + this.FormatClassDesc(cls));
		if (cls.Profit > 0)
			sb.append('(' + (cls.TktPrice * cls.Profit / 100) + ')');
		sb.append('</td>');
		ctrlID = 'fltlia_odr_' + idx;
		// sb.append('<td><a id="' + ctrlID + '" href="' + this.MakeFltSelLink('parent.FltGetRemark', ctrlID, flt, cls) + '">退改签</a><br/>');
		sb.append('<td><a href="' + this.MakeFltSelLink('parent.FltOrderTkt', ctrlID, flt, cls) + '">预定</a></td></tr>');
	}
	sb.append('</table>');
	return sb.toString();
}
CFltList.prototype.GetSelCls = function(strSel)
{
	var arySel = strSel.split(',');
	if (arySel.length != 3) return null;
	var nFltIdx = parseInt(arySel[0], 10);
	if (isNaN(nFltIdx)) return null;
	return this.GetClassInfo(nFltIdx, arySel[2]);
}