/*
AJAX connection framework
Version 1.2. 02-11-06
Author: Bernie Witter <webmaster@syscon-gmbh.com>
(©) 2005-2006
**************************************/
//!!!!!!!! This requires an bInit() function in the calling !!!!!!!!!!!!!!!!!!!
var xmlhttp; // connection object
var resultType; // switch between xml and htm result
var XMLresult; // xml result data object
var HTMresult; // html result string
var AJAXmethod = "GET";
var AJAXpost_string = null;
//==============================================
 // get xml data
function getXML(url, what){
 resultType = what;
 	
	if(xmlhhtp = getXMLHttpObject() == false) {
	fehler("Error connecting to XML Base file.");
	return;
	}
	
xmlhttp.open(AJAXmethod, url , true);
xmlhttp.onreadystatechange = handleHttpState;
	if(AJAXmethod=="POST")
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send(AJAXpost_string);
}
//================================================
//connect:
function getXMLHttpObject(){
	try { 
	 xmlhttp = new XMLHttpRequest(); 
	} 
	catch (error) 
	{ 
	 try { 
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	 } 
	 catch (error) 
	 { 
	   return false; 
	 } 
	}
}
//=================================================
// connection or result handling:
function handleHttpState(){
	if (xmlhttp.readyState == 4){ 
		if ( xmlhttp.status == 200) {
			// ok response process:
			bResult();
		} else {
			// error
			fehler("Error reading XML file.");
		}
	} 
}
//=============================================
// xml/html  result processing:
function bResult(){
	if(resultType=="xml"){
	// DOM object:
	XMLresult = xmlhttp.responseXML;
	}else{
	//htm string:
	HTMresult = xmlhttp.responseText;
	} 
bInit(resultType);
}
//==========================================
function fehler(fehler){
alert(fehler);
}
