	//
	// AJINA Open Source AJAX-Framework
	//
	// http://www.ajina.org
	//
	// Copyright (c) 2005, 2006 by Andreas van Loock
	//
	// This source file is subject to version 2.0 of the GPL license,
	// that is bundled with this package in the file LICENSE, and is
	// available through the world-wide-web at the following url:
	//
	// http://www.ajina.org/lizenz/gpl_license.html
	//
	// If you did not receive a copy of the phpFormular license and are unable
	// to obtain it through the world-wide-web, please send a note to
	// info@toolpixx.com so we can mail you a copy immediately.
	//
	// Author: Andreas van Loock
	//

	//
	// This ajaxConnector is the base of phpFormular-Ajax functionality
	//
	// The most wanted is, that you can connect to any with method any, then you
	// can setup the readyStateChange after request and so on. It is a most
	// simple ajax-connector to be free in requesting anything over ajax.
	//

	// Example:
	//
	// URL, METHOD (get|post), TYPE (xml|empty), VALUES
	//
	// createAjaxConnect('dummy.php{$SET_SESSION_URL}', 'POST', 'xml', 'FORMULARCOMMAND_DELETE=true&fileid={$item.id}&filetype={$item.type}')
	//

	//
	// <?xml version="1.0" encoding="ISO-8859-1" ?>
	// <ajax>
	// 	<status>true</status>
	// 	<message><![CDATA[Aktion wurde ausgef?hrt]]></message>
	// 	<htmlid><![CDATA[main]]></htmlid>
	// 	<htmlcode><![CDATA[<strong>Hau mich blau und irgendein HTML-Konstrukt welchen man dann auf der Webseite im HTML-Element "htmlid" austauscht</strong>]]></htmlcode>
	// </ajax>
	//

	// Init variables
	var http_request = false;
	var http_request_url = '';
	var http_request_method = '';
	var http_request_data = '';
	var http_request_mimetype = '';
	var http_response_text = '';
	var http_response_status = false;
	var http_response_xml = null;

	//
	// AjaxConnector
	// @string url to connect to
	// @string method to request-method
	//
	function createAjaxConnect(url, method, mimetype, data) {

		http_request = false;

		http_request_url = url;
		http_request_method = method;
		http_request_mimetype = mimetype;
		http_request_data = data;

		if (http_request_url == '') {
			alert('Es ist ein Fehler aufgetreten. Bitte geben Sie eine URL an.');
			return;
		}
		if (http_request_method == '') {
			alert('Es ist ein Fehler aufgetreten. Bitte geben Sie eine Request-Methode an (GET oder POST).');
		}

		if (http_request) {
			return;
		}

		try {
			if (window.XMLHttpRequest) { // Mozilla, Safari,...
			    http_request = new XMLHttpRequest();
			} else if (window.ActiveXObject) { // IE
			    try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			    } catch (e) {
				try {
				    http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			    }
			}
			if (http_request.overrideMimeType && http_request_mimetype == 'xml') {
				http_request.overrideMimeType('text/xml');
				// zu dieser Zeile siehe weiter unten
			}
		} catch(e) {
			alert('Es ist ein Fehler aufgetreten!');
		}
		finally{}
	}

	//
	// Send the ajax-request
	// @string stateFunction the function we will call after request
	//
	function sendAjaxRequest(stateFunction) {

		if (stateFunction != '') {
			eval('http_request.onreadystatechange = ' + stateFunction);
		} else {
			alert('Es ist ein Fehler aufgetreten. Bitte geben Sie eine OnReadyStateChange-Function an!');
		}
		try {
			if (http_request_method == 'POST') {
				http_request.open(http_request_method, http_request_url, true);
				http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				http_request.setRequestHeader( 'Content-length', http_request_data.length );
				http_request.send(http_request_data);
			} else {
				http_request.open(http_request_method, http_request_url, true);
				http_request.send(null);
			}
		} catch(e) {
			alert('Request failed!');
		}
		finally{}
	}

	//
	// Get the returncodes of request/response
	//
	function getAjaxResponseReadyState() {

		try {
			if((http_request.readyState == 4)&&(http_request.status == 200)){
			    http_response_status = true;
			    http_response_text = http_request.responseText;
			    http_response_xml =  http_request.responseXML.documentElement;
			    return true;
			}
		} catch(e) {
			alert('Bei dem Request ist ein Problem aufgetreten. ['+http_request.status+'] '+http_request.statusText);
		}
		finally{}
	}

	//
	// Return the status of responseXML
	//
	function getResponseStatus() {

		if (http_response_xml.getElementsByTagName("status")[0].firstChild.nodeValue == 'true') {
			return true;
		} else {
			return false;
		}

		return http_response_xml.getElementsByTagName("status")[0].firstChild.nodeValue;
	}