document.write('<script type="text/javascript" src="/cab2c/include/getAirlineFromCity.jsp"><\/script>');


/**单程，往返两种情况下不同出发城市对应的到达城市*/
function kindselect(type)
{
	var kind;
	if(type!=null){
		var kind = type.toLowerCase();	
	}
	else{
		kind = getAirkind();
	}
	if(document.form1.actionkind!=null){
		document.form1.actionkind.value=kind;
	}
	if(kind=="multiseg")kind="oneway";//对于多段，城市对同单程
	if(kind=="roundtrip")kind="airreturn";//对国际票往返做出的修正
	var cfcity = document.form1.org.options[document.form1.org.selectedIndex].value;
	switch (kind.toLowerCase()) 
	{
		case "oneway":
			ddchange(cfcity,0);
			try{
				setOnewayCond();//Add by liaoxu,隐藏显示
			}catch(e){}
			break;
		case "airreturn": 
			ddchange(cfcity,1);
			try{
				setReturnCond();
			}catch(e){}
			break;
		case "roundtrip": 
			ddchange(cfcity,1);
			try{
				setReturnCond();
			}catch(e){}
			break;
		default://默认选中单程 
			if(document.getElementById("oneway_airkind")!=null){
				document.getElementById("oneway_airkind").checked = true;
			}
			break;
	}	
}
/*只改变行程种类，不重置城市*/
function kindchange()
{
	document.form1.actionkind.value=getAirkind();
	switch (getAirkind()) {
		case "oneway":setOnewayCond();kindselect();break;
		case "airreturn":setReturnCond();kindselect();break;
		case "multiseg":setOnewayCond();kindselect();break;
		/*case "oneway":setOnewayCond();break;
		case "airreturn":setReturnCond();break;
		case "multiseg":setOnewayCond();break;*/
	}
}

//公用函数
function cleardst(){
	var len = document.form1.dst.options.length;
	for(var i = (len-1); i >= 0; i--) {
		if (document.form1.dst.options[i] != null) {
			document.form1.dst.options[i] = null;
		}
	}
}

function filldst(itemno,itemcode){
	var length = itemno.length;
	var option = document.form1.dst;
	for(var i=0;i<length;i++){
		//if(international&&itemcode[i]=="SHA"){
		//	itemno[i] == "SHANGHAI";//国际票显示上海而不是上海虹桥
		//}
		option.options[i]=new Option(itemno[i],itemcode[i]); 
    }
}

Array.prototype.clone = function(){
 	var tmp=new Array();
 	for(ob in this)tmp[ob]=this[ob];
 	return tmp;
}

//显示可到达城市
function ddchange(cfcity,isreturn){
	cleardst();
	var arrayname;
	var theone= -1;
	var tmpitemno;
	var tmpitemcode;
	if(international){//国际票
		if(isreturn == 1){
			arrayname = "return_"+cfcity.toLowerCase()+"_i";
		}
		else{
			arrayname = "oneway_"+cfcity.toLowerCase()+"_i";
		}
	}
	else{
		
		if(isreturn == 1){
			arrayname = "return_"+cfcity.toLowerCase();
		}
		else{
			arrayname = "oneway_"+cfcity.toLowerCase();
		}
			
	}

	try{
		if(cfcity.toLowerCase()=="tpe"||cfcity.toLowerCase()=="tsa"){alert(alerttpestr);}
		
		itemcode = eval(arrayname);
		var length = itemcode.length;
		var itemno = new Array();
		for(var i=0;i<length;i++){
			if(itemcode[i]==cfcity){
				theone = i;
			}
			itemno[i] = citycode[itemcode[i]];
		}
		if(theone!=-1){
			//alert(itemno);
			tmpitemno = itemno.clone();
			tmpitemcode = itemcode.clone();
			//alert(tmpitemno);
			tmpitemno.splice(theone,1);
			tmpitemcode.splice(theone,1);
			filldst(tmpitemno,tmpitemcode);
		}
		else{
			filldst(itemno,itemcode);
		}
	}
	catch(e){
		filldst(new Array(),null);
		return;
	}
}

/*/单程--北京--到达城市
function ddchange_oneway(){
	itemno=new Array(
    'Baotou','Changzhou','Changchun','Changsha','Chengdu','Chongqing','Dalian','Datong','Dazhou','Fuzhou','Guangzhou','Guilin','Guiyang','Haerbin','Haikou','Hailaer','Hangzhou','Hefei','Huhehaote','Huangshan','Jinggangshan','Kunming','Lasa','Lanzhou','Mianyang','Nanchang','Nanjing','Nanning','Nantong','Ningbo','Qinhuangdao','Qingdao','Sanya','Shantou','Shanghaihongqiao','Shanghaipudong','Shenzhen','Shenyang','Taiyuan','Weihai','Wenzhou','Wulumuqi','Wuhan','Wuyishan','Xi an','Xining','Xilinhaote','Xiamen','Xiangfan','Yancheng','Yantai','Yanji','Yinchuan','Zhangjiajie','Zhengzhou','Zhuhai');
    itemcode=new Array(
    'BAV','CZX','CGQ','CSX','CTU','CKG','DLC','DAT','DAX','FOC','CAN','KWL','KWE','HRB','HAK','HLD','HGH','HFE','HET','TXN','JGS','KMG','LHW','MIG','KHN','NKG','NNG','NTG','NGB','SHP','TAO','SYX','SWA','SHA','PVG','SZX','SHE','TYN','WEH','WNZ','URC','WUH','WUS','XIY','XNN','XIL','XMN','XFN','YNZ','YNT','YNJ','INC','DYG','CGO','ZUH');
	filldst(itemno,itemcode);
}
*/
function getAirkind(){
	var kind = "";
	var airkind = document.getElementsByName("airkind");
	for (var i=0;i<airkind.length;i++){
		if(airkind[i].checked){
			kind = airkind[i].value;
			break;
		}	
	}
	return kind;
}

/**国际票使用：单程，往返两种情况下时间显示控件*/
function dateDisplay()
{
	switch (getAirkind()) 
	{
		case "oneway": 
			document.form1.actionkind.value="oneway";//赋值给将传递到下一个页面的参数"actionkind"
			//隐藏往返情况下的返城日期
			document.form1.sectime.value = "";
			document.getElementById("backdate_checkbox").style.display = 'none';
			break;
		case "airreturn": 
			document.form1.actionkind.value="airreturn";//赋值给将传递到下一个页面的参数"actionkind"
			document.form1.sectime.value = "返程日期:";
			document.getElementById("backdate_checkbox").style.display = 'block';
			break;
		default:
			document.getElementsById("oneway_airkind").checked = true;
			document.form1.dstcity.value = "To:";
			document.form1.fsttime.value = "Departing";
			document.form1.sectime.value = "";
			document.form1.back_year.disabled = false;
			document.form1.back_month.disabled = false;
			document.form1.back_date.disabled= false ;
			break;
	}
	
}

//起飞城市
function cfcityDisplay(formname)
{
	var operationform=document.form1;
	if(arguments.length==1){
		operationform=formname;
	}
	
	//清空列表
	var len = operationform.org.options.length;
	for(var i = len-1; i >= 0; i--) {
		operationform.org.options[i] = null;
	}
	
	if(!international){//国内起飞城市
		itemcode = domesticcitycode;
	}
    else {//国际起飞城市
		itemcode = domesticcitycode.concat(new Array('blue'));
		itemcode = itemcode.concat(internationalcitycode);
	}
	for(var i=0;i<itemcode.length;i++){
		//if (itemcode[i]=='SHA'&&international){
			
		//	continue;
		//}
		if (itemcode[i]=='blue'&&international){
			var blueline_option = new Option(citycode[itemcode[i]],itemcode[i]);
			blueline_option.style.color ="blue";
			operationform.org.options[operationform.org.length]=blueline_option;
			continue;
		}
		operationform.org.options[operationform.org.length]=new Option(citycode[itemcode[i]],itemcode[i]); 
	}
    setdv(operationform.org,"PEK");
}

function detectdstcity(formname){
	var operationform=document.form1;
	if(arguments.length==1){
		operationform=formname;
	}
	if(operationform.dst.value == "TPE"||operationform.dst.value == "TSA"){
		alert(alerttpestr);
	}
}