﻿function TypeIsChangeC(chk,tyear,tmonth,tday,calT)
{   
    var lyear=document.getElementById(tyear); 
	var lmon=document.getElementById(tmonth);
	var lday=document.getElementById(tday); 
	var lcal=document.getElementById(calT); 
	lyear.disabled=chk;
	lmon.disabled=chk;
	lday.disabled=chk; 
	lcal.disabled=chk; 
}
 
function SelectCountryType(drpTypeId,DrpFromCityId,DrpToAreaId,DrpToCountryId,DrpToCityId,UseType)
{ 
    var typeL;
    var cityL;
    var type;
    var response;
    var areaLTo;
    var countryLTo;
    var cityLTo;
    var responseTo;
    
    if(drpTypeId!=null)
        typeL=document.getElementById(drpTypeId);
    if(DrpFromCityId!=null)
        cityL=document.getElementById(DrpFromCityId); 
    if(typeL!=null)
    {
        type=typeL.value;
        response =Methods.GetCityByType(type,UseType);
        if(cityL!=null)
            flist(cityL,response,'お選びください');
    }
     
    if(DrpToAreaId!=null)
        areaLTo=document.getElementById(DrpToAreaId);
    if(DrpToCountryId!=null) 
        countryLTo=document.getElementById(DrpToCountryId); 
    if(DrpToCityId!=null)
        cityLTo=document.getElementById(DrpToCityId);  
    
    setAreaState(DrpToAreaId,DrpToCountryId,DrpToCityId);
    if(areaLTo!=null)
    {  
        if(type=="CHN")
        {
            responseTo=Methods.GetDrpAreaByType("CHN",false);
            flist(areaLTo,responseTo,'お選びください');
            if(countryLTo!=null)
            {
                countryLTo.options.add(new  Option('お選びください',''));  
            }
            if(cityLTo!=null)
            {
                cityLTo.options.add(new  Option('お選びください',''));  
            }
        }
        else if(type=="JPN")
        {
            responseTo=Methods.GetDrpAreaByType("CHN",true);
            flistOne(areaLTo,responseTo,'お選びください');
            responseTo=null;
            var areaCode=areaLTo.value;
            responseTo=Methods.GetDrpCountryByType(areaCode,'CHN',true);
            flistOne(countryLTo,responseTo,'お選びください');
            var countryCode=countryLTo.value;
            responseTo=null;
            responseTo=Methods.GetCityByCountry(countryCode,UseType);
            flist(cityLTo,responseTo,'お選びください');
        } 
        else
        {
            if(areaLTo!=null)
            {
                areaLTo.options.add(new  Option('お選びください',''));  
            }
            if(countryLTo!=null)
            {
                countryLTo.options.add(new  Option('お選びください',''));  
            }
            if(cityLTo!=null)
            {
                cityLTo.options.add(new  Option('お選びください',''));  
            }
        }
       
        
       
    } 
    return;
} 

function FillCountryByType(drpTypeId,AreaList,FillList,ClearList)
{   
    ClearDepartList(AreaList,FillList,ClearList); 
    var typeL=document.getElementById(drpTypeId);
    var areaL=document.getElementById(AreaList);
    var fillL=document.getElementById(FillList); 
	var strAreaCode =areaL.value;
    var type=typeL.value;
    var response; 
    if(type=='CHN')
    {
        response=Methods.GetDrpCountryByType(strAreaCode,'CHN',false);
    }
    if(type=='JPN')
    {
        response=Methods.GetDrpCountryByType(strAreaCode,'CHN',true);
    }  
	if(fillL!=null)
	{
	    flist(fillL,response,'お選びください');
	}
	return;
}
function FillDrpCity(firstDrpID,SecondDrpID,UseType)
{    
    var countryCode =(document.getElementById(firstDrpID)).value;
    var response =Methods.GetCityByCountry(countryCode,UseType);
    var list = document.getElementById(SecondDrpID);
    flist(list,response,'お選びください');
}
 
function ClearDepartList(AreaList,FillList,ClearList)
{
    var areaL;
    var fillL;
    var clearL;
    var departL;
    areaL=document.getElementById(AreaList);
	if(areaL==null)
	    return;
	fillL=document.getElementById(FillList);
	if (fillL==null)
		return;
	if (ClearList!=null)
	{
		clearL=document.getElementById(ClearList);
		if (clearL!=null)
		{
			clearL.length=0;
			clearL.options.add(new  Option('お選びください',''));  
	    }
	}
}

function setAreaState(AreaList,FillList,ClearList)
{
    var areaL;
    var fillL;
    var clearL;
    var departL; 
	if(AreaList!=null)
	{
	    areaL=document.getElementById(AreaList);
	    if (areaL!=null)
	    {
			areaL.length=0;
	    }
	} 
	if(FillList!=null)
	{
	    fillL=document.getElementById(FillList);
	    if (fillL!=null)
	    {
			fillL.length=0;
	    }
	}  
	if (ClearList!=null)
	{
		clearL=document.getElementById(ClearList);
		if (clearL!=null)
		{
			clearL.length=0;  
	    }
	}
}

function SetState(drpCountryTyp,drpFromCity,drpToArea,drpToCountry,drpToCity,DLinYear,DLinMonth,DLinDay,DLoutYear,DLoutMonth,DLoutDate,drpAirline,drpClass,drpPassengerType,rdpType1,calT,UseType)
{
    var response;
    var responseTo;
    CountryTyp=document.getElementById(drpCountryTyp);
    FromCity=document.getElementById(drpFromCity);
    ToArea=document.getElementById(drpToArea);
    ToCountry=document.getElementById(drpToCountry);
    ToCity=document.getElementById(drpToCity);
    
    
    Airline=document.getElementById(drpAirline);
    Class=document.getElementById(drpClass);
    PassengerType=document.getElementById(drpPassengerType);
    Type1=document.getElementById(rdpType1);  
    IcalT=document.getElementById(calT);
     
    LoutYear=document.getElementById(DLoutYear);
    LoutMonth=document.getElementById(DLoutMonth);
    LoutDate=document.getElementById(DLoutDate);
     
    if(CountryTyp!=null)
    {   
        CountryTyp.selectedIndex =0;
        var type=CountryTyp.value;
        response =Methods.GetCityByType(type,UseType);
        if(FromCity!=null)
            flist(FromCity,response,'お選びください');
           
       if(type=="CHN")
       { 
            responseTo=Methods.GetDrpAreaByType("FRN",true);
            flist(ToArea,responseTo,'お選びください');
            if(ToCountry!=null)
            {
                ToCountry.length=0;
                ToCountry.options.add(new  Option('お選びください',''));  
            }
            if(ToCity!=null)
            {
                ToCity.length=0;
                ToCity.options.add(new  Option('お選びください',''));  
            }
       }
       else
       {
            if(ToArea!=null)
            {
                ToArea.length=0;
                ToArea.options.add(new  Option('お選びください',''));  
            }
            if(ToCountry!=null)
            {
                ToCountry.length=0;
                ToCountry.options.add(new  Option('お選びください',''));  
            }
            if(ToCity!=null)
            {
                ToCity.length=0;
                ToCity.options.add(new  Option('お選びください',''));  
            }
       }
    } 
    
    SetDState(DLinYear,DLinMonth,DLinDay,DLoutYear,DLoutMonth,DLoutDate);
    
    if(Airline!=null)
    { 
        response =Methods.GetAirline();
        if(Airline!=null)
            flist(Airline,response,'お選びください');
    }
    if(Class!=null)
    {
        Class.selectedIndex =0;
    }
    if(PassengerType!=null)
    {
        PassengerType.selectedIndex =0;
    }
    
    if(Type1!=null)
    {
        Type1.checked=true;
        LoutYear.disabled=true;
        LoutMonth.disabled=true;
        LoutDate.disabled=true;
        IcalT.disabled=true;
    }
    
   
    
    
}


function SetDState(year,month,day,year2,month2,day2)
{
	var toDay = new Date();
	var nextDay=new Date(Date.parse(toDay) + 86400000);
	document.getElementById(year2).value=toDay.getFullYear();
	document.getElementById(year).value=nextDay.getFullYear();

	var intMonth=toDay.getMonth()+1;
	var strMonth=intMonth.toString();
	strMonth='0'+strMonth;
	strMonth=strMonth.substring(strMonth.length-2,strMonth.length);

	document.getElementById(month).value=strMonth;
	
	intMonth=nextDay.getMonth()+1;
	strMonth=intMonth.toString();
	strMonth='0'+strMonth;
	strMonth=strMonth.substring(strMonth.length-2,strMonth.length);
	document.getElementById(month2).value=strMonth;
	
	var intDay=toDay.getDate();
	var strDay=intDay.toString();
	strDay='0'+strDay;
	strDay=strDay.substring(strDay.length-2,strDay.length);
	document.getElementById(day).value=strDay;
	
	intDay=nextDay.getDate();
	strDay=intDay.toString();
	strDay='0'+strDay;
	strDay=strDay.substring(strDay.length-2,strDay.length);
	document.getElementById(day2).value=strDay;
	
} 