// JavaScript Document
document.write("<script language=\"javascript\" src=\"/js/inland.js\"></script>");
$(function(){
//函数getAirPortCode
//根据城市名获得机场代码
//m_HTML1-城市数组源，m_HTML2机场代码数组源，m_cityName输入城市名，m_Hide-输出位置（为一个隐藏域）
	function getAirPortCode(m_HTML1,m_HTML2,m_cityName,m_Hide){
		var airport_split = citystr.split(",");
		var airportCode_split = citystrcode.split(",");
		var m_cityName_temp = m_cityName.toUpperCase();
		for(i=0;i<airport_split.length-1;i++){
			if(airport_split[i]==m_cityName_temp){
				$("#"+m_Hide).val(airportCode_split[i]);
//				alert($("#"+m_Hide).val());return false;
			break;
			}
		}
	}
	//提交机票首页搜索
	$("#js_search_flights_button").click(function(){
//		if($("#destinationCode2Text").val()==""){
//			var startCode1Text = $("#startCode1Text").val();
//			var destinationCode1Text = $("#destinationCode1Text").val();
//			var temp = getAirPortCode("airport","airportCode",startCode1Text,"startCode1");
//			var temp1 = getAirPortCode("airport","airportCode",destinationCode1Text,"destinationCode1");
//		}
//		else{
//			var startCode1Text = $("#startCode1Text").val();
//			var destinationCode1Text = $("#destinationCode1Text").val();
//			var destinationCode2Text = $("#destinationCode2Text").val();
//			var temp = getAirPortCode("airport","airportCode",startCode1Text,"startCode1");
//			var temp1 = getAirPortCode("airport","airportCode",destinationCode1Text,"destinationCode1");
//			var temp2 = getAirPortCode("airport","airportCode",destinationCode2Text,"destinationCode2");
//		}
//		return false;
		$("#flightsform").attr("action","/china-flights/postquery.asp");
		$("#flightsform").submit();
	});
	$(".triptype").click(function(){
		$(".getFromCity").hide();
		if($(this).val()=="1"){
			$("#tReturn").css("display","none");
			$("#flightFromTo").html("&nbsp; To: ");
			$("#StrseCity").css("display","none");
			$("#Depart").html("Depart: ");
			$("#aReturn").html("To");
			}
		else if($(this).val()=="2"){
			$("#tReturn").css("display","");
			$("#flightFromTo").html("&nbsp; To: ");
			$("#StrseCity").css("display","none");
			$("#Depart").html("Depart: ");
			$("#Return").html("Return");
			$("#aReturn").html("To");
			}
		else if($(this).val()=="3"){
			$("#flightFromTo").html("&nbsp; Fst Arrival: ");
			$("#StrseCity").css("display","");
			$("#Return").html("Sec Depart: ");
			$("#Depart").html("Fst Depart:");
			$("#tReturn").css("display","");
			$("#aReturn").html("Fst Arrival");
			}
		});
	});
///////Country弹窗
function getCityList(cityText,cityDiv,cityCode){
	$("#"+cityDiv).css("display","");
	var w = $("#"+cityText).val();
	var ajax_url = "/include/ajax-getcity.asp?w="+w+"&cityText="+cityText+"&cityCode="+cityCode+"&cityDiv="+cityDiv
	postget(ajax_url,cityDiv);}
//cc:城市代码  cn:城市名
function SelectCity(cc,cn,cityText,cityCode,cityDiv){
	$("#"+cityText).val(cn);
	$("#"+cityCode).val(cc);
	$("#"+cityDiv).css("display","none");
}
function CancelDiv(strDiv){$("."+strDiv).hide();}
$(function(){
	$("#startCode1Text").focus(function(){
		$(".getFromCity").hide();
		$("#getFromCity1").show();
	})
});
$(function(){
	$("#destinationCode1Text").focus(function(){
		$(".getFromCity").hide();
		$("#getFromCity2").show();
	})
});
$(function(){
	$("#destinationCode2Text").focus(function(){
		$(".getFromCity").hide();
		$("#getFromCity3").show();
	})
});
///////Country弹窗

 $(document).ready(function(){
		
 //航班搜索JS代码
 //CZY - finish
 //CJ - move into
		var oLabel=$("#typeSelect input");
		    oLabel.eq(0).attr("checked","checked");
		 //定义一个函数先隐藏全部的label标签
		function hideAll(){
			   $("#frame2 label").hide();
			   $("#frame3 label").hide();
			}
		 //遍历三个label，分别给加上点击事件
		    oLabel.each(function(i){
			    switch(i){
				  case 0:
					 this.onclick=function(){
						 hideAll();
						
						 $("#fromWhere").show();
						 $("#toWhere").show();
						 $("#startDate").show();
						 $("#textTo").html("<strong>Going to:</strong")
						   }
					  break
				  case 1:
					  this.onclick=function(){
						 hideAll();
						
						 $("#fromWhere").show();
					     $("#toWhere").show();
						 $("#startDate").show();
					     $("#endDate").show();
						 $("#textTo").html("<strong>Going to:</strong>");
						 $("#textRetuenDate").html("&nbsp;<strong>Return:</strong>")
						   }
					   break
				  case 2:
					   this.onclick=function(){
						  hideAll(); 
						 
						  $("#fromWhere").show();
						  $("#toWhere").show();
						  $("#startDate").show();
						  $("#endDate").show();
						  $("#textTo").html("&nbsp;<strong>Fst Arrival:</strong>");
						  $("#arrival").show();
						  $("#textRetuenDate").html("&nbsp;<strong>Sec Depart:</strong>")
					   } 
					   break
					}				 
	});
 //航班搜索JS代码


//作用页面 flight-list.asp flight-list-02.asp
//机票ALL Classes	展开效果
	$(".tableResult .allclass").click(function(){
		var strtmp = $(this).attr("name");
		var arrstrtmp = strtmp.split("_");
		$(this).parents("tr").next().children().css("borderBottom","");
		$(this).parents("tr").children().css("borderBottom","");
		var cstar = arrstrtmp[0];
		var cdest = arrstrtmp[1];
		var id = arrstrtmp[2];
		var queryId = arrstrtmp[3];
		var blsave = arrstrtmp[4];
		var datapag;
		var js_Cache = "<tr class='js_openClass'><td colspan='8' class='price'><img src='/pic/ajax-loader-1.gif' /></td></tr>";
		if($(this).attr("id") == "js_openClass")
		{
			 
			// $(this).parents("tr").after(js_Cache);
			$(this).parents("tr").next().after(js_Cache);
 			$(this).text("Hide Classes").attr("id","js_closeClass").parents("tr").attr("id",$(this).parents("tr").attr("class")).removeClass().addClass("openClass");
//缓存后不调用AJAX
			if($(".tr"+id).length > 0 )
			{
				$(".js_openClass").remove();
				$(".tr"+id).show();
				return;	
			}
//缓存后不调用AJAX
			$.post("/include/ajax.asp",{strtemp:"get-other-flight-price",id:id,queryId:queryId,cstar:cstar,cdest:cdest,blsave:blsave},function(data){
				// alert(data);
				$(".js_openClass").remove();
				$(".allclass[name="+strtmp+"]").parents("tr").next().after(data);
			});
		}
		else
		{
			$(this).text("All Classes").attr("id","js_openClass").parents("tr").removeClass().addClass($(this).parents("tr").attr("id"));
			$(".tr"+id).hide();
		}
	});
//机票ALL Classes	展开效果

	$(".ParamSort").click(function(){
//		alert($(this).attr("name"));return false;
		if($(this).attr("id") == "OrderByTime")
		{
			$("#orderBy_Price").val("");
			$("#orderBy_Time").val($(this).attr("name"));
		}
		else
		{
			$("#orderBy_Time").val("");
			$("#orderBy_Price").val($(this).attr("name"));
		}
//		alert($("#orderBy_Time").val());
//		alert($("#orderBy_Price").val());
//		return false;
		$("#flightForm").submit();
	});
//作用页面 flight-list.asp flight-list-02.asp

//flight-list.asp flight-list-02.asp
//页面筛选航空公司和时间按钮效果
//CJ 09-8-29
	//打开显示按钮
	$(".flightSort > a").click(function(){
		$(".flightSort .windowOut").show();
	});
	//关闭按钮
	$(".js_close").click(function(){
		$(".flightSort .windowOut").hide();
	});
	//全选按钮
	$(".js_chooseall").click(function(){
		thisBox = $(this).attr("id").replace(/js_/g,"");
		if($(this).attr("name") == "remove")
		{
			$(this).attr("name","").text("Choose All");
			$(".flightSort input[name="+thisBox+"]:visible").attr("checked","");
			return;
		}
		$(this).attr("name","remove").text("Remove All");
		$(".flightSort input[name="+thisBox+"]:visible").attr("checked","checked");
	});
	//继续按钮
	$(".js_continue").click(function(){
		$.each($(".flightSort input:visible"),function(){
			if($(this).attr("checked"))
			{
				$("#flightForm").submit();
				return;
			}
		});
		$(".flightSort > div:visible").hide();
	});
//flight-list.asp flight-list-02.asp
//页面筛选航空公司和时间按钮效果

//flight-list.asp
//点击触发选择往返或联程最便宜价格组合的事件
	$("#js_chooseLowPrice").click(function(){
		$(this).parents("form").submit();
	});
//flight-list.asp
//点击触发选择往返或联程最便宜价格组合的事件
})
