var xmlHttp=new Array();
var reqAction=new Array();
var continueAction=false;
function getXMLRequester() {
    xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
    return xmlhttp;
}
function processResponse( thisKennung )
{
    // status 0 UNINITIALIZED open() has not been called yet.
    // status 1 LOADING send() has not been called yet.
    // status 2 LOADED send() has been called, headers and status are available.
    // status 3 INTERACTIVE Downloading, responseText holds the partial data.
    // status 4 COMPLETED Finished with all operations.    
    switch( xmlHttp[thisKennung].readyState )
    {
        // uninitialized
        case 0:
        // loading
        case 1:
        // loaded
        case 2:
        // interactive
        case 3:
            break;
        // complete
        case 4:    
            // check http status
            if( xmlHttp[thisKennung].status == 200 )    // success
            {
                processData( xmlHttp[thisKennung],thisKennung);
                xmlHttp[thisKennung]=null;
            }
            else
            {
                if( window.handleAJAXError )
                {                	
                    handleAJAXError( xmlHttpxmlHttp[thisKennung], thisKennung );                
                }
                else
                    alert( "ERROR\n HTTP status = " + xmlHttp[thisKennung].status + "\n" + xmlHttp[thisKennung].statusText ) ;
                xmlHttp[thisKennung]=null;
            }
    }
}
function sendRequest( strSource, strData, intType, thisKennung )
{	
		xmlHttp[thisKennung]=getXMLRequester();
		
    if( !strData )
        strData = '';

    // default type (0 = GET, 1 = xml, 2 = POST )
    if( isNaN( intType ) )
        intType = 0; // GET
    // previous request not finished yet, abort it before sending a new request
    if( xmlHttp[thisKennung] && xmlHttp[thisKennung].readyState )
    {
        xmlHttp[thisKennung].abort( );
        xmlHttp[thisKennung] = false;
    }
        
    // parse query string
    if( intType != 1 && ( strData && strData.substr( 0, 1 ) == '&' || strData.substr( 0, 1 ) == '?' ) )
        strData = strData.substring( 1, strData.length );

    // data to send using POST
    var dataReturn = strData ? strData : strSource;
    switch( intType )
    {
        case 1:    // xml
            strData = "xml=" + strData;
        case 2: // POST
            // open the connection 
            //alert(strData);
            xmlHttp[thisKennung].open( "POST", strSource, true );
            xmlHttp[thisKennung].setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
            xmlHttp[thisKennung].setRequestHeader( 'Content-length', strData.length );
            break;
        case 3: // HEAD
            // open the connection 
            xmlHttp[thisKennung].open( "HEAD", strSource, true );
            strData = null;
            break;
        default: // GET
            // open the connection 
            var strDataFile = strSource + (strData ? '?' + strData : '' );
            //alert(strDataFile);
            xmlHttp[thisKennung].open( "GET", strDataFile, true );
            strData = null;
    }
    
    // set onload data event-handler
    xmlHttp[thisKennung].onreadystatechange = new Function( "", "processResponse('" + thisKennung + "')" ); ;

    // send request to server
    //debug2(strData);
    //alert("what?");
    xmlHttp[thisKennung].send( strData );    // param = POST data   
    //alert("this");
    return dataReturn;
}



// process data from server
function processData( xmlHttpTemp, thisKennung)
{
    // process text data
    handleXml(xmlHttpTemp.responseText,thisKennung);
}


function enc(s){
	s = s.replace(/\+/g, '%2B');
	s = s.replace(/\ /g, '+');
	s = escape(s);
	s = s.replace(/\"/g,'%22');
	s = s.replace(/\'/g, '%27');
	s = s.replace(/\//g,'%2F');
	return s;
}
function ents(s){
	s = s.replace(/ä/g, 'ssssza');
	s = s.replace(/Ä/g, 'sssszA');
	s = s.replace(/ü/g, 'sssszu');
	s = s.replace(/Ü/g, 'sssszU');
	s = s.replace(/ö/g, 'sssszo');
	s = s.replace(/Ö/g, 'sssszO');
	s = s.replace(/ß/g, 'sssszs');
	return s;
}