﻿// JavaScript Document
var strInternational = new Array("BKK","FUK","JKT","KUL","NGO","KIX","PEN","PUS","SDJ","SEL","SIN","NRT","AMS","PAR","LAX","HKG","CVG","CRK","DXB","DFW","TAE","FKS","HAN","SGN","FKS","HNA","BDL","HNL","LAO","LAS","LON","LAD","MFM","MNL","MEL","OIT","OKJ","MCO","PNH","FNJ","HKT","REP","RGN","SHJ","SYD","HSG","SLC","REP","TOY","TAK","THK","YVR","JIN","YNY","ALA","ASB","ATL","BAK","FRU","BWN","BOS","CJJ","CNX","CGK","DYU","DEL","HIJ","ISB","IKT","KKJ","KOJ","KHV","BKI","KCH","KMJ","KTM","KWJ","MOW","MMJ","NYC","KIJ","OVB","SPN","SPK","SEL","TAE","TAS","VTE","VVO","TPE","CJU","MIL","THR","IKA","JED","OSS","ATH","BCN","BER","BHX","BRU","CPH","DUS","EDI","FRA","GVA","HAM","HEL","LIS","MAD","MAN","MIL","MUC","NCL","ROM","STO","VIE","WAW","ZRH","LOS","ORD","CLE","IAH","JAX","FLL","MEM","EWR","TPA","LIM","BNE");

function $(id){
	return document.getElementById(id);	
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function clearchildnodes(parentnodenames){//清除节点
		var parentnodes = $(parentnodenames);
		var childnodecounts = parentnodes.childNodes.length;
		if(parentnodes.hasChildNodes()){
			for (i=0 ; i<childnodecounts;i++){
				parentnodes.removeChild(parentnodes.childNodes[0]);
			}
		}
}

function clearpresentnode(presentnode){//删除当前节点
		var mypresentnode = document.getElementById(presentnode);
		mypresentnode.parentNode.removeChild(mypresentnode);
}

/*国际航班*/
function internationalCheck(){
	var temp =false;
	for(var k=1; k<6; k++){
		var strcity2 = $("city"+k).value;
			for (var i= 0; i<strInternational.length; i++){
				if(strcity2 == strInternational[i]){
					temp = true;
					break;
				}
			}
		if(temp){
			break;
		}
	}
	return temp;
}

function timezoneOffsetWrite(){//获取时区
   d = new Date();
   tz = d.getTimezoneOffset()/60;
   $("getTimezone").innerHTML = "<input type=hidden name=offset value=" + tz + ">";
}

/*事件路由*/
Array.prototype.append=function(obj,nobup){
	if(!(nobup && this.contacts(obj))){
		this[this.length]=obj;
	}
}

Array.prototype.contacts=function(obj){
	return (this.indexOf(obj)>=0);
}

Array.prototype.indexOf=function(obj){
	var results=-1;
	for(var i=0; i<this.length; i++ ){
		if(this[i]==obj){
		results = i;
		break;
		}
	}
	return results;
}
var jsEvent=new Array();
jsEvent.EventRouter=function(el,evenType){
		this.lsnrs=new Array();
		this.el=el;
		el.eventRouter=this;
		el[evenType]=jsEvent.EventRouter.callback;
}
jsEvent.EventRouter.prototype.addListener=function(lsnr){
		this.lsnrs.append(lsnr,true);
}
jsEvent.EventRouter.prototype.removeListener=function(lsnr){
		this.lsnrs.remove(lsnr);
}
jsEvent.EventRouter.prototype.notify=function(e){
		var lsnrs=this.lsnrs;
		for(var i=0;i<lsnrs.length; i++){
			var lsnr=lsnrs[i];
			lsnr.call(this,e);
		}
}
jsEvent.EventRouter.callback=function(event){
		var e=event||window.event;
		var router=this.eventRouter;
		router.notify(e);
}
/* end Eventrouter */

function copyrightDate(){
	var temp = $("CopyRightDate");
	var nowDate=new Date();
	temp.innerHTML=nowDate.getFullYear();	
}

function switchTab(tabpage,tabid)//首页选项卡1
{
        var oItem = $(tabpage);
        for(var i=0; i<oItem.childNodes.length; i++){
         var x = oItem.childNodes[i];
         if(typeof(x.tagName) == 'undefined') continue;
         x.className = "";
        }
        $(tabid).className = "active";
        var dvs=$("cnt").getElementsByTagName("li");
        for (var i=0; i<dvs.length; i++)
        {
                if (dvs[i].id==('d'+tabid))
                {dvs[i].style.display='block';}
                else
                {dvs[i].style.display='none';}
        }
}

function switchTab2(tabpage,tabid)//首页选项卡2 
{
        var oItem = $(tabpage);
        for(var i=0; i<oItem.childNodes.length; i++)
        {
         var x = oItem.childNodes[i];
         if(typeof(x.tagName) == 'undefined') continue;
         x.className = "";
        }
        $(tabid).className = "active";
        var dvs=$("cnt2").getElementsByTagName("li");
        for (var i=0; i<dvs.length; i++)
        {
                if (dvs[i].id==('d'+tabid)){
					dvs[i].style.display='block';
				}
                else
                {dvs[i].style.display='none';}
        }
}


function adpictures(){//ad picture
setTimeout('change_img()',5000);
}
var temp = 1;
function change_img()
{
 if(temp>8) temp=1
 setTimeout('setFocus1('+temp+')',5000);
 temp++;
// alert(temp);
 tt=setTimeout('change_img()',5000);
}
function setFocus1(i)
{
 selectLayer1(i);
}
function selectLayer1(i)
{
	//alert($("focusPic1"));
 switch(i)
 {
 case 1:
 $("focusPic1").style.display="block";
$("focusPic2").style.display="none";
$("focusPic3").style.display="none";
$("focusPic4").style.display="none";
$("focusPic5").style.display="none";
$("focusPic6").style.display="none";
$("focusPic7").style.display="none";
 $("focusPic1nav").style.display="block";
$("focusPic2nav").style.display="none";
$("focusPic3nav").style.display="none";
 $("focusPic4nav").style.display="none";
 $("focusPic5nav").style.display="none";
 $("focusPic6nav").style.display="none";
$("focusPic7nav").style.display="none";
 break;
 case 2:
 $("focusPic1").style.display="none";
 $("focusPic2").style.display="block";
$("focusPic3").style.display="none";
 $("focusPic4").style.display="none";
 $("focusPic5").style.display="none";
$("focusPic6").style.display="none";
$("focusPic7").style.display="none";
 $("focusPic1nav").style.display="none";
 $("focusPic2nav").style.display="block";
$("focusPic3nav").style.display="none";
  $("focusPic4nav").style.display="none";
$("focusPic5nav").style.display="none";
$("focusPic6nav").style.display="none";
$("focusPic7nav").style.display="none";
 break;
case 3:
 $("focusPic1").style.display="none";
 $("focusPic2").style.display="none";
 $("focusPic3").style.display="block";
 $("focusPic4").style.display="none";
 $("focusPic5").style.display="none";
$("focusPic6").style.display="none";
$("focusPic7").style.display="none";
 $("focusPic1nav").style.display="none";
 $("focusPic2nav").style.display="none";
 $("focusPic3nav").style.display="block";
 $("focusPic4nav").style.display="none";
 $("focusPic5nav").style.display="none";
$("focusPic6nav").style.display="none";
$("focusPic7nav").style.display="none";
 break;
case 4:
 $("focusPic1").style.display="none";
 $("focusPic2").style.display="none";
 $("focusPic3").style.display="none";
 $("focusPic4").style.display="block";
$("focusPic5").style.display="none";
$("focusPic6").style.display="none";
$("focusPic7").style.display="none";
 $("focusPic1nav").style.display="none";
 $("focusPic2nav").style.display="none";
 $("focusPic3nav").style.display="none";
 $("focusPic4nav").style.display="block";
$("focusPic5nav").style.display="none";
$("focusPic6nav").style.display="none";
$("focusPic7nav").style.display="none";
 break;
  case 5:
 $("focusPic1").style.display="none";
 $("focusPic2").style.display="none";
 $("focusPic3").style.display="none";
 $("focusPic4").style.display="none";
$("focusPic5").style.display="block";
$("focusPic6").style.display="none";
$("focusPic7").style.display="none";
 $("focusPic1nav").style.display="none";
 $("focusPic2nav").style.display="none";
 $("focusPic3nav").style.display="none";
 $("focusPic4nav").style.display="none";
 $("focusPic5nav").style.display="block";
$("focusPic6nav").style.display="none";
$("focusPic7nav").style.display="none";
 break;
case 6:
 $("focusPic1").style.display="none";
 $("focusPic2").style.display="none";
 $("focusPic3").style.display="none";
 $("focusPic4").style.display="none";
$("focusPic5").style.display="none";
$("focusPic6").style.display="block";
$("focusPic7").style.display="none";
 $("focusPic1nav").style.display="none";
 $("focusPic2nav").style.display="none";
 $("focusPic3nav").style.display="none";
 $("focusPic4nav").style.display="none";
 $("focusPic5nav").style.display="none";
 $("focusPic6nav").style.display="block";
$("focusPic7nav").style.display="none";
 break;
 
case 7:
 $("focusPic1").style.display="none";
 $("focusPic2").style.display="none";
 $("focusPic3").style.display="none";
 $("focusPic4").style.display="none";
$("focusPic5").style.display="none";
$("focusPic6").style.display="none";
$("focusPic7").style.display="block";
 $("focusPic1nav").style.display="none";
 $("focusPic2nav").style.display="none";
 $("focusPic3nav").style.display="none";
 $("focusPic4nav").style.display="none";
 $("focusPic5nav").style.display="none";
 $("focusPic6nav").style.display="none";
  $("focusPic7nav").style.display="block";
 break;
 
 }
}

function initXHR(){//初始化XMLHttpRequest对象
		var xhr = null;
		try {
			xhr=new window.ActiveXObject("Msxml2.XMLHTTP");
		}catch (e){
			try {
				xhr=new window.ActiveXObject("Microsoft.XMLHTTP");	
			}catch (E){
				xhr=false;
			}
		}		
		if(!xhr && typeof XMLHttpRequest !="undefined"){
			xhr= new XMLHttpRequest();	
		}
		
		return xhr;
}

function airlinesOneway(){//机票预订
		clearchildnodes("flightInfo");
		$("airlines").style.display="block";
		$("boutarea").style.display="none";
		$("moreline").style.display="none";
}

function airlinesBout(){
		clearchildnodes("flightInfo");
		$("airlines").style.display="block";
		$("boutarea").style.display="block";
		$("moreline").style.display="none";
		$("iDate2return").innerHTML = "Return Date:";
			
}
function airlinesMoreline(){
		clearchildnodes("flightInfo");
		$("airlines").style.display="block";
		$("boutarea").style.display="block";
		$("moreline").style.display="block";
		$("iDate2return").innerHTML = "Depart Date:";
			
}

function orderFood(){//餐食预定
	var foodID = $("foodID").value;
	var foodMb = $("foodMb").value;
	var foodurl ="http://airport.csair.com/food/app?service=external/Login&sp="
	if (foodID.length == 0){
		clearchildnodes("foodInfo");
		$("foodInfo").innerHTML="ID No error."
	}else if(foodMb.length == 0){
		clearchildnodes("foodID");
		$("foodInfo").innerHTML="Mobile error."
	}else{
		window.location.href=foodurl+"S"+foodID+"&sp=S"+foodMb;	
	}
		
}

function baggage(){//行李查询
	var baggageNo = $("baggageNo").value;
	var passengerIdTel = $("passengerIdTel").value;
	var baggageInfoSelect =$("baggageInfoSelect").value;
	var passengerInfoSelect =$("passengerInfoSelect").value;
	var ApUrl="http://airport.csair.com/outbaggage/app?service=external/OutWebHomeEn&sp="
	//var ApUrl="http://172.16.22.6/outbaggage/app?service=external/OutWebHomeEn&sp="
	if (baggageNo.length == 0){
		clearchildnodes("baggageInfo");
		if(baggageInfoSelect == "ahSuffix"){
		//$("baggageInfo").innerHTML="请您输入查询编号。"
		$("baggageInfo").innerHTML="Please enter your reference number"
		}else{
		//$("baggageInfo").innerHTML="请您输入行李牌号码。"
		$("baggageInfo").innerHTML="Error!"
		}
	}else if(passengerIdTel.length == 0){
		clearchildnodes("baggageInfo");
		if(passengerInfoSelect == "passengerTel"){
		//$("baggageInfo").innerHTML="请您输入电话号码。"
		$("baggageInfo").innerHTML="Error!"
		}else{
		//$("baggageInfo").innerHTML="请您输入证件号码。"
		$("baggageInfo").innerHTML="Error!"
		}
	}else{
		clearchildnodes("baggageInfo");
		window.location.href=ApUrl+"S"+baggageInfoSelect+"&sp=S"+baggageNo+"&sp=S"+passengerInfoSelect+"&sp=S"+passengerIdTel;	
	}		
}

function airport(){//网上值机
	var ApId = $("ApId").value;
	var ApFlt = $("ApFlt").value;
	var ApMb = $("ApMb").value;
	var ApUrl ="http://airport.csair.com/cki/app?service=external/login&sp=Sen&sp="
	//var ApUrl ="http://10.108.71.18/cki/app?service=external/login&sp=Sen&sp="
	if (ApId.length == 0){
		clearchildnodes("ApInfo");
		$("ApInfo").innerHTML="ID No error."
	}else if(ApFlt.length == 0){
		clearchildnodes("ApInfo");
		$("ApInfo").innerHTML="Flight No error."
	}else if(ApMb.length == 0){
		clearchildnodes("ApInfo");
		$("ApInfo").innerHTML="Mobile error."	
	}else{
		clearchildnodes("ApInfo");
		window.location.href=ApUrl+"S"+ApId+"&sp=S"+ApFlt+"&sp=S"+ApMb;	
	}
		
}

/* submit hotel */
function requestHotel(){
	var weburl1="http://travel.feinar.com/feinar/hotel/hotellist.asp";
	var price_high = escape($("price_high").value);
	var star = escape($("star").value);
	var hotel_class = escape($("hotel_class").value);
	var city_name = escape($("city_name").value);
	var radio_tmp = escape($("radio_tmp").value);
	var hotel_name = escape($("hotel_name").value);
	var rq_stay = escape($("rq_stay").value);
	var rq_leave = escape($("rq_leave").value);
	var postDate =weburl1+"?price_high="+price_high+"&star="+star+"&hotel_class="+hotel_class+"&city_name="+city_name+"&radio_tmp="+radio_tmp+"&hotel_name="+hotel_name+"&rq_stay="+rq_stay+"&rq_leave="+rq_leave;
	
	var nowDate = new Date();
	var nowYear = nowDate.getFullYear();
	var nowMonth = nowDate.getMonth()+1;
	if (nowMonth < 10){
		nowMonth = "0"+nowMonth;
	}	
	var nowday = nowDate.getDate();
	if (nowday < 10){
		nowday = "0"+nowday;
	}	
	var strDate=nowYear+nowMonth+nowday;
	
	if (city_name.length == 0){
		clearchildnodes("hotelInfo");
		$("hotelInfo").innerHTML="Select an Airport";
	}else if(rq_stay.length == 0){
		clearchildnodes("hotelInfo");
		$("hotelInfo").innerHTML="tester";
	}else if(rq_leave.length == 0){
		clearchildnodes("hotelInfo");
		$("hotelInfo").innerHTML="test";
	}else if((rq_stay.replace("-","")).replace("-","")<strDate){
		clearchildnodes("hotelInfo");
		$("hotelInfo").innerHTML="#";
	}else if((rq_stay.replace("-","")).replace("-","")>(rq_leave.replace("-","")).replace("-","")){
		clearchildnodes("hotelInfo");
		$("hotelInfo").innerHTML="#";
	}else{
		window.location.href = postDate;
	}
}
/* end submit hotel */

/* submit Travel*/
function requestTravel(){
	var weburl1="http://travel.feinar.com/feinar/tours/tour_lists.asp"
	var Depart_Class = document.getElementsByName("Depart_Class");
	for(var i = 0; i< Depart_Class.length; i++){
		if (Depart_Class[i].checked){
			var Depart_Class = Depart_Class[i].value;
		}
	}
	var Depart_City = escape($("Depart_City").value)
	var Order_City = escape($("Order_City").value)
	var postDate =weburl1+"?Depart_Class="+Depart_Class+"&Depart_City="+Depart_City+"&Order_City="+Order_City
	if (Depart_City.length == 0){
		clearchildnodes("travelInfo");
		$("travelInfo").innerHTML="Select an Airport"
	}else if(Order_City.length == 0){
		clearchildnodes("hotelInfo");
		$("travelInfo").innerHTML="Select an Airport"
	}else if(Order_City == Depart_City){
		clearchildnodes("hotelInfo");
		$("travelInfo").innerHTML="Airport Error"
	}else{
		window.location.href = postDate;
	}
}
/* end submit Travel */

/* 默认时间*/
function setDefaultTime(dateEle){
	var nowDate = new Date();
	var nowYear = nowDate.getFullYear();
	var nowMonth = nowDate.getMonth()+1;
	if (nowMonth < 10){
		nowMonth = "0"+nowMonth;
	}	
	var nowday = nowDate.getDate();
	if (nowday < 10){
		nowday = "0"+nowday;
	}	
	var strDate=nowYear+"-"+nowMonth+"-"+nowday;
	$(dateEle).value = strDate;
}

function setDefaultTimeBack(dateEle){
	var nowDate = new Date();
	nowDate.setDate(nowDate.getDate() + 1);
	var nowYear = nowDate.getFullYear();
	var nowMonth = nowDate.getMonth()+1;
	if (nowMonth < 10){
		nowMonth = "0"+nowMonth;
	}	
	var nowday = nowDate.getDate();
	if (nowday < 10){
		nowday = "0"+nowday;
	}	
	var strDate=nowYear+"-"+nowMonth+"-"+nowday;
	$(dateEle).value = strDate;
}

/* 机票预定提交表单*/
function fltForm(){
	var arrSegtype = document.getElementsByName("segtype");
	var segtype="";
	for(var i = 0; i<arrSegtype.length; i++){
		if(arrSegtype[i].checked){
			segtype = arrSegtype[i].value; 	
		}
	}
	var adultno = $("adult").value;
	var childno = $("child").value;
	var cabinorder = $("cabinorder").value;
	var isDirect = $("isDirect").value;
	var language = $("language").value;
	var city1 = $("city1").value;
	var city2 = $("city2").value;
	var date1 = $("date1").value;
	var date2 ="";
	var date3 ="";
	var date4 ="";
	var date5 ="";
	var date22;
	var date33;
	var date44;
	var date55;
	date11 = (date1.replace("-","")).replace("-","");
	if($("date2")){
		if(segtype=="S"){
			date22 = (date1.replace("-","")).replace("-","");
		}else{
			date2 = $("date2").value;
			date22 = (date2.replace("-","")).replace("-","");
		}
	}
	if($("date3")){
		date3 = $("date3").value;
		date33 = (date3.replace("-","")).replace("-","");
		date4 = $("date4").value;
		date44 = (date4.replace("-","")).replace("-","");
		date5 = $("date5").value;
		date55 = (date5.replace("-","")).replace("-","");
	}
	var city3="";
	var city4="";
	var city5="";
	var city6="";
	if($("city3")){
		city3 = $("city3").value;
		city4 = $("city4").value;
		city5 = $("city5").value;
		city6 = $("city6").value;
	}
	
	var cityStr="";
	var dateCount = 1;
	var cityCount = 2;
	if(segtype == "S"){
			cityStr = "@"+city1+"@"+city2;
	}else if(segtype == "R"){
			cityStr = "@"+city1+"@"+city2+"@"+city1;
			dateCount = 2;
	}else if(segtype == "M"){
		for(var i = 1; i<= 6; i++){
			if(eval("city"+i)!="" && eval("city"+i)!= null && eval("city"+i)!= "undefined"){
					cityStr +="@"+eval("city"+i)
			}
		}
		dateCount = 5;
		cityCount = 6;
	}else{
		$("flightInfo").innerHTML="Select Flight Error";
		return false;
	}
	cityStr = cityStr.substring(1);
	
	var inter ="";
	for (var k = 1 ; k <= cityCount; k++){
		for (var i= 0; i<strInternational.length; i++){
			if(eval("city"+k)!="" && eval("city"+k)!= null && eval("city"+k)!= "undefined"){
				if(eval("city"+k) == strInternational[i]){
					inter = "Y";
				}
			}
		}
	}
	
	
	var dateStr="";
	for(var i = 1; i<= dateCount; i++){
		if(eval("date"+i)!="" && eval("date"+i)!= null && eval("date"+i)!= "undefined"){
				dateStr +="#"+eval("date"+i)
			}	
	}
	dateStr = dateStr.substring(1);
	
	
	var nowDate = new Date();
	var nowYear = nowDate.getFullYear();
	var nowMonth = nowDate.getMonth()+1;
	if (nowMonth < 10){
		nowMonth = "0"+nowMonth;
	}	
	var nowday = nowDate.getDate();
	if (nowday < 10){
		nowday = "0"+nowday;
	}
	var entryno = "";
	if(inter=="Y"){
		entryno="0";
	}else{
		entryno="1";
	}
	var strDate=nowYear+""+nowMonth+""+nowday;
	
	var flightInfo ="";
	
	flightInfo+=entryno+"%"+segtype+"%"+cabinorder+"%"+isDirect+"%"+adultno+"%"+childno+"%"+cityStr+"%"+dateStr;
	
	
	var  bookInterCity="N";
	if(inter == "Y"){
		if(segtype=="S" || segtype=="R"){
			if(city1=="CAN"){
				if("HKGSINLAXJKTPAR".indexOf(city2)==-1)  bookInterCity="Y";
			}else{
				if(city2=="CAN"){
					if("HKGSINLAXJKTPAR".indexOf(city1)==-1)  bookInterCity="Y";
				}else{
					bookInterCity="Y";
				}
			}
		}else{
			bookInterCity="Y";
		}
	}
	
	
	if (city1 == city2){
		clearchildnodes("flightInfo");
		$("flightInfo").innerHTML="Airport Error";
		return false;
	}else if(date11 < strDate){
		clearchildnodes("flightInfo");
		$("flightInfo").innerHTML="Date Error";
		return false;
	}else if(date11>date22){
			clearchildnodes("flightInfo");
			$("flightInfo").innerHTML="Date Error";
			return false;
	}else if(segtype == "M"){
		var cityint = 0;
		var dateint = 0;
		var date6;
		for (var i=1;i<=6;i++){
			if(eval("city"+i)){
				cityint+=1;	
			}
			if(eval("date"+i)){
				dateint	+=1;
			}
		}
		if(city3==""){
			clearchildnodes("flightInfo");
			$("flightInfo").innerHTML="Airport Error";
			return false;
		}else if(cityint<=dateint){
			clearchildnodes("flightInfo");
			$("flightInfo").innerHTML="Airport Error";
			return false;
		}else{
			//alert("city:"+cityStr);
		//alert("date:"+dateStr);
			if(inter == "Y"){
			 international_link(segtype,adultno,childno,cityStr,dateStr,language);
             return false;
			}else{
					if(language=="zh"){
						$("conditionStrInternalZH").value=flightInfo;
						$("conditionStrFormInternalZH").submit();	
					}else if(language=="en"){
						$("conditionStrInternalEN").value=flightInfo;
						$("conditionStrFormInternalEN").submit();			
					}else{
						
					}
			}	
		}
	}else{
		//alert("city:"+cityStr);
		if(inter == "Y"){
			international_link(segtype,adultno,childno,cityStr,dateStr,language);
             return false;
		}else{
				if(language=="zh"){
					$("conditionStrInternalZH").value=flightInfo;
					$("conditionStrFormInternalZH").submit();	
				}else if(language=="en"){
					$("conditionStrInternalEN").value=flightInfo;
					$("conditionStrFormInternalEN").submit();			
				}else{
					
				}
		}
	}
}


function international_link (segtype,adultno,childno,cityStr,dateStr,language){
                            //var urlString="http://siteacceptance.wftc3.e-travel.com/plnext/CAZG/Override.action?";
							var urlString="http://wftc3.e-travel.com/plnext/CAZG/Override.action?";
                            urlString += (language == "zh")?"LANGUAGE=CN&":"LANGUAGE=GB&";
                            urlString += (segtype == "S")?"TRIP_TYPE=O&":((segtype =="R")?"TRIP_TYPE=R&":"TRIP_TYPE=M&");
                            urlString += (segtype == "M")?"EMBEDDED_TRANSACTION=AirComplexAvailability&":"EMBEDDED_TRANSACTION=AirAvailability&";
                            var cityarr = cityStr.split("@");
                            for(i=0;i<cityarr.length-1;i++){
                                     urlString += "B_LOCATION_"+(i+1)+"="+cityarr[i]+"&"+"E_LOCATION_"+(i+1)+"="+cityarr[i+1]+"&";
                            }
                            var datearr = dateStr.split("#");
                            for(i=0;i<cityarr.length-1;i++){
                                     urlString += "B_DATE_"+(i+1)+"="+datearr[i].substring(0,4)+datearr[i].substring(5,7)+datearr[i].substring(8,10)+"0000&";
                                     urlString += "B_ANY_TIME_"+(i+1)+"=true&";
                                     urlString += "AIRLINE_"+(i+1)+"_1=CZ&";
                            }
                            for(i=0;i<adultno;i++){
                                     urlString += "TRAVELLER_TYPE_"+(i+1)+"=ADT&";
                            }
                            for(i=0;i<childno;i++){
                                     urlString += "TRAVELLER_TYPE_"+(adultno+i+1)+"=CHD&";
                            }
                            //urlString += "CABIN=E&";
                            //urlString += "SO_SITE_EXT_PSPURL=https%3A%2F%2Fmigs.gcxcorp.com%2Ftest%2F1A_CZ_Payment%2Famadeus2migs.aspx&";
                            urlString += "SITE=CAZGCAZG&SO_SITE_POINT_OF_SALE=PEK&TRIPFLOW=YES&EXTERNAL_ID=US&DIRECT_LOGIN=NO&HAS_INFANT_1=FALSE&HAS_INFANT_2=FALSE&SO_SITE_MOP_CALL_ME=FALSE&SO_SITE_ET_CODE_SHARE=00";
                            urlString += "&SO_GL=%3C%3Fxml+version%3D%271.0%27+encoding%3D%27iso-8859-1%27%3F%3E%3CSO_GL%3E%0D%0A%3CGLOBAL_LIST+mode%3D%27complete%27%3E%3CNAME%3ESO_SINGLE_MULTIPLE_COMMAND_BUILDER%3C%2FNAME%3E%0D%0A%3CLIST_ELEMENT%3E%0D%0A%3CCODE%3E1%3C%2FCODE%3E%0D%0A%3CLIST_VALUE%3E%3C%21%5BCDATA%5BOS+YY+IP+%3CCLIENT_IP_ADDRESS%3E%5D%5D%3E%3C%2FLIST_VALUE%3E%0D%0A%3CLIST_VALUE%3EM%3C%2FLIST_VALUE%3E%0D%0A%3C%2FLIST_ELEMENT%3E%0D%0A%3CLIST_ELEMENT%3E%0D%0A%3CCODE%3E2%3C%2FCODE%3E%0D%0A%3CLIST_VALUE%3E%3C%21%5BCDATA%5BAPE-%3CUSERMAIL_COMPLETE%3E%5D%5D%3E%3C%2FLIST_VALUE%3E%0D%0A%3CLIST_VALUE%3EM%3C%2FLIST_VALUE%3E%0D%0A%3C%2FLIST_ELEMENT%3E%0D%0A%3CLIST_ELEMENT%3E%0D%0A%3CCODE%3E3%3C%2FCODE%3E%0D%0A%3CLIST_VALUE%3E%3C%21%5BCDATA%5BSRCKIN-CHECK+ID+AND+CREDIT+CARD+AT+CHK-IN%5D%5D%3E%3C%2FLIST_VALUE%3E%0D%0A%3CLIST_VALUE%3EM%3C%2FLIST_VALUE%3E%0D%0A%3C%2FLIST_ELEMENT%3E%0D%0A%3C%2FGLOBAL_LIST%3E%0D%0A%3C%2FSO_GL%3E%0D%0A";
 //return;
                            //alert("entryno"+entryno);
                            //alert("segtype"+segtype);
                            //alert("cabinorder"+cabinorder);
                            //alert("isDirect"+isDirect);
                            //alert("adultno"+adultno);
                            //alert("childno"+childno);
                            //alert("cityStr"+cityStr);
                            //alert("dateStr"+dateStr);
                            //alert("language"+language);
window.location.href=urlString;
}

/*国际航线限制选择儿童*/
function internationalChild(city){
	/*var strcity2 = $(city).value;*/
	var temp = true;
	/*for (var i= 0; i<strInternational.length; i++){
		if(strcity2 == strInternational[i]){
			clearchildnodes("childCount");
			$("childCount").innerHTML = "<select name='child' id='child'><option value='0'>0</option></select>";
			temp = false;
		}
	}*/
	
	if(temp){
		adultchild();
	}
}

function removeObj(){//点击标题栏触发的事件
	clearpresentnode("bgIframe");//删除背景层iframe
    clearpresentnode("bgDiv");//删除背景层Div
    clearpresentnode("msgDiv");//删除提示框层
}

function alertInfo(){
	var str ="<b style='margin-bottom:10px; display:block;'>Friendly Reminder:</b><ol style='margin-top:0;margin-bottom:0;'><li style='margin-bottom:10px;'>Valid dates of the international flight booking are 3days from now through the next 11 months; please confirm you have chosen the correct date.</li><li style='margin-bottom:10px;'>If you try to purchase your ticket with a bank card issued outside of Mainland China and or without a UnionPay logo, please visit our <a href='http://www.flychinasouthern.com/'>Global Website</a> to continue;</li><li>During filling in the identification information, for ChinaMainland Citizens, please fill in valid passport numbers for international flights; and fill in valid Hong Kong/Macau travel pass numbers for traveling to Hong Kong and Macau. For Foreign Countries Citizens, Hong Kong and Macau Residents and Taiwan fellow citizens, please fill in valid passport, China entry pass, resident pass, or travel pass numbers accordingly.</li><li style='margin-bottom:10px;'>Before you travel, please make sure you have a valid passport, visa, and have completed any necessary travel applications.  Passengers should carry their passports, visa, and any travel documents on them at all time, do not leave them in check-in baggage.  China Southern will not be responsible for the loss if passenger fail to provide valid travel documentation for travel.</li><li style='margin-bottom:10px;'> During the payment process, please do not close the browser.</li><li style='margin-bottom:10px;'>After your refund request is accepted, the refund amount will be credited back to your bank account in about 15 days.</li><li style='margin-bottom:10px;'>If you are an exchange student or a new immigrant of Australia and would like to benefit from the extra baggage allowance program, please proceed to the local China Southern Office.  Once you purchase your ticket online, the baggage allowance CANNOT be increased.</li><li style='margin-bottom:10px;'>If you have any questions, please contact the China Southern Customer Service Hotline: 4006695539 or 0086-20-22395539, or email to flychinasouthern@cs-air.com.</li></ol><p align='center'><input type='button' value='Confirm' onclick='return fltForm();' />&nbsp;&nbsp;&nbsp;<input type='button' value='Cancel' onclick='removeObj()' /></p>";
  var msgw,msgh,bordercolor;
  msgw=580;//提示窗口的宽度
  msgh=560;//提示窗口的高度
  bordercolor="#007CBA";//提示窗口的边框颜色
  titlecolor="#99CCFF";//提示窗口的标题颜色

  var sWidth,sHeight;
  sWidth=document.body.offsetWidth;//浏览器工作区域内页面宽度
  sHeight=screen.height;//屏幕高度（垂直分辨率）
  
  
  bod = document.getElementsByTagName('body')[0];//清除垂直滚动条
  bod.style.height = '100%';
  bod.style.overflow = 'hidden';
				  
  htm = document.getElementsByTagName('html')[0];//清除垂直滚动条
  htm.style.height = '100%';
  htm.style.overflow = 'hidden';

  
  cWidth = ((msgw+10)/2)+"px";
  cHeight = ((msgh+10)/2)+"px";

  //背景层（大小与窗口有效区域相同，即当弹出对话框时，背景显示为放射状透明灰色）
  var bgObj=document.createElement("iframe");
  bgObj.setAttribute('id','bgIframe');
  bgObj.style.position="absolute";
  bgObj.style.top="0";
  bgObj.style.background="#666";
  bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0,finishOpacity=0";
  bgObj.style.opacity="0.0";
  bgObj.style.left="0";
  bgObj.style.width=sWidth + "px";
  bgObj.style.height=sHeight + "px";
  bgObj.style.textAlign = "center";
  bgObj.style.zIndex = "9999";
  document.body.appendChild(bgObj);//在body内添加该div对象
  
  var bgObj2=document.createElement("div");
  bgObj2.setAttribute('id','bgDiv');
  bgObj2.style.position="absolute";
  bgObj2.style.top="0";
  bgObj2.style.background="#666";
  bgObj2.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
  bgObj2.style.opacity="0.6";
  bgObj2.style.left="0";
  bgObj2.style.width=sWidth + "px";
  bgObj2.style.height=sHeight + "px";
  bgObj2.style.textAlign = "center";
  bgObj2.style.zIndex = "10000";
  document.body.appendChild(bgObj2);//在body内添加该div对象

  var msgObj=document.createElement("div")//创建一个div对象（提示框层）
  msgObj.setAttribute("id","msgDiv");
  msgObj.setAttribute("align","left");
  msgObj.style.background="white";
  msgObj.style.border="5px solid " + bordercolor;
  msgObj.style.padding="0 10px"
  msgObj.style.position = "absolute";
  msgObj.style.left = "50%";
  msgObj.style.top = "50%";
  msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
  msgObj.style.marginLeft = "-" + cWidth;
  msgObj.style.marginTop = "-" + cHeight
  msgObj.style.width = msgw + "px";
  msgObj.style.height = msgh + "px";
  msgObj.style.textAlign = "justify";
  msgObj.style.lineHeight ="18px";
  msgObj.style.zIndex = "10001";
  msgObj.style.textJustify="inter-ideograph";

  document.body.appendChild(msgObj);//在body内添加提示框div对象msgObj

  var txt=document.createElement("div");//创建一个div对象（提示框提示信息）
  txt.style.margin="1em 0"
  txt.setAttribute("id","msgTxt");
  txt.innerHTML=str;//来源于函数调用时的参数值
  
  document.getElementById("msgDiv").appendChild(txt);//在提示框div中添加提示信息对象txt
}


/*成人儿童选择关系*/
function adultchild(){
	var strAdult = $("adult").value;
	var strcity2 = $("city2").value;
	var strcity1 = $("city1").value;
	var temp = true;
	for (var i= 0; i<strInternational.length; i++){
		if((strcity2 == strInternational[i])||(strcity1 == strInternational[i])){
			temp = false;
		}
	}
	
	if (strAdult == 1 && temp){
		clearchildnodes("childCount");
		$("childCount").innerHTML = "<select name='child' id='child'><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option></select>"
	}else if(strAdult == 2 && temp){
		clearchildnodes("childCount");
		$("childCount").innerHTML = "<select name='child' id='child'><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option></select>"
	}else if(strAdult == 3 && temp){
		clearchildnodes("childCount");
		$("childCount").innerHTML = "<select name='child' id='child'><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option></select>"
	}else if(strAdult == 4 && temp){
		clearchildnodes("childCount");
		$("childCount").innerHTML = "<select name='child' id='child'><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option></select>"
	}else if(strAdult == 5 && temp){
		clearchildnodes("childCount");
		$("childCount").innerHTML = "<select name='child' id='child'><option value='0'>0</option><option value='1'>1</option></select>"
	}else if(strAdult == 6 && temp){
		clearchildnodes("childCount");
		$("childCount").innerHTML = "<select name='child' id='child'><option value='0'>0</option></select>"
	}else{
			
	}
}

/*初始化*/
function  iniPage(){
	$("oneway").checked=true;
	$("all").checked=true;
}

/*loading*/
window.onload = function() {
	iniPage();
	if($("date1").value == ""){
		setDefaultTime("date1");
	}
	if($("date2")){
		setDefaultTimeBack("date2")
	}
	copyrightDate();
	adpictures();
	adultchild();
	internationalChild("city1");
	internationalChild("city2");
	
	if($("foodsubmit")){
		var EventEle=$("foodsubmit");
		var mouseRouter=new jsEvent.EventRouter(EventEle,'onclick');
		mouseRouter.addListener(orderFood);
	}
	if($("baggagesubmit")){
		var EventEle_1=$("baggagesubmit");
		var mouseRouter=new jsEvent.EventRouter(EventEle_1,'onclick');
		mouseRouter.addListener(baggage);
	}
	if($("ApBtn")){
		var EventEle_1=$("ApBtn");
		var mouseRouter=new jsEvent.EventRouter(EventEle_1,'onclick');
		mouseRouter.addListener(airport);
	}
	var EventEle_2 = $("oneway")
	var mouseRouter=new jsEvent.EventRouter(EventEle_2,'onclick');
	mouseRouter.addListener(airlinesOneway);
	
	var EventEle_3 = $("bout")
	var mouseRouter=new jsEvent.EventRouter(EventEle_3,'onclick');
	mouseRouter.addListener(airlinesBout);
	
	var EventEle_4 = $("more")
	var mouseRouter=new jsEvent.EventRouter(EventEle_4,'onclick');
	mouseRouter.addListener(airlinesMoreline);
	
	var EventEle_7 = $("adult");
	var mouseRouter=new jsEvent.EventRouter(EventEle_7,'onchange');
	mouseRouter.addListener(adultchild);
	
}
