var submenutermin = "<ul>";

function banddaten(band) {

	switch (requestT.readyState) {
		// wenn der readyState 4 und der request.status 200 ist, dann ist alles korrekt gelaufen
		case 4:
			if (requestT.status != 200) {
				alert("Der Request wurde abgeschlossen, ist aber nicht OK\nFehler:"+requestT.status);
			} else {
				// Antwort des Servers -> als XML-Dokument
				xmlDoc	= requestT.responseXML;
					//alert(xmlDoc.getElementsByTagName('band')[0].childNodes.length);
				for (var i = 0; i< xmlDoc.getElementsByTagName('band')[0].childNodes.length; i++){
					submenutermin = submenutermin+"&nbsp;&middot;&nbsp;<li><a onclick=\"bandstart('"+xmlDoc.getElementsByTagName('band')[0].childNodes[i].firstChild.firstChild.nodeValue+"');\" >"+xmlDoc.getElementsByTagName('band')[0].childNodes[i].firstChild.firstChild.nodeValue+"</a></li>";
				}
				var breadcrumbbreadcrumb = "<ul>";
				breadcrumbbreadcrumb = breadcrumbbreadcrumb+"&nbsp;&middot;&nbsp;<li><a href='index2.php'>home</a></li>";
				breadcrumbbreadcrumb = breadcrumbbreadcrumb+"&nbsp;&middot;&nbsp;<li><a href='band.php'>band</a></li>";
				breadcrumbbreadcrumb = breadcrumbbreadcrumb+"</ul>";
				document.getElementById('breadcrumb_breadcrumb').innerHTML = breadcrumbbreadcrumb;	
				submenutermin = submenutermin+"</ul>";
				document.getElementById('submenu').innerHTML = submenutermin;	
				
				if(band){
					bandstart(band);
				}
				else{
					bandstart("Biographie");
				}
			}
			break;
		default:
			break;
	}
}

function bandstart(bandsuche,eigen){

var platz = 0;
var bandausgabe = "<div class='news'><p id='date' class='date'></p><div class='textleft'>";
	for (var ib = 0; ib< xmlDoc.getElementsByTagName('band')[0].childNodes.length; ib++){
		if (xmlDoc.getElementsByTagName('band')[0].childNodes[ib].firstChild.firstChild.nodeValue == bandsuche){
			for (var jb = 1; jb< xmlDoc.getElementsByTagName('band')[0].childNodes[ib].childNodes.length; jb++){
				if (xmlDoc.getElementsByTagName('band')[0].childNodes[ib].firstChild.firstChild.nodeValue == "Biographie"){
					platz = 1;
					
					if(!xmlDoc.getElementsByTagName('band')[0].childNodes[ib].childNodes[jb].childNodes[0].firstChild){
					var thema = "";
					}
					else{
					var thema = xmlDoc.getElementsByTagName('band')[0].childNodes[ib].childNodes[jb].childNodes[0].firstChild.nodeValue;
					}
					if(!xmlDoc.getElementsByTagName('band')[0].childNodes[ib].childNodes[jb].childNodes[1].firstChild){
					var inhalt = "";
					}
					else{
					var inhalt = xmlDoc.getElementsByTagName('band')[0].childNodes[ib].childNodes[jb].childNodes[1].firstChild.nodeValue;
					}

					bandausgabe = bandausgabe+"<div class='text3'>"+inhalt+"</div>";
					bandausgabe = bandausgabe+"</div>";
					bandausgabe = bandausgabe+"<div id='pix3' class='pix3'>";  
					bandausgabe = bandausgabe+"<img id='guitarre' name='guitarre' src='./images/band/bio.jpg'  alt='' />";
					bandausgabe = bandausgabe+"</div>";
					bandausgabe = bandausgabe+"<div class='clean'></div>";

					bandausgabe = bandausgabe+"<div class='clean'></div>";
				}
				else{
					if(!xmlDoc.getElementsByTagName('band')[0].childNodes[ib].childNodes[jb].childNodes[0].firstChild){
					var thema = "";
					}
					else{
					var thema = xmlDoc.getElementsByTagName('band')[0].childNodes[ib].childNodes[jb].childNodes[0].firstChild.nodeValue;
					}
					if(!xmlDoc.getElementsByTagName('band')[0].childNodes[ib].childNodes[jb].childNodes[1].firstChild){
					var inhalt = "";
					}
					else{
					var inhalt = xmlDoc.getElementsByTagName('band')[0].childNodes[ib].childNodes[jb].childNodes[1].firstChild.nodeValue;
					}
					bandausgabe = bandausgabe+"<div class='text4'><b>"+thema+"</b></div>";
                    bandausgabe = bandausgabe+"<div class='text5'>"+inhalt+"</div>";
                    bandausgabe = bandausgabe+"<div class='clean'></div>";
				}
			}
		}
	}
	if(platz == 0){
					bandausgabe = bandausgabe+"</div><div id='pix4' class='pix4'>";  
					bandausgabe = bandausgabe+"<img id='band' name='band' src='./images/band/bio.jpg'  alt='' />"; 
					bandausgabe = bandausgabe+"</div>";
					bandausgabe = bandausgabe+"<div class='clean'></div>";
	}
	
	bandausgabe = bandausgabe+"</div></div>";
	document.getElementById('inhaltmain').innerHTML = bandausgabe;
	document.getElementById('date').innerHTML = bandsuche;
	if(platz == 0){
		if(bandsuche == "Christian (Gossi) Gosserau"){
		eigen = "trommel";
		var quelle = "./images/band/"+eigen+"over.jpg";
		document.getElementById("band").setAttribute("src", quelle);
		}
		if(bandsuche == "Ronny Paul Wagner"){
		eigen = "guitarre";
		var quelle = "./images/band/"+eigen+"over.jpg";
		document.getElementById("band").setAttribute("src", quelle);
		}
		if(bandsuche == "Joachim Wawra"){
		eigen = "bass";
		var quelle = "./images/band/"+eigen+"over.jpg";
		document.getElementById("band").setAttribute("src", quelle);
		}
		if(bandsuche == "Marco Voigt"){
		eigen = "gesang";
		var quelle = "./images/band/"+eigen+"over.jpg";
		document.getElementById("band").setAttribute("src", quelle);
		}

	}
}



