var xmlHttp = createXmlHttpRequestObject();
var xmlHttp2 = createXmlHttpRequestObject();

// retrieves the XMLHttpRequest object
function createXmlHttpRequestObject()
{
  // will store the reference to the XMLHttpRequest object
  var xmlHttp;
  // if running Internet Explorer
  if(window.ActiveXObject)
  {
    try
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  // if running Mozilla or other browsers
  else
  {
    try
    {
      xmlHttp = new XMLHttpRequest();
    }
    catch (e)
    {
      xmlHttp = false;
    }
  }
  // return the created object or display an error message
  if (!xmlHttp)

    alert("Error creating the XMLHttpRequest object.");
  else
    return xmlHttp;
}

/* TODO: Test vernünftig umwandeln! */
function test(name){
	if (xmlHttp != null) {
	   xmlHttp.open("GET", "./ajax/hundeliste.php?name=" + escape(name), true);
	   xmlHttp.onreadystatechange = ausgeben;
	   xmlHttp.send(null);
	}
}

function ausgeben() {
   if (xmlHttp.readyState == 4) {
      document.getElementById("hundeliste").innerHTML =
         xmlHttp.responseText;
   }
}

function getAnzahlErgebnisseVolltextSuche(pvSearchString, pvPLZ, pvKid){
	if (xmlHttp2 != null) {
	   xmlHttp2.open("GET", "./ajax/volltextsuchergebnis.php?kid=" + escape(pvKid) + "&suchstring=" + escape(pvSearchString) + "&plz=" + escape(pvPLZ), true);
	   xmlHttp2.onreadystatechange = volltextSucheErgebnis;
	   xmlHttp2.send(null);
	}
}

function volltextSucheErgebnis(){
   if (xmlHttp2.readyState == 4) {
      document.getElementById("volltextsucheergebnis").innerHTML =
         xmlHttp2.responseText;
   }
}




/**
 Den übergebenen Layer anzeigen / verstecken
*/
function showHideDiv(szDivID, iState) // 1 visible, 0 hidden
{
  document.getElementById(szDivID).style.display= iState ? "block" : "none";
}