﻿        var lastClickTime=null;  
        var international=false;//国际查询标志
        var dayOfWeek = new Array('星期日','星期一','星期二','星期三','星期四','星期五','星期六');

        function initdate(){
	        document.getElementById('dayNum').value = dayOfWeek[new Date().getDay()];
	        var today = new Date();
	        var year = (today.getFullYear()>1900)?today.getFullYear():today.getFullYear()+1900;
	        showstr(document.getElementById('year'),document.getElementById('month'),document.getElementById('date'),year,today.getMonth()+1,today.getDate());
	        showstr(document.getElementById('back_year'),document.getElementById('back_month'),document.getElementById('back_date'),year,today.getMonth()+1,today.getDate());
        }

        function setdepdate(cal1){
	        bdate = cal1.date;
			if(document.getElementById('year')!=null)
			{			
	          showstr(document.getElementById('year'),document.getElementById('month'),document.getElementById('date'),bdate.getFullYear(),bdate.getMonth()+1,bdate.getDate());
			}
        }
        function setrtndate(cal2){
	        edate = cal2.date;
			if(document.getElementById('back_year')!=null)
			{
	          showstr(document.getElementById('back_year'),document.getElementById('back_month'),document.getElementById('back_date'),edate.getFullYear(),edate.getMonth()+1,edate.getDate());
			}
        }
        function showstr(yearObj,monthObj,dateObj,year,month,date){
	        for (var i = 1;i<yearObj.options.length;i++){
		        if(yearObj.options[i].text.indexOf(year)>-1){
			        yearObj.options[i].selected = true;
			        break;
		        }
	        }
	        monthObj.options[month].selected = true;
	        dateObj.options[date].selected = true;
	        setDateDayNum();
	        setDateDayNum_r();
        }

        function login()
        {
	        if(loginform.usrid.value==""){
		        alert_simple_traditional("请输入用户名！");
		        return false;
	        }
	        else if(loginform.password.value==""){
		        alert_simple_traditional("请输入密码！");
		        return false;
	        }
	        else if(loginform.certify.value==""){
		        alert_simple_traditional("请输入验证码！");
		        return false;
	        }
	        return true;
        }

        //joly点击查询确定之后的处理方法
        function goaction(formobj)
        {
          //三秒内点击提交按钮无效
  	        var currentClickTime=new Date(); 
  	        if(lastClickTime==null){                                                  
		        lastClickTime=currentClickTime;                                   
  	        }else if(currentClickTime.getTime()-lastClickTime.getTime()<3000){      
		        lastClickTime=currentClickTime; 
		        //alert_simple_traditional("系统正在处理您的查询操作！如果需要进行新的查询，请从现在起3秒钟后再进行查询！");       
		        return;	                                                    
	        }else{                                                              
		        lastClickTime=currentClickTime;		                    
	        }                                                                   
	        var internationalformobj = document.airQueryForm;
  	        var actionkind="";
  	        var year,month,day;
  	        var queryAdultNum=formobj.adultNum.value;
  	        var queryChildNum=formobj.childNum.value;
  	        var queryCabinTypeLevel=formobj.queryTypeLevel.value;
          
  	        if(queryAdultNum=="0"&&queryChildNum=="0"){
      	        alert_simple_traditional("请选择乘客数！");
      	        return false;
  	        }
  	        if(queryAdultNum>"0"&&queryChildNum>"0"&&queryCabinTypeLevel!="economy"){
      	        alert_simple_traditional("当既有成人又有儿童的时候只能选择经济舱,请重新选择");
      	        return false;
  	        }

  	        if(queryCabinTypeLevel=="special"){
  		        if (queryChildNum!="0"){
			        alert_simple_traditional("抱歉，特价机票只适用于成人，儿童请选择其他舱位。");
			        return false;
		        }
  	        }
  	        if ((international)&&(queryChildNum!="0")){
  		        alert_simple_traditional("抱歉，本网站暂不支持国际机票中儿童票的出售。");
		        return false;
  	        }
  	        if ((formobj.actionkind.value=="multiseg")&&(queryChildNum!="0")){
  		        alert_simple_traditional("抱歉，多段不支持儿童票的出售。");
		        return false;
  	        } 
  	        actionkind = formobj.actionkind.value;
  	        internationalformobj.cabinClass.value=queryCabinTypeLevel;
  	        internationalformobj.airkind.value=actionkind;
  	        internationalformobj.travelers.value=formobj.adultNum.value;
  	        internationalformobj.adultTravelers.value=formobj.adultNum.value;
  	        internationalformobj.childTravelers.value=formobj.childNum.value;
          
  	        year = "20"+formobj.year.options[formobj.year.selectedIndex].value;
  	        month = formobj.month.selectedIndex;
  	        if(parseInt(month)<10)month = "0"+month;
  	        day = formobj.date.options[formobj.date.selectedIndex].value;
  	        internationalformobj.takeoffDate.value = year+"-"+month+"-"+day;
  	        year = "20"+formobj.back_year.options[formobj.back_year.selectedIndex].value;
  	        month = formobj.back_month.selectedIndex;
  	        if(parseInt(month)<10)month = "0"+month;
  	        day = formobj.back_date.options[formobj.back_date.selectedIndex].value;
  	        internationalformobj.returnDate.value = year+"-"+month+"-"+day;
          
  	        internationalformobj.orgCity.value = formobj.org.value;
  	        internationalformobj.dstCity.value = formobj.dst.value;
  	        if(international){
      	        //internationalformobj.doaction.value="/cab2c/FlightSearch.do";
  	        }
  	        if(actionkind=="airreturn"){
		        if(international){
    		        internationalformobj.tripType.value = "ROUNDTRIP";
    	        }else{
        	        internationalformobj.tripType.value = "airreturn";
    	        }
                
    	        recstr = "";
    	        recstr = detecttwodate(formobj,"出发日期","返程日期");
    	        if (recstr=="成功") {
			        recstr = detecttwowhere(formobj,"出发城市","到达城市");
			        if (recstr=="成功") {
				        document.airQueryForm.submit();
			        }else{
				        alert_simple_traditional(recstr);
			        }	
		        }else{
			        alert_simple_traditional(recstr);
		        } 
  	        }else{
       	        if(actionkind=="multiseg"){
                    internationalformobj.tripType.value = "MultiSeg";
       	        }
       	        recstr = detectonedate(formobj);
	   	        if (recstr=="成功"){  
	   		        recstr = detecttwowhere(formobj,"出发城市","到达城市");
			        if (recstr=="成功"){
               	        document.airQueryForm.submit();
			        }
       	        }else{
			        alert_simple_traditional(recstr);
		        }	
   	        }
        }//end of this function

        function query(formobj)
        {	

	        if (check_simple_traditional_input(formobj.passenger_name))
		        return false;

	        if(formobj.tkt_no.value==""){
		        alert_simple_traditional("请填写您的票号！");
		        return false;
	        }	
	        else if(formobj.passenger_name.value==""){
		        alert_simple_traditional("请填写乘机旅客姓名！");
		        return false;
	        }
	        else if(formobj.tkt_no.value.substring(0,3)!="999"){
		        alert_simple_traditional("抱歉，输入票号错误！请填写您的国航电子票有效票号！");
		        return false;
	        }
	        else{
		        return true;
	        }	
        }

        function setInternational(){
	        international=true;
            document.getElementById("oneway_airkind").checked = true;
            dateDisplay();
            cfcityDisplay();
   	        kindselect();
            document.getElementById('multiseg_airkind').style.display = "none";
	        getObj('multilabel').style.display = "none";
	        document.getElementById("childNumSpan").style.visibility = "hidden";
	        document.getElementById('childNum').value = 0;
	        //getObj("navBody1").style.display = "none";
            //change();
        }

        function setDomain(){
	        international=false;
            document.getElementById("oneway_airkind").checked = true;
            cfcityDisplay();
            kindselect();
	        setOnewayCond();
            setdv(document.getElementById('dst'),'SHA');
	        var airkind = document.getElementsByName("airkind");
	        for (var i=0;i<airkind.length;i++){
		        if(airkind[i].checked){
			        kind = airkind[i].value;
 			        break;
		        }
	        }
	        document.getElementById('multiseg_airkind').style.display ="";
	        getObj('multilabel').style.display = "";
	        document.getElementById("childNumSpan").style.visibility = "visible";
            //change();
        }


        //joly
        function setDateDayNum(){
            var monthValue=getmonthnum(document.getElementById('month').value)-1;
            var yearValue=parseInt(document.getElementById('year').value)+2000;
            var datevalue=document.getElementById('date').value;
	        document.getElementById('dayNum').value = dayOfWeek[new Date(yearValue,monthValue,datevalue).getDay()];
        }

        function setDateDayNum_r(){
            var monthValue=getmonthnum(document.getElementById('back_month').value)-1;
            var yearValue=parseInt(document.getElementById('back_year').value)+2000;
            var datevalue=document.getElementById('back_date').value;
	        document.getElementById('dayNum_Back').value = dayOfWeek[new Date(yearValue,monthValue,datevalue).getDay()];
        }

        //值机输入验证方法
        function checkCheckIn(){
  	        PsrName=document.checkInInoutform.PsrName.value;//值机旅客姓名
	        InputType=document.checkInInoutform.InputType.value; //证件类型
	        InputNumber=document.checkInInoutform.InputNumber.value; //证件号码
	        DeptCity=document.checkInInoutform.DeptCity.value; // 起飞城市
	        MobilePhone=document.checkInInoutform.MobilePhone.value; //手机号码
	        if(PsrName==""){
		        alert_simple_traditional("请输入您购买机票时的旅客姓名!");
		        checkInInoutform.PsrName.focus();
		        return false;
	        }
	        else if(InputNumber=="")
	        {
		        alert_simple_traditional("请输入您的证件号码!");
		        checkInInoutform.InputNumber.focus();
		        return false;
	        }
	        else if((MobilePhone=="")||(MobilePhone.length!=11))
	        {
		        alert_simple_traditional("请输入您的有效手机号码!");
		        checkInInoutform.MobilePhone.focus();
		        return false;
	        }
            document.checkInform.PsrName.value=PsrName;
	        document.checkInform.InputType.value=InputType;
	        document.checkInform.InputNumber.value=InputNumber;
	        document.checkInform.DeptCity.value=DeptCity;
	        document.checkInform.MobilePhone.value=MobilePhone;
            document.checkInInoutform.reset();
            document.checkInform.submit();
        }

        function popCity(){
          // window.open ("/cab2c/html/city.jsp", "newwindow", "height=670, width=520, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no")
        }
        function setOnewayCond(){
	        document.getElementById('sectime').style.display = 'none';
	        document.getElementById("backdate_checkbox").style.display = 'none';
        }
        function setReturnCond(){
            document.getElementById('dayNum_Back').value = dayOfWeek[new Date().getDay()];
	        document.getElementById('sectime').style.display = 'block';
	        document.getElementById("backdate_checkbox").style.display = 'block';
        }

        var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
        // 处理 Flash 影片中的所有 FSCommand 消息
        function canav_DoFSCommand(command, args) {
	        var canavObj = isInternetExplorer ? document.all.canav : document.canav;
	        if (command=="flashnav")
	        {
		        window.location.href=args;
	        }
        }

        var arrs = new Array();

        var XMLHttp;
              
        function createXMLHttpRequest(){
            if(window.ActiveXObject){
    	        XMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
            }else if(window.XMLHttpRequest){
		        XMLHttp=new XMLHttpRequest();
            }
        }

        function addItem(oListbox,sName,sValue){
	        var oOption=document.createElement("option");
            oOption.appendChild(document.createTextNode(sName));
            if(arguments.length==3){
    	        oOption.setAttribute("value",sValue);
            }
            oListbox.appendChild(oOption);
        }

        function handleStateChange(){
            if(XMLHttp.readyState==4){
		        if(XMLHttp.status==200){
        	        updateOckiList();
			        setzhijishijian();//兼容FF
                }
            }
        }
            
        function updateOckiList(){
	        if(arrs.length==0){
		        var models=document.getElementById("DeptCity");
		        var zhijishijiantag=document.getElementById("zhijishijian");
		        var resultscode=XMLHttp.responseXML.getElementsByTagName("cityCode");
		        var resultscn=XMLHttp.responseXML.getElementsByTagName("cityName");
		        var resultdesc=XMLHttp.responseXML.getElementsByTagName("cityDesc");
		        var option=null;
		        var tempCode;
		        var tempCn;
		        zhijishijiantag.innerText=resultdesc[0].firstChild.nodeValue;
		        for(var i=0;i<resultscode.length;i++){
			        tempCn=resultscn[i].firstChild.nodeValue;
			        addItem(models,tempCn,resultscode[i].firstChild.nodeValue);
			        arrs[i]=new Array(resultscode[i].firstChild.nodeValue,resultdesc[i].firstChild.nodeValue);
		        }
            }
        }
            
        function clearModelsList(){
            var models=document.getElementById("models");
            while(models.childNodes.length>0){
	            models.removeChild(models.childNode[0]);
            }
        }

        //ie挂钩
        <!--
        if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	        document.write('<script language=\"VBScript\"\>\n');
	        document.write('On Error Resume Next\n');
	        document.write('Sub canav_FSCommand(ByVal command, ByVal args)\n');
	        document.write('	Call canav_DoFSCommand(command, args)\n');
	        document.write('End Sub\n');
	        document.write('</script\>');
        }
        //-->
 function ConfirmDel()
 {
  
	 if(confirm("确定要删除吗？一旦删除将不能恢复！"))
	 {
		return true;
		}
	else
		 return false;
	
 }

