/*********************************************************
（このファイルはUTF-8で保存すること）
*********************************************************/

function select_tour_goal_area(area_name)
{
	if ( area_name ){
		sendData  = "area_name=" + encodeURI(area_name);
		httpObj = createXMLHttpRequest(fetch_goal_prefecture);
		if ( httpObj ){
			httpObj.open( "POST", "/ajax/fetch_goal_prefecture.php", true );
			httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	//この指定が無いとリクエストを受け付けない処理系もあるので
			httpObj.send( sendData );
		}
	}
	else{
		document.frm.elements["tour_goal_prefecture"].length = 0;
	}
}
function fetch_goal_prefecture()
{
	pulldown = document.frm.elements["tour_goal_prefecture"];
	if ( ( httpObj.readyState == 4 ) && ( httpObj.status == 200 ) ){
		//JSONのデータを解析して表示する
		jsData = httpObj.responseText;
		data = eval("("+jsData+")");
		if ( data.prefecture_array ){
			pulldown.length = 0;
			for ( i = 0; i < data.prefecture_array.length; i ++ ){
				idx = pulldown.length;
				pulldown.length ++;
				pulldown.options[idx].text = data.prefecture_array[i].prefecture_name;
				pulldown.options[idx].value = data.prefecture_array[i].prefecture_value;
			}
		}
		else{
			pulldown.length = 0;
		}
	}
}




function change_prefecture(prefecture)
{
	if ( prefecture.value ){
		sendData  = "prefecture=" + encodeURI( prefecture.value );
		httpObj = createXMLHttpRequest( fetch_district );
		if ( httpObj ){
			httpObj.open( "POST", "/ajax/fetch_district.php", true );
			httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	//この指定が無いとリクエストを受け付けない処理系もあるので
			httpObj.send( sendData );
		}
	}
	else{
		document.frm.elements["agency_district"].length = 0;
	}
}

function fetch_district()
{
	district_pulldown = document.frm.elements["agency_district"];
	if ( ( httpObj.readyState == 4 ) && ( httpObj.status == 200 ) ){
		//JSONのデータを解析して表示する
		jsData = httpObj.responseText;
		data = eval("("+jsData+")");
		if ( data.district_array ){
			district_pulldown.length = 0;
			for ( i = 0; i < data.district_array.length; i ++ ){
				idx = district_pulldown.length;
				district_pulldown.length ++;
				district_pulldown.options[idx].text = data.district_array[i].district_name;
				district_pulldown.options[idx].value = data.district_array[i].district_value;
			}
		}
		else{
			district_pulldown.length = 0;
		}
	}
}

