function select_kat(id){
	req.open('get', 'request.php?op=kat&id='+ id);
	req.onreadystatechange = handle_kat;
	req.send(null);
}

function handle_kat() {
	if(req.readyState == 4){
		
		var selector = document.getElementById('kategorie');
		if(selector.options.length>0){
			for(i = selector.options.length-1; i >= 0; i--) {
				selector.options[i] = null;
			}
		}
		
		var br_selector = document.getElementById('branche');
		if(br_selector.options.length>0){
			for(i = br_selector.options.length-1; i >= 0; i--) {
				br_selector.options[i] = null;
			}
		}
		
		var arr = req.responseText.split("||");
		var part;
		for(x = 0; x < arr.length; x++){
			part = arr[x].split("|");
			selector.options[selector.options.length] = new Option(part[1], part[0]);
		}
		
	}
}

function select_branche(){
	var selector = document.getElementById('kategorie');
	if(selector.value!=""){
		req.open('get', 'request.php?op=kat&id='+ selector.value);
		req.onreadystatechange = handle_branche;
		req.send(null);
	}
}

function handle_branche() {
	if(req.readyState == 4){
		
		var selector = document.getElementById('branche');
		if(selector.options.length>0){
			for(i = selector.options.length-1; i >= 0; i--) {
				selector.options[i] = null;
			}
		}
		
		var arr = req.responseText.split("||");
		var part;
		for(x = 0; x < arr.length; x++){
			part = arr[x].split("|");
			selector.options[selector.options.length] = new Option(part[1], part[0]);
		}
	}
}

