﻿// JScript 文件


    function isTrueid(s)   
    {   

//alert(s.value);
        var patrn=/^[0-9]*[0-9][0-9]*$/;
        if(s.value.substring(0,1)=="0" &&  s.value.length>1)
        {
                     s.value="";
             return false  ;
        }   
        else
        {
        if (!patrn.exec(s.value))
        {
         
             s.value="";
             return false  ;
         }
         else
         {
 
            return true ;
        } 
        }

    } 
    
//验证后台登陆用户名和密码是否填写    
function ValidateUser()
{
   var user= document.getElementById("TextBox1");
   var pwd = document.getElementById("TextBox2");
   
   if(user.value == null || user.value == "")
   {
    alert("用户名必填!");
    document.getElementById("TextBox1").focus();
    return false;
   }
   if(pwd.value == null || pwd.value == "")
   {
   alert("密码必填!");
   document.getElementById("TextBox2").focus();
   return false;
   }
   return true;
}

function ChengShi()
{
            var fcity1 = document.getElementById("ddlFromCity");
			var fcity =fcity1.options[fcity1.selectedIndex].value;
			
				var tcity1 = document.getElementById("ddlToCity");
			var tcity =tcity1.options[tcity1.selectedIndex].value;
			  var stime = document.getElementById("depart_dateqa");
			  
    var etime = document.getElementById("depart_dateqa0");
        if(fcity == tcity)
    {
        alert("查询城市有误");
        return false;
    }
    if(stime.value==""||stime.value==null)
    {

        document.getElementById("depart_dateqa").focus();
        return false;
    }  
    if(stime.value==""||stime.value==null)
    {
        document.getElementById("depart_dateqa").focus();
        return false;
    }  

    var date=new Date(); 
    var date_arr=document.getElementById("depart_dateqa").value.split("-"); 

    var year=parseInt(date_arr[0]); 

    var month=parseInt(date_arr[1],10)-1; 

    var day=parseInt(date_arr[2],10); 

    var date1=new Date(year,month,day); 
    var year1=date.getYear();
    var month1=date.getMonth();

    var day1=date.getDate();
    var date2=new Date(year1,month1,day1);

    if(date2>date1)
    { 
        alert("不能查询今天以前的航班！！"); 
        return false;
    } 
    window.location.href="guodu.aspx?hcid="+fcity+tcity+"&Flighttime="+stime.value+"&type=1";
  }
  
  function searchs()
  {
        var radio1 = document.getElementsByName('TripType');
        if(radio1.item(0).checked)
        {
            var fcity1 = document.getElementById("ddlFromCity");
	        var fcity =fcity1.options[fcity1.selectedIndex].value;
			
	        var tcity1 = document.getElementById("ddlToCity");
	        var tcity =tcity1.options[tcity1.selectedIndex].value;
			
	        var stime = document.getElementById("depart_dateqa");
            if(fcity == tcity)
            {
                alert("出发城市和到达城市不能一致");
                return false;
            }
            var stime = document.getElementById("depart_dateqa");
            if(stime.value==""||stime.value==null)
            {
                document.getElementById("depart_dateqa").focus();
                return false;
            }  

            var date=new Date(); 
            var date_arr=document.getElementById("depart_dateqa").value.split("-"); 

            var year=parseInt(date_arr[0]); 

            var month=parseInt(date_arr[1],10)-1; 

            var day=parseInt(date_arr[2],10); 

            var date1=new Date(year,month,day); 
            var year1=date.getYear();
            var month1=date.getMonth();

            var day1=date.getDate();
            var date2=new Date(year1,month1,day1);

            if(date2>date1)
            { 
                alert("不能查询今天以前的航班！！"); 
                return false;
            }
            
            window.location.href="guodu.aspx?hcid="+fcity+tcity+"&Flighttime="+stime.value+"&type=1";
        }
        else if(radio1.item(1).checked)
        {
            var fcity1 = document.getElementById("ddlFromCity");
	        var fcity =fcity1.options[fcity1.selectedIndex].value;
			
	        var tcity1 = document.getElementById("ddlToCity");
	        var tcity =tcity1.options[tcity1.selectedIndex].value;
			
	        var stime = document.getElementById("depart_dateqa");
            if(fcity == tcity)
            {
                alert("出发城市和到达城市不能一致");
                return false;
            }
            var stime = document.getElementById("depart_dateqa");
            if(stime.value==""||stime.value==null)
            {
                document.getElementById("depart_dateqa").focus();
                return false;
            }  

            var date=new Date(); 
            var date_arr=document.getElementById("depart_dateqa").value.split("-"); 

            var year=parseInt(date_arr[0]); 

            var month=parseInt(date_arr[1],10)-1; 

            var day=parseInt(date_arr[2],10); 

            var date1=new Date(year,month,day); 
            var year1=date.getYear();
            var month1=date.getMonth();

            var day1=date.getDate();
            var date2=new Date(year1,month1,day1);

            if(date2>date1)
            { 
                alert("不能查询今天以前的航班！！"); 
                return false;
            }
            
            
            
            var dtime = document.getElementById("depart_dateqa2");
            if(dtime.value==""||dtime.value==null)
            {
                document.getElementById("depart_dateqa2").focus();
                return false;
            }  
            if(dtime.value==""||dtime.value==null)
            {
                document.getElementById("depart_dateqa2").focus();
                return false;
            }
            
            var arys= new Array();  
            var startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);
    
            if(stime.value != null && dtime.value != null) 
            {  
                    arys=stime.value.split('-');  
                    startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);   
                    arys=stime.value.split('-');  
                    var checkEndDate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);   
                    if(stime.value > dtime.value) 
                    {  
                      alert("出发日期不能大于回程日期！");  
                      return false;  
                    }
            }  
            
            window.location.href="guodu.aspx?rsc="+fcity+tcity+"&rst="+stime.value+"&ret="+dtime.value+"&type=2";            
        }
        else
        {
             var fcity1 = document.getElementById("ddlFromCity");
	        var fcity =fcity1.options[fcity1.selectedIndex].value;
			
	        var tcity1 = document.getElementById("ddlToCity");
	        var tcity =tcity1.options[tcity1.selectedIndex].value;
			
	        var stime = document.getElementById("depart_dateqa");
            if(fcity == tcity)
            {
                alert("第一航程出发城市和第一航程到达城市不能一致");
                return false;
            }
            var stime = document.getElementById("depart_dateqa");
            if(stime.value==""||stime.value==null)
            {
                document.getElementById("depart_dateqa").focus();
                return false;
            }  

            var date=new Date(); 
            var date_arr=document.getElementById("depart_dateqa").value.split("-"); 

            var year=parseInt(date_arr[0]); 

            var month=parseInt(date_arr[1],10)-1; 

            var day=parseInt(date_arr[2],10); 

            var date1=new Date(year,month,day); 
            var year1=date.getYear();
            var month1=date.getMonth();

            var day1=date.getDate();
            var date2=new Date(year1,month1,day1);

            if(date2>date1)
            { 
                alert("不能查询今天以前的航班！！"); 
                return false;
            }
            
            var fcity2 = document.getElementById("ddlFromCity2");
	        fcity2 =fcity2.options[fcity2.selectedIndex].value;
			
	        var tcity2 = document.getElementById("ddlToCity2");
	        var tcity2 =tcity2.options[tcity2.selectedIndex].value;
			
	        var stimes = document.getElementById("depart_dateqa2");
            if(fcity2 == tcity2)
            {
                alert("第二航程出发城市和第二航程到达城市不能一致");
                return false;
            }

            if(stimes.value==""||stimes.value==null)
            {
                document.getElementById("depart_dateqa2").focus();
                return false;
            } 
            
             var arys= new Array();  
            var startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);
    
            if(stime.value != null && stimes.value != null) 
            {  
                    arys=stime.value.split('-');  
                    startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);   
                    arys=stime.value.split('-');  
                    var checkEndDate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);   
                    if(stime.value > stimes.value) 
                    {  
                      alert("第一航程出发日期不能大于第二航程出发日期！");  
                      return false;  
                    }
            } 
            window.location.href="guodu.aspx?jsc="+fcity+tcity+"&jst="+stime.value+"&jsct="+fcity2+tcity2+"&jstt="+stimes.value+"&type=3";
        }
        return true;
  }

  function searchsgo()
  {
        var radio1 = document.getElementsByName('TripType');
        if(radio1.item(0).checked)
        {
            var fcity1 = document.getElementById("ddlFromCity");
	        var fcity =fcity1.options[fcity1.selectedIndex].value;
			
	        var tcity1 = document.getElementById("ddlToCity");
	        var tcity =tcity1.options[tcity1.selectedIndex].value;
			
	        var stime = document.getElementById("depart_dateqa");
            if(fcity == tcity)
            {
                alert("出发城市和到达城市不能一致");
                return false;
            }
            var stime = document.getElementById("depart_dateqa");
            if(stime.value==""||stime.value==null)
            {
                document.getElementById("depart_dateqa").focus();
                return false;
            }  

            var date=new Date(); 
            var date_arr=document.getElementById("depart_dateqa").value.split("-"); 

            var year=parseInt(date_arr[0]); 

            var month=parseInt(date_arr[1],10)-1; 

            var day=parseInt(date_arr[2],10); 

            var date1=new Date(year,month,day); 
            var year1=date.getYear();
            var month1=date.getMonth();

            var day1=date.getDate();
            var date2=new Date(year1,month1,day1);

            if(date2>date1)
            { 
                alert("不能查询今天以前的航班！！"); 
                return false;
            }
           // window.location.href="guodu.aspx?hcid="+fcity+tcity+"&Flighttime="+stime.value+"&type=1";
			window.open("guodu.aspx?hcid="+fcity+tcity+"&Flighttime="+stime.value+"&type=1","_blank","");
        }
        else if(radio1.item(1).checked)
        {
            var fcity1 = document.getElementById("ddlFromCity");
	        var fcity =fcity1.options[fcity1.selectedIndex].value;
			
	        var tcity1 = document.getElementById("ddlToCity");
	        var tcity =tcity1.options[tcity1.selectedIndex].value;
			
	        var stime = document.getElementById("depart_dateqa");
            if(fcity == tcity)
            {
                alert("出发城市和到达城市不能一致");
                return false;
            }
            var stime = document.getElementById("depart_dateqa");
            if(stime.value==""||stime.value==null)
            {
                document.getElementById("depart_dateqa").focus();
                return false;
            }  

            var date=new Date(); 
            var date_arr=document.getElementById("depart_dateqa").value.split("-"); 

            var year=parseInt(date_arr[0]); 

            var month=parseInt(date_arr[1],10)-1; 

            var day=parseInt(date_arr[2],10); 

            var date1=new Date(year,month,day); 
            var year1=date.getYear();
            var month1=date.getMonth();

            var day1=date.getDate();
            var date2=new Date(year1,month1,day1);

            if(date2>date1)
            { 
                alert("不能查询今天以前的航班！！"); 
                return false;
            }
            
            
            
            var dtime = document.getElementById("depart_dateqa2");
            if(dtime.value==""||dtime.value==null)
            {
                document.getElementById("depart_dateqa2").focus();
                return false;
            }  
            if(dtime.value==""||dtime.value==null)
            {
                document.getElementById("depart_dateqa2").focus();
                return false;
            }
            
            var arys= new Array();  
            var startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);
    
            if(stime.value != null && dtime.value != null) 
            {  
                    arys=stime.value.split('-');  
                    startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);   
                    arys=stime.value.split('-');  
                    var checkEndDate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);   
                    if(stime.value > dtime.value) 
                    {  
                      alert("出发日期不能大于回程日期！");  
                      return false;  
                    }
            }  
            
//            window.location.href="guodu.aspx?rsc="+fcity+tcity+"&rst="+stime.value+"&ret="+dtime.value+"&type=2";            
			window.open("guodu.aspx?rsc="+fcity+tcity+"&rst="+stime.value+"&ret="+dtime.value+"&type=2","_blank","");
        }
        else
        {
             var fcity1 = document.getElementById("ddlFromCity");
	        var fcity =fcity1.options[fcity1.selectedIndex].value;
			
	        var tcity1 = document.getElementById("ddlToCity");
	        var tcity =tcity1.options[tcity1.selectedIndex].value;
			
	        var stime = document.getElementById("depart_dateqa");
            if(fcity == tcity)
            {
                alert("第一航程出发城市和第一航程到达城市不能一致");
                return false;
            }
            var stime = document.getElementById("depart_dateqa");
            if(stime.value==""||stime.value==null)
            {
                document.getElementById("depart_dateqa").focus();
                return false;
            }  

            var date=new Date(); 
            var date_arr=document.getElementById("depart_dateqa").value.split("-"); 

            var year=parseInt(date_arr[0]); 

            var month=parseInt(date_arr[1],10)-1; 

            var day=parseInt(date_arr[2],10); 

            var date1=new Date(year,month,day); 
            var year1=date.getYear();
            var month1=date.getMonth();

            var day1=date.getDate();
            var date2=new Date(year1,month1,day1);

            if(date2>date1)
            { 
                alert("不能查询今天以前的航班！！"); 
                return false;
            }
            
            var fcity2 = document.getElementById("ddlFromCity2");
	        fcity2 =fcity2.options[fcity2.selectedIndex].value;
			
	        var tcity2 = document.getElementById("ddlToCity2");
	        var tcity2 =tcity2.options[tcity2.selectedIndex].value;
			
	        var stimes = document.getElementById("depart_dateqa2");
            if(fcity2 == tcity2)
            {
                alert("第二航程出发城市和第二航程到达城市不能一致");
                return false;
            }

            if(stimes.value==""||stimes.value==null)
            {
                document.getElementById("depart_dateqa2").focus();
                return false;
            } 
            
             var arys= new Array();  
            var startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);
    
            if(stime.value != null && stimes.value != null) 
            {  
                    arys=stime.value.split('-');  
                    startdate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);   
                    arys=stime.value.split('-');  
                    var checkEndDate=new Date(arys[0],parseInt(arys[1]-1),arys[2]);   
                    if(stime.value > stimes.value) 
                    {  
                      alert("第一航程出发日期不能大于第二航程出发日期！");  
                      return false;  
                    }
            } 
//            window.location.href="guodu.aspx?jsc="+fcity+tcity+"&jst="+stime.value+"&jsct="+fcity2+tcity2+"&jstt="+stimes.value+"&type=3";
						window.open("guodu.aspx?jsc="+fcity+tcity+"&jst="+stime.value+"&jsct="+fcity2+tcity2+"&jstt="+stimes.value+"&type=3","_blank","");
        }
        return true;
  }
  
  function searchShow(id)
  {
  	  if(id==1)
  	  {
  	  	document.getElementById("wftr").style.display="none";
  	  }
  	  else
  	  {
  	  	document.getElementById("wftr").style.display="block";
  	  }
  }
