function showResult(str)
{
if(!document.getElementById("livesearch")){
//	return;
}
if (str.length < 2)
  { 
  document.getElementById("livesearch").innerHTML="";
  document.getElementById("livesearch").style.border="0px";
  document.getElementById("livesearch").style.visibility = "hidden";
  return;
  }

document.getElementById("livesearch").style.visibility = "visible";
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
    document.getElementById("livesearch").style.border="1px solid #A5ACB2";
    }
  }
xmlhttp.open("GET","livesearch.php?q="+str,true);
xmlhttp.send();
}

function do_livesearch(){
	if(document.suchform.livesearchfield){
		var select = document.suchform.livesearchfield;
	} else {
		var select = document.getElementById("livesearchfield");
	}
	var livewert = select.options[select.selectedIndex].value;
	var live_position = livewert.indexOf("||");
	var live_url = livewert.substr(0,live_position);
	var live_text = livewert.substr(live_position + 2, (livewert.length - live_position - 2));
	if(live_url == "X"){
		document.getElementById("livesearch").innerHTML = "";
		document.suchform.getname.value = "";
		document.getElementById("livesearch").style.visibility = "hidden";
		if(document.suchform.xname){
			document.suchform.xname.value = "";
		}
		return;
	}
	document.suchform.getname.value = live_text;
	if(document.suchform.xname){
		document.suchform.xname.value = live_text;
	}
	document.suchform.gobutton.disabled = true;
	document.getElementById("livesearch").innerHTML = "";
	document.location.href = "/?page=suchen&realpage=search&getname="+live_url;
}
function change_livesearch(){
	if(document.suchform.livesearchfield){
		var select = document.suchform.livesearchfield;
	} else {
		var select = document.getElementById("livesearchfield");
	}
	var livewert = select.options[select.selectedIndex].value;
	var live_position = livewert.indexOf("||");
	var live_url = livewert.substr(0,live_position);
	var live_text = livewert.substr(live_position + 2, (livewert.length - live_position - 2));
	document.suchform.getname.value = live_text;
	if(document.suchform.xname){
		document.suchform.xname.value = live_text;
	}
}
var hatfocus = false;
var oldfocus = false;

function TasteGedrueckt(Ereignis){
	if(!Ereignis){
		Ereignis = window.event;
	}
	if(!Ereignis){
		return;
	}
	if(document.suchform.livesearchfield){
		var select = document.suchform.livesearchfield;
	} else {
		var select = document.getElementById("livesearchfield");
	}
	if(Ereignis && Ereignis.keyCode && Ereignis.keyCode == 40 && document.getElementById("livesearch") && document.getElementById("livesearch").innerHTML.length > 3 && hatfocus < 1 && oldfocus > 0){
		hatfocus = true;
		oldfocus = false;

		select.focus();
	} else if(Ereignis && Ereignis.keyCode && Ereignis.keyCode == 13 && document.getElementById("livesearch") && document.getElementById("livesearch").innerHTML.length > 3 && select && hatfocus){
		do_livesearch();
	}
}

function close_Livesearch(){
	document.getElementById("livesearch").innerHTML = "";
	document.getElementById("livesearch").style.visibility = "hidden";
	if(document.suchform.xname){
		document.suchform.xname.focus();
	} else {
		document.suchform.getname.focus();
	}
}

document.onkeypress = TasteGedrueckt;
document.onkeydown = TasteGedrueckt;

