var showErrors = true;
var cache = new Array();
var xmlHttp_1 = createXmlHttpRequestObject();

function createXmlHttpRequestObject() {
  var xmlHttp;

  try  {
    xmlHttp = new XMLHttpRequest();
  } catch(e) {
    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) {
    displayError("Error creating the XMLHttpRequest object.");
  } else {
    return xmlHttp;
  }
}

function displayError($message) {
  if (showErrors)   {
     showErrors = false;
     alert("Error encountered: \n" + $message);
  }
}

//Ajax Funkition, tausch asynchron mit Server über XMLHTTPReaquest Objekt Daten aus
function sys_ajax_process_url(xmlHttp_v, pfad, parameter, function_name, div, v1, v2, v3) {
   if (!document.getElementById(div)) {div='';}   //falls kein HTML Div übergeben

   if(xmlHttp_v) {

      if (xmlHttp_v.readyState == 1 || xmlHttp_v.readyState == 2 || xmlHttp_v.readyState == 3) {
         if (div != '') {document.getElementById(div).innerHTML = 'please waiting ...';}
      } else {
         xmlHttp_v.open('GET', pfad, true);
         xmlHttp_v.onreadystatechange = function () {
			if (xmlHttp_v.readyState == 2) {
			   if (div != '') {document.getElementById(div).innerHTML = 'loading ...'; }
            }
            if (xmlHttp_v.readyState == 4) {
               if ((xmlHttp_v.status == 200) || (xmlHttp_v.status == 0)) {
                    var content = xmlHttp_v.responseText;
					if (function_name) {
					   var my_function = eval(function_name);
					   my_function(content, v1, v2, v3);  //übergebene Funktion aufrufen Parameter sind optional
					}
               } else if (xmlHttp_v.status == 404) {
                    if (div != '') {document.getElementById(div).innerHTML = 'no data ...';}
               }
            }
         }
         xmlHttp_v.send(null);
      }
   }
}