/*********************************************************
（このファイルはUTF-8で保存すること）
*********************************************************/
function select_main_category(category_id)
{
	sendData  = "category_id=" + encodeURI(category_id);
	httpObj = createXMLHttpRequest(fetch_sub_category);
	if ( httpObj ){
		httpObj.open( "POST", "../tpl/get_sub_category.php", true );
		httpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");	//この指定が無いとリクエストを受け付けない処理系もあるので
		httpObj.send( sendData );
	}
	document.getElementById("article_sub_category").length = 0;
}

function fetch_sub_category()
{
	pulldown = document.getElementById("article_sub_category");
	if ( ( httpObj.readyState == 4 ) && ( httpObj.status == 200 ) ){
		//JSONのデータを解析して表示する
		jsData = httpObj.responseText;
		data = eval("("+jsData+")");
		if ( data.sub_category_array ){
			pulldown.length = 0;
			pulldown.length ++;
			pulldown.options[0].text = "";
			pulldown.options[0].value = "";
			for ( i = 0; i < data.sub_category_array.length; i ++ ){
				idx = pulldown.length;
				pulldown.length ++;
				pulldown.options[idx].text = data.sub_category_array[i].name;
				pulldown.options[idx].value = data.sub_category_array[i].id;
			}
		}
		else{
			pulldown.length = 0;
		}
	}
}


