
var ajaxList = new Array();
var ajaxLevel = 0;

function getAjaxList(sel, nextlevel)
{
	var id = sel.options[sel.selectedIndex].value;
	if(id.length > 0) {
		var index = ajaxList.length;
		ajaxList[index] = new sack();
		ajaxList[index].requestFile = 'places.php?id=' + id;	// Übergabe an das php
		ajaxList[index].onCompletion = function(){ createAjaxList(index, nextlevel) };	// Rückgabe
		ajaxList[index].runAJAX();	// AJAX aufrufen
	}
	document.getElementById('choosed_cat').value = id;
}

function createAjaxList(index, nextlevel)
{
	if(ajaxList[index].response.length > 5) {
		for(i=nextlevel; i<=ajaxLevel; i++) {
			var e = document.getElementById('catchooselevel'+i);
			if(e){ e.options.length=0; }	// Box leer machen
		}
		var obj = document.getElementById('catchooselevel'+nextlevel);
		if(!obj) {
			var pn = document.getElementById('catchoose');
			pn.appendChild(document.createElement('br'));
			obj = document.createElement('select');
			pn.appendChild(obj);
			obj.setAttribute('id', 'catchooselevel'+nextlevel);
			obj.setAttribute('onchange', 'getAjaxList(this,'+(nextlevel+1)+')');
			ajaxLevel++;
		}
		eval(ajaxList[index].response);	// JS-Rückgabe anwenden
	}
	
	
}

