var globalRouteID = '';

var stationAjax = function (route_id, routeID)
{
  globalRouteID = routeID;
  $_optionsLength = document.getElementById('station' + routeID).options.length;
  for ($_tmpI=1; $_tmpI<$_optionsLength; $_tmpI++)
  {
    document.getElementById('station' + routeID).options[0] = null;
  }
  if (route_id == 0) {
    document.getElementById('station' + globalRouteID).options[0]
      = new Option('路線を選択してください','');
    return;
  } else {
    document.getElementById('station' + globalRouteID).options[0]
      = new Option('駅名を選択してください','');
  }
  var oJsr = new JSONscriptRequest('/article/index.php?ctrl=list&page=js&route_id=' + route_id);
  oJsr.buildScriptTag();
  oJsr.addScriptTag();
}


var stationCallback = function (route_id, station)
{
  if (!station) {
    globalRouteID = '';
    return;
  }
  var stationCount = 0;
  while (stationItem = station[stationCount]) {
    document.getElementById('station' + globalRouteID).options[stationCount + 1]
      = new Option(decodeURIComponent(stationItem['station_name']), stationItem['id']);
    stationCount++;
  }
  globalRouteID = '';
  return;
}

