<!--

//エリア初期化処理
function dmArea_initialize(ChihoCode,TodofukenCode,ShigunCode,KuchosonCode){
  param = '&MODE=INI&CHIHO_CODE=' + ChihoCode + '&TODOFUKEN_CODE=' + TodofukenCode + '&SHIGUN_CODE=' + ShigunCode + '&KUCHOSON_CODE=' + KuchosonCode;
  sendRequest(onloaded_ini,param,'GET','/ajax/areaselect_dm.php',true,true);
}

//受信時処理
function onloaded_ini(jsData)
{

  work = 'document.dm_area.CHIHO_CODE';
  ChihoObj = eval(work);
  ChihoObj.options.length = 1;
  ChihoObj.options[0] = new Option("地方を選択してください","");
  
  work = 'document.dm_area.TODOFUKEN_CODE';
  TodofukenObj = eval(work);
  TodofukenObj.options.length = 1;
  TodofukenObj.options[0] = new Option("都道府県を選択してください","");
  
  work = 'document.dm_area.SHIGUN_CODE';
  ShigunObj = eval(work);
  ShigunObj.options.length = 1;
  ShigunObj.options[0] = new Option("地域を選択してください","");
  
  work = 'document.dm_area.KUCHOSON_CODE';
  KuchosonObj = eval(work);
  KuchosonObj.options.length = 1;
  KuchosonObj.options[0] = new Option("細かい地域を選択してください","");
  
  var ChihoCnt = 1;
  var TodofukenCnt = 1;
  var ShigunCnt = 1;
  var KuchosonCnt = 1;
  
  var formObj = document.getElementById('dm_area');
  
  var resdata = "";
  resdata = jsData.responseText;
  
  var data = "";
  data = eval("("+resdata+")");
  
  for(var i=0; i<data.item.length; i++){
  
    var Name = data.item[i].Name;
    var Code = data.item[i].Code;
    var Type = data.item[i].Type;
    var Selected = data.item[i].Selected;
    var Url = data.item[i].Url;
    
    if( Type == 'CHIHO' ){
      ChihoObj.options[ChihoCnt] = new Option(Name,Code);
      if(Selected == 1){
        ChihoObj.options[ChihoCnt].selected = true;
        
        formObj.action = Url.replace("/domestic/area", "/domestic/hotel/area");
        
      }
      ChihoCnt++;
    }
    
    if( Type == 'TODOFUKEN' ){
      TodofukenObj.options[TodofukenCnt] = new Option(Name,Code);
      if(Selected == 1){
        TodofukenObj.options[TodofukenCnt].selected = true;
        
        formObj.action = Url.replace("/domestic/area", "/domestic/hotel/area");
        
      }
      TodofukenCnt++;
    }
    
    if( Type == 'SHIGUN' ){
      ShigunObj.options[ShigunCnt] = new Option(Name,Code);
      if(Selected == 1){
        ShigunObj.options[ShigunCnt].selected = true;
        
        formObj.action = Url.replace("/domestic/area", "/domestic/hotel/area");
        
      }
      ShigunCnt++;
    }
    
    if( Type == 'KUCHOSON' ){
      KuchosonObj.options[KuchosonCnt] = new Option(Name,Code);
      if(Selected == 1){
        KuchosonObj.options[KuchosonCnt].selected = true;
        
        formObj.action = Url.replace("/domestic/area", "/domestic/hotel/area");
        
      }
      KuchosonCnt++;
    }
  }
  if(TodofukenCnt > 1){
    TodofukenObj.options[TodofukenCnt] = new Option('選択しない','');
  }
  if(ShigunCnt > 1){
    ShigunObj.options[ShigunCnt] = new Option('選択しない','');
  }
  if(KuchosonCnt > 1){
    KuchosonObj.options[KuchosonCnt] = new Option('選択しない','');
  }
}

function changeAreaDm(area){
  if(area=='chiho'){
    dmArea_initialize(document.dm_area.CHIHO_CODE.value,'','','');
  }
  if(area=='todofuken'){
    if(document.dm_area.TODOFUKEN_CODE.value){
      dmArea_initialize(document.dm_area.CHIHO_CODE.value,document.dm_area.TODOFUKEN_CODE.value,'','');
    }
    else{
      formObj = document.getElementById('dm_area');
      url = formObj.action;
      w = url.split("/");
      newurl = w[0] + '/' + w[1] + '/' + w[2] + '/' + w[3] + '/' + w[4] + '/';
      formObj.action = newurl;
      
      document.dm_area.SHIGUN_CODE.options.length = 1;
      document.dm_area.SHIGUN_CODE.options[0] = new Option('選択しない','');
      document.dm_area.KUCHOSON_CODE.options.length = 1;
      document.dm_area.KUCHOSON_CODE.options[0] = new Option('選択しない','');
    }
  }
  if(area=='shigun'){
    if(document.dm_area.SHIGUN_CODE.value){
      dmArea_initialize(document.dm_area.CHIHO_CODE.value,document.dm_area.TODOFUKEN_CODE.value,document.dm_area.SHIGUN_CODE.value,'');
    }
    else{
      formObj = document.getElementById('dm_area');
      url = formObj.action;
      w = url.split("/");
      newurl = w[0] + '/' + w[1] + '/' + w[2] + '/' + w[3] + '/' + w[4] + '/' + w[5] + '/';
      formObj.action = newurl;
      
      document.dm_area.KUCHOSON_CODE.options.length = 1;
      document.dm_area.KUCHOSON_CODE.options[0] = new Option('選択しない','');
    }
  }
  if(area=='kuchoson'){
    if(document.dm_area.KUCHOSON_CODE.value){
      dmArea_initialize(document.dm_area.CHIHO_CODE.value,document.dm_area.TODOFUKEN_CODE.value,document.dm_area.SHIGUN_CODE.value,document.dm_area.KUCHOSON_CODE.value);
    }
    else{
      formObj = document.getElementById('dm_area');
      url = formObj.action;
      w = url.split("/");
      newurl = w[0] + '/' + w[1] + '/' + w[2] + '/' + w[3] + '/' + w[4] + '/' + w[5] + '/' + w[6] + '/';
      formObj.action = newurl;
    }
  }
}

function goSubmit(){
  var formObj = document.getElementById('dm_area');
  if(formObj.action == ''){
    alert('エリアを選択してください。');
  }
  else{
    formObj.submit();
  }
}


-->

