function GetXmlHttp(){
	var xmlhttp = new Object();
	if (window.XMLHttpRequest && !(window.ActiveXObject)) {
		xmlhttp = new XMLHttpRequest();
		xmlhttp.overrideMimeType("text/xml");
	} else if (window.ActiveXObject) {
		try {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				xmlhttp = false;
			}
		}
	}
	return xmlhttp;
}

function LoadArr(elem,val,txt,k,s,s2){
	elem.length = 0;
	j = 0;r = 0;

	if(k != '') elem.options[j++] = new Option(k,'');
	var len = val.length;
	for(i = j; i < (j + len); i++){
		elem.options[i] = new Option(txt[r],val[r]);
		if(val[r] == s) elem.options[i].selected = true;
		r++;
	}
}

function fillChildCategory(parent_id,level,elem) {
	var xmlhttp = new Object();
	xmlhttp = GetXmlHttp();
	xmlhttp.open("POST", "/xml/category.php", true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4) {
			var category = xmlhttp.responseXML.getElementsByTagName('category');
			var text = new Array();
			var value = new Array();
			var len = category.length;
			for(i = 0; i < category.length; i++) {
				value.push(category[i].getAttribute("cat_id"));
				text.push((category[i].firstChild.data != null)?category[i].firstChild.data:"");
			}
			LoadArr(elem,value,text,'-','','');
		}
	}
	var params = "parent_id=" + parent_id + "&level=" + level;
	xmlhttp.send(params);	
}