var http = null;

function getBranchen()
{
  
	var suche = document.Suche.Branchensuche.value;
	if (window.XMLHttpRequest) {
   	http = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
	   http = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (http != null) {
		var i = 0;
		// http.open("GET", "branchen.php?Suche="+escape(suche), true);
		http.open("GET", "branchen.php?Suche=" + encodeURI(suche), true);
    	http.onreadystatechange = ausgeben;
	    http.send(null);
	}
}

function ausgeben() {
   if (http.readyState == 4) {
   var SelectBox = document.forms.Suche.Branchen;
      var unsortiert = http.responseText;
      var splitted = unsortiert.split("///V///");
      var anzahl = (splitted.length - 1) / 2;
      var k = 1;
      var opt = 0;
      var val = 1;
      var length = SelectBox.length;
      var i = 0;
	  while(++i < length+2) {
                SelectBox.options[0] = null;

	 }    
	for (var i = 0; i < anzahl; i++)
	{
	 	if (i == 0)
		{
		   SelectBox.options[0] = new Option("Alle","Alle", true);
	   	}
	   SelectBox.options[k] = new Option(splitted[opt], splitted[val]);
	   k++;
	   opt++;
	   val++;
	   opt++;
	   val++;
	}

         }
}
