// http://www.parkcity.ne.jp/~chaichan/src/javasc31.htm

var subcat_options = new Array();

function create_style(objList, objArray)
{
	//objListは、select要素のオブジェクト
	//objArrayは、select要素へ代入する値の配列
	var nMax = objArray.length/2;//select要素へ代入する値の配列数
	var nLoop = 0;
	objList.length=nLoop;
	for (nLoop = 0; nLoop < nMax; nLoop++)
	{
		//option要素を作成
		oAdd = document.createElement('option');

		//option要素を親要素に追加する前にすでに子要素があるときはそれを削除
		if(objList.childNodes[nLoop]  != undefined)
		{
			objList.removeChild(objList.childNodes[nLoop]);
		}

		//option要素を親要素（select）へ追加
		objList.appendChild(oAdd);

		//option要素のvalue属性にインデックスの値を設定
		objList.childNodes[nLoop].setAttribute('value', objArray[nLoop*2]);//＊＊変更＊＊

		//option要素の子要素にobjArray配列の値をテキストとして作成
		oAddx= document.createTextNode(objArray[nLoop*2+1]);

		//すでに子要素があるときはそれを削除
		if(objList.childNodes[nLoop].firstChild  != undefined)
		{
			objList.childNodes[nLoop].removeChild(objList.childNodes[nLoop].firstChild);
		}

		//作成したテキストを親要素（option）へ追加
		objList.childNodes[nLoop].appendChild(oAddx);
	}
	//連動する方のselect要素の個数を設定する
//	objList.length=nLoop;
}

function create_option_list(list, cat)
{
	if ( subcat_options[list][cat] != undefined )
	{
		categoryId = cat;
	}
	else
	{
		categoryId = 'noselect';
	}
	create_style(document.getElementById(list), subcat_options[list][categoryId]);
}