/*
카테고리 출력

// 셀렉트 박스 출력

*/

var txt = "<script src=\"/_data/category_arr.js\"></scr";
txt += "ipt>";
document.write(txt);

function cate_chg(depth)
{
	var i;
	var obj;
	var obj1;
	var txt;
	for (i=(depth+1); i<=10; i++)
	{
		obj = document.getElementById("cate_" + i);
		if (obj != null) 
		{
			obj.value = "";
			obj.options.length = 1;
			//obj.style.display = "none"
		}
	}
	
	obj = document.getElementById("cate_" + depth);
	obj1 = document.getElementById("cate_" + (parseInt(depth,10)+1));
	if (obj1 != null)
	{
		obj1.options.length=1;
		obj1.value="";
		if ( typeof(cateArr[obj.value])=="object")
		{
			chk = false;
			for (var j in cateArr[obj.value])
			{
				obj1.options[obj1.options.length] = new Option(cateArr[obj.value][j] , j , true);
			}
			obj1.style.display = "";
		}
	}
}
function category_p(ptype , cate)
{
	var txt;
	var code;
	var code1;
	var oparent;
	var i;
	var obj;
	var chk = false;
	if (ptype == "select")
	{
		for (i=1;i<=10 ;i++ )
		{
			document.write("<select name=\"cate_" + i + "\" id=\"cate_" + i + "\" onchange=\"cate_chg(" + i + ")\" style=\"display:none\"><option value=\"\">" + i + "차 카테고리 선택</option></select>");
		}
		var carr = cate.split(",");
		var j=0;
		code = carr[0].substring(1,carr[0].length-1)
		obj = document.getElementById("cate_1");
		obj.options.length=1;
		chk = false;
		for (var j in cateArr[0])
		{
			obj.options[obj.options.length] = new Option(cateArr[0][j] , j , true);
			if ( code == j ) chk = true;
		}
		if ( chk == true ) obj.value = code;
		obj.style.display = "";

		for (i=1;i<=carr.length ;i++ )
		{
			if (carr[i-1] != "")
			{
				obj = document.getElementById("cate_" + (i+1));
				code = carr.length>i ? carr[i].substring(1,carr[i].length-1) : "";
				oparent = carr[i-1].substring(1,carr[i-1].length-1)
				if ( typeof(cateArr[oparent])=="object")
				{
					obj.options.length=1;
					obj.value="";
					chk = false;
					for (var j in cateArr[oparent])
					{
						obj.options[obj.options.length] = new Option(cateArr[oparent][j] , j , true);
						if ( code == j ) chk = true;
					}
					if ( chk == true ) obj.value = code;
					obj.style.display = "";
				}

			}
		}
	}
}

