var xmlhttp;

function bezirk_ajax(bezirk) 
{
	var bundesland;
	bundesland=document.form_suche.q_bundesland.value;
	
	if(bundesland=="alle" || bundesland=="Österreich" || bundesland=="Deutschland")
	{
		document.getElementById('bezirk_tiersuche_cont').innerHTML="";
		document.getElementById('tr_bezirk_tiersuche').style.display="none";
	}
	else
	{
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
	  	{
	  	alert ("Your browser does not support XMLHTTP!");
	  	return;
	  	}
		
		var bundesland_ajax;
		bundesland_ajax=bundesland.replace(/ö/, "ooee");
		bundesland_ajax=bundesland_ajax.replace(/ä/, "aaee");
		bundesland_ajax=bundesland_ajax.replace(/ü/, "uuee");
		bundesland_ajax=bundesland_ajax.replace(/-/, "bbbb");
		
		var bezirk_ajax;
		bezirk_ajax=bezirk.replace(/ö/, "ooee");
		bezirk_ajax=bezirk_ajax.replace(/ä/, "aaee");
		bezirk_ajax=bezirk_ajax.replace(/ü/, "uuee");
		bezirk_ajax=bezirk_ajax.replace(/-/, "bbbb");
		bezirk_ajax=bezirk_ajax.replace(/ß/, "ssss");
		bezirk_ajax=bezirk_ajax.replace(/ /, "xxxx");
		bezirk_ajax=bezirk_ajax.replace(/\(/, "gggg");
		bezirk_ajax=bezirk_ajax.replace(/\)/, "hhhh");
		
		var url="http://www.tieranzeigen.at/ajax/get_bezirk_tiersuche.php?bundesland="+bundesland_ajax+"&bezirk="+bezirk_ajax;
		
		xmlhttp.onreadystatechange=stateChanged;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		}
		
		function stateChanged()
		{
		  if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete")
		  {
		  document.getElementById('bezirk_tiersuche_cont').innerHTML=xmlhttp.responseText; 
		  document.getElementById('tr_bezirk_tiersuche').style.display="";
		  }
		}
		
		function GetXmlHttpObject()
		{
		if (window.XMLHttpRequest)
		  {
		  // code for IE7+, Firefox, Chrome, Opera, Safari
		  return new XMLHttpRequest();
		  }
		if (window.ActiveXObject)
		  {
		  // code for IE6, IE5
		  return new ActiveXObject("Microsoft.XMLHTTP");
		  }
		return null;
	}
}
