	function returnData(http_request, url, listid) {
		if (http_request.readyState == 4) {
			if (http_request.status == 200) {
				updateList(http_request, url, listid);
			} else {
				alert('There was a problem with the request.');
			}
		}
		if (http_request.readyState <= 1)
		{
			showLoading();
		}
	}
	
	function showLoading()
	{
// 		document.getElementById('se-newgenre').innerHTML='<option>Loading...</option>';
	}
	
	function updateList(http_request, url, listid) {
		var xmldoc = http_request.responseXML;
		
		listid++;
		var selection = document.getElementById('genre_' + listid);
		
		// Remove lists after the level of the one selected
		for (no = listid; no < 3; no++)
		{
			if (document.getElementById('genres_' + no))
			{
				document.getElementById('genres_' + no).style.display='none';
				document.getElementById('genre_' + no).innerHTML = '';
			}
		}
		
		// 'Select a sub-genre' list item
		var new_option = document.createElement('option');
		new_option.appendChild(document.createTextNode('Select a sub-genre'));
		new_option.setAttribute('value', '');
		selection.appendChild(new_option);
		
		// Insert new child elements for those in the XML file
		var node_count = xmldoc.getElementsByTagName('genre').length;
		for (i = 0; i < node_count; i++) {
			var genre_name = xmldoc.getElementsByTagName('name').item(i);
			var genre_id = xmldoc.getElementsByTagName('id').item(i);
			var new_option = document.createElement('option');
			new_option.setAttribute('value', genre_id.firstChild.data);
			new_option.appendChild(document.createTextNode(genre_name.firstChild.data))
			selection.appendChild(new_option);
		}
		
		if (node_count > 0)
		{
// 			selection.appendChild(new_list);
			document.getElementById('genres_' + listid).style.display='block';
		}
	}
	
	function getGenres(url, listid) {
		var tmp_url = url + '/' + document.getElementById('genre_' + listid).value + '';
		http_request = makeRequest(tmp_url);	
		http_request.onreadystatechange = function() { returnData(http_request, url, listid); };
		http_request.open('GET', tmp_url, true);
		http_request.send(null);
	}