/*
// +----------------------------------------------------------------------+
// | Copyright (c) 2004 Bitflux GmbH                                      |
// +----------------------------------------------------------------------+
// | Licensed under the Apache License, Version 2.0 (the "License");      |
// | you may not use this file except in compliance with the License.     |
// | You may obtain a copy of the License at                              |
// | http://www.apache.org/licenses/LICENSE-2.0                           |
// | Unless required by applicable law or agreed to in writing, software  |
// | distributed under the License is distributed on an "AS IS" BASIS,    |
// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or      |
// | implied. See the License for the specific language governing         |
// | permissions and limitations under the License.                       |
// +----------------------------------------------------------------------+
// | Author: Bitflux GmbH <devel@bitflux.ch>                              |
// +----------------------------------------------------------------------+

*/

//Änderungen zum Original: stark gekürzt

var liveSearchReq = false;
var t = null;
var liveSearchLast = "";

var div = "LSResult";
var formular_id = "megasuche";

function liveSearchStartExt(param,param2) { div=param; formular_id=param2; liveSearchStart() };
	

function liveSearchHideDelayed(param,param2) { div=param; formular_id=param2;
  	window.setTimeout("liveSearchHide()",400);
}


function liveSearchHide() {
	document.getElementById(div).style.display = "none";
	var hm = document.getElementById("hidemely1");
	if (hm != null) {hm.style.visibility = "visible"};
	var hm = document.getElementById("cgiad");
	if (hm != null) {hm.style.visibility = "visible"};
}


function liveSearchStart() {
    if (t) {
		window.clearTimeout(t);
	}
	t = window.setTimeout("liveSearchDoSearch()",0); // vorher 200
}


function liveSearchDoSearch() {
    if (liveSearchLast != document.getElementById(formular_id).search.value) {
		if (liveSearchReq && liveSearchReq.readyState < 4) {
			liveSearchReq.abort();
		}
		if ( document.getElementById(formular_id).search.value == "") {
			liveSearchHide();
			return false;
		}
//	if (window.XMLHttpRequest) {
//	// branch for IE/Windows ActiveX version
//	  liveSearchReq = new XMLHttpRequest();
//	} else if (window.ActiveXObject) {
//          liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
//	}
	
		try{
    		liveSearchReq=new ActiveXObject("Msxml2.XMLHTTP")
  		}catch(e){
    		try{
      			liveSearchReq=new ActiveXObject("Microsoft.XMLHTTP")
    		} catch(oc){
      			liveSearchReq=null
    		}
  		}
  	
  		if(!liveSearchReq && typeof XMLHttpRequest != "undefined") {
    		liveSearchReq=new XMLHttpRequest()
  		}
  		if(!liveSearchReq) {return}

		var res = document.getElementById(div);
                var search = escape(document.getElementById(formular_id).search.value);
                search = search.replace(/\+/g, "%2b");

		res.style.display = "block";
		res.innerHTML = '<iframe style="height:270px;border:0px;" src="/parts/livesearch.mc?searchname=' + search +'"></iframe>'

		if ( 0 ) {
        	liveSearchReq.onreadystatechange= liveSearchProcessReqChange;
        	liveSearchReq.open("GET", "/parts/livesearch.mc?searchname=" + document.getElementById(formular_id).search.value);
        	liveSearchLast = document.getElementById(formular_id).search.value;
        	liveSearchReq.send(null);
    	}
	}
}


function liveSearchProcessReqChange() {
	if (liveSearchReq.readyState == 4) {
        var hm = document.getElementById("hidemely1");
		if (hm != null) {hm.style.visibility = "hidden"};
        var hm = document.getElementById("cgiad");
		if (hm != null) {hm.style.visibility = "hidden"};
		var res = document.getElementById(div);
		res.style.display = "block";
		res.innerHTML = '<table border="0" cellspacing="0" cellpadding="3" width="100%" bgcolor="#eeeeee"><tr><td class="arhead" colspan="2"><b>H&auml;ufige Suchanfragen</b></td></tr>' + liveSearchReq.responseText;
		window.status = "Fertig";
	}
}


