
function isAjaxEnabled() {
	ajaxenabled = false;
	
	try {
		ajaxenabled = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			ajaxenabled = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			ajaxenabled = false;
		}
	}
	if (!ajaxenabled && typeof XMLHttpRequest!='undefined') {
		ajaxenabled = new XMLHttpRequest();
	}
	
	/*
	if(!ajaxenabled) {
		return false;
	} else {
		return true;
	}
	*/
	
	return false;
}

function ajaxRequest(url, onCompleteFunction) {	
	if(debug) alert("Step 05a: Ajax Request vorbereiten");
	
	//var ajaxRequestUserCallback = callback;
	var ajaxRequestUrl 			= url;
	var ajaxRequest				= null;
	
	if(debug) alert("Step 06: Ajax Implementierung ermitteln");
	
	try {
		ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		if(debug) alert("Step 06a: Ajax Implementierung: Msxml2.XMLHTTP");
	} catch (e) {
		try {
			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			if(debug) alert("Step 06a: Ajax Implementierung: Microsoft.XMLHTTP");
		} catch (E) {
			ajaxRequest = false;
		}
	}
	if (!ajaxRequest && typeof XMLHttpRequest!='undefined') {
		ajaxRequest = new XMLHttpRequest();
		if(debug) alert("Step 06a: Ajax Implementierung: XMLHttpRequest");
	}
	
	if(ajaxRequest) {		
		if(debug) alert("Step 07: Ajax Implementierung: " + ajaxRequest);
		
		ajaxRequestUrl += ((ajaxRequestUrl.indexOf('?') > -1) ? '&' : '?') + 'ajaxRequestId=' + new Date().valueOf();
		
		if(debug) alert("Step 08: Send Ajax Request");
		
		ajaxRequest.onreadystatechange = function() {
			if(debug) alert("Step 09: ReadyStateChange: " + ajaxRequest.readyState);
	
			if (ajaxRequest.readyState == 4) {
				if (ajaxRequest.status == 200 || ajaxRequest.status == 0) {
					if(debug) alert("Step 10: Ajax Request Success. Starting Callback");
					
					//ajaxRequestUserCallback(ajaxRequest);
					//writeData(ajaxRequest);
					eval(onCompleteFunction+"(ajaxRequest);");
					
				} else {
					if(debug) alert("Step 10: Ajax Request Failure.");
				
					//_iwfOnRequestError(req.status, req.statusText, req.responseText);
				}
				return;
			}
		
		}
		ajaxRequest.open("GET", ajaxRequestUrl, true);
		ajaxRequest.send(null);
	} else {
		if(debug) alert("Step 07: No Ajax Implementation Found");
		//neu fn, 20.9.2006. DER möchte einen Hinweis für den User
		document.getElementById("result_headline").innerHTML 	= "<span style=\"display:block;text-align:center;\"><b>Verbindungsfehler</b></div>";
		document.getElementById("result").innerHTML 		= '<span style="font-size:12px;color:#424242">Sollten Sie den Internet Explorer einsetzen, pruefen Sie bitte in den Sicherheitseinstellungen, ob ActiveX-Steuerelemente ausgefuehrt werden duerfen.';
	}
}

function ajaxIframeRequest(url,callback) {
	if(!frames['AjaxFrame']) {
		alert("hier");
	
		var ajaxFrameParent = document.createElement("DIV");
		ajaxFrameParent.style.visibility="hidden";
		ajaxFrameParent.style.position="absolute";
		ajaxFrameParent.style.left="-10000";
		ajaxFrameParent.style.top="-10000";
		ajaxFrameParent.style.width="0";
		ajaxFrameParent.style.height="0";
		
		var ajaxFrame = document.createElement("IFRAME");
		ajaxFrame.name="AjaxFrame";
		ajaxFrame.id="AjaxFrame";
		//ajaxFrame.onload=callback;
		
		ajaxFrameParent.appendChild(ajaxFrame);
		document.body.appendChild(ajaxFrameParent);
	}
	
	alert("dort");
	
	
	//document.getElementById("AjaxFrame").setAttribute("onload", function() {alert("test");});
	
	//document.getElementById("AjaxFrame").contentWindow.onload = function() {alert("test");};
	
	//iFrameEl.contentWindow.document
		
	frames['AjaxFrame'].document.onload = callback;
	frames['AjaxFrame'].location.href = url;
	
}

function extractIFrameBody(iFrameEl) {

  var doc = null;
  if (iFrameEl.contentDocument) { // For NS6
    doc = iFrameEl.contentDocument; 
  } else if (iFrameEl.contentWindow) { // For IE5.5 and IE6
    doc = iFrameEl.contentWindow.document;
  } else if (iFrameEl.document) { // For IE5
    doc = iFrameEl.document;
  } else {
    alert("Error: could not find sumiFrame document");
    return null;
  }
  
  //return doc.body;
  return doc;

}
