// 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].toUpperCase()==m_cityName_temp){
				$("#"+m_Hide).val(airportCode_split[i]);
//				alert($("#"+m_Hide).val())
			break;
			}
		}
	}
	$("#flightsform").submit(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;
		$(this).attr("action","/vols/postquery.asp");
	});
	
	$(".triptype").click(function(){
		$(".getFromCity").hide();
		if($(this).val()=="1"){
			$("#tReturn").css("display","none");
			$("#flightFromTo").html("&nbsp; To: ");
			$("#StrseCity").css("display","none");
			$("#Depart").html("Depart: ");
			}
		else if($(this).val()=="2"){
			$("#tReturn").css("display","");
			$("#flightFromTo").html("&nbsp; To: ");
			$("#StrseCity").css("display","none");
			$("#Depart").html("Départ: ");
			$("#Return").html("Retour");
			}
		else if($(this).val()=="3"){
			$("#flightFromTo").html("&nbsp; Fst Arrival: ");
			$("#StrseCity").css("display","");
			$("#Return").html("2ème ville de départ: ");
			$("#Depart").html("1ère ville de départ:");
			$("#tReturn").css("display","");
		}
	});

  //作用页面 flight-list.asp flight-list-02.asp
  //机票ALL Classes	展开效果
	$(".tableResult .allclass").click(function(){
		var strtmp = $(this).attr("name");
		var arrstrtmp = strtmp.split("_");
		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='7' class='price'><img src='/pic/ajax-loader-1.gif' /></td></tr>";
		if($(this).attr("id") == "js_openClass")
		{
			$(this).parents("tr").after(js_Cache);
			$(this).text("toutes les 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){
				$(".js_openClass").remove();
				$(".allclass[name="+strtmp+"]").parents("tr").after(data);
			});
		}
		else
		{
			$(this).text("toutes les Classes").attr("id","js_openClass").parents("tr").removeClass().addClass($(this).parents("tr").attr("id"));
			$(".tr"+id).hide();
		}
	});
	//机票ALL Classes	展开效果


	$("#flightResultFilter input").click(function(){
		$("#flightForm").submit();
	});
	$(".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();
	});

	///////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);}
	
	function CancelDiv(strDiv){$("."+strDiv).hide();}
	
	$("#startCode1Text").focus(function(){
		$(".getFromCity").hide();
		$("#getFromCity1").show();
	});
	$("#destinationCode1Text").focus(function(){
		$(".getFromCity").hide();
		$("#getFromCity2").show();
	});
	$("#destinationCode2Text").focus(function(){
		$(".getFromCity").hide();
		$("#getFromCity3").show();
	});
	///////Country弹窗


});

//cc:城市代码  cn:城市名
	
	function SelectCity(cc,cn,cityText,cityCode,cityDiv){
		$("#"+cityText).val(cn);
		$("#"+cityCode).val(cc);
		$("#"+cityDiv).css("display","none");
	}
