//XMLHTTP-Request wird erstellt. Für InetExplorer 5 und 6 wird ActiveXObject oder Microsoft.XMLHTTP erzeugt, da diese Browser XMLHttpRequest nicht kennen
req = null;
if(window.XMLHttpRequest){
	req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
	try {
		req = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e1){
		try {
			req = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (e2){
		
		}
	}
}

function change_image(image_id){
	//Request wird asynchron ausgeführt
	req.open('POST', 'bibliotheken/ajax_xml_module.php?change_image=1', true);
	
	parameter = "imageid="+image_id;
	
	main_image 			= document.getElementById('aktionen_hauptfoto_foto');
	main_image_caption	= document.getElementById('aktionen_fotobox_fotounterschrift');
	main_image_link		= document.getElementById('aktionen_hauptfoto');
	
	//Ladesymbol wird angezeigt solange req.readyState != 4
	main_image.src = 'images/general/ladesymbol.gif';
	
	//Send the proper header information along with the request
	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
	req.setRequestHeader("Content-length", parameter.length);
	req.setRequestHeader("Connection", "close");
	
	req.onreadystatechange = function() {
		if (req.readyState == 4 && req.status == 200){

			foto	 	= req.responseXML.documentElement;
				id 			= foto.getAttribute('id');
				foto_src	= foto.getAttribute('foto_src');
	
				fotounterschrift_text = '';
				
				for(i=0; i < foto.childNodes.length; i++){	
							fotounterschrift_text += foto.childNodes[i].nodeValue;
				}		
					
			//Einfügen in die Fotobox
			main_image.src 					= "media/aktionen/"+foto_src;
			main_image_caption.innerHTML	= fotounterschrift_text;
			main_image_link.href 			= "media/aktionen/"+foto_src;
			
		}
	}
	req.send(parameter);
}
