var xmlHttp = createXmlHttpRequestObject();

function checkProject(){
	jQuery(document).ready(function($){
		if($('h1').text() == 'IRON SKY'){
			$('#startnext_project').show(0);
		}
		else{
			$('#startnext_project').hide(0);
		}
		return;
	});
}

function createXmlHttpRequestObject(){
	var xmlHttp;
	
	try{
		xmlHttp = new XMLHttpRequest();
	}
	catch(e){
		//für UE6 oder älter
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
										"MSXML2.XMLHTTP.5.0",
										"MSXML2.XMLHTTP.4.0",
										"MSXML2.XMLHTTP.3.0",
										"MSXML2.XMLHTTP",
										"Microsoft.XMLHTTP");
		
		for(var i=0; i<XmlHttpVersions.length && !xmlHttp; i++){
			try{
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch(e){}
		}
	}
	if(!xmlHttp)
		alert("Error creating the XMLHttpRequest Object");
	else
		return xmlHttp;
}
	
//liest eine Datei vom Server
function process(id){
	
	//nur fortfahren wenn xmlHttp nicht leer ist
	if(xmlHttp){
		try{			
			//var anregung = document.getElementById("anregung").value;
			//var anregung = 'jawohl...';
			//erzeugt den Parameterstring
			var params = "id="+id;
					
			xmlHttp.open("GET", "get_project.php?" + params, true);
			xmlHttp.onreadystatechange = handleRequestStateChange;
			xmlHttp.send(null);
		}
		catch(e){
			//alert("Can't connect to Server");
		}
	}
}
	
//Aufruf der Funktion bei Statusänderungen
function handleRequestStateChange(){
	
	//wenn readyState = 4, kann man Server Antwort lesen
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
			try{
				handleServerResponse();					
			}
			catch(e){
				alert(e);
			}
		}
		else{
			//alert("There was a problem retrieving the data");
		}
	}
}

//behandlet die vom Server empfangene Antwort
function handleServerResponse(){
	var Response = xmlHttp.responseText;		
	//fängt potenzielle Fehler bei IE und Opera
	/*if(!xmlResponse || !xmlResponse.documentElement)
		throw("Invalid XML structure");
		
	var rootNodeName = xmlResponse.documentElement.nodeName;		
	if(rootNodeName == "parsererror")
		throw("Invalid XML structure");
		
	xmlRoot = xmlResponse.documentElement;
	if(rootNodeName != "response" || !xmlRoot.firstChild)
		throw("Invalid XML structure");
		
	responseText = xmlRoot.firstChild.data;*/
	//zeigt Nachricht für den User an
	myDiv = document.getElementById("content");
	myDiv.innerHTML = Response;
	checkProject();
}	
