	/*
// +----------------------------------------------------------------------+
// | 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>                              |
// +----------------------------------------------------------------------+

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

var isIE = false;
// on !IE we only have to initialize it once


function liveSearchInit() {
}


function liveSearchHide() {
	document.getElementById("SearchResult").style.display = "none";
}


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

function liveSearchDoSearch() {

	if (typeof liveSearchRoot == "undefined") {
		liveSearchRoot = "";
	}
	if (typeof liveSearchRootSubDir == "undefined") {
		liveSearchRootSubDir = "";
	}
	if (typeof liveSearchParams == "undefined") {
		liveSearchParams2 = "";
	} else {
		liveSearchParams2 = "&" + liveSearchParams;
	}
	if (liveSearchLast != document.forms.searchform.q.value) {
	if (liveSearchReq && liveSearchReq.readyState < 4) {
		liveSearchReq.abort();
	}
	if ( document.forms.searchform.q.value == "") {
		liveSearchHide();
		return false;
	}

	if (window.XMLHttpRequest) {
	// branch for IE/Windows ActiveX version
		liveSearchReq = new XMLHttpRequest();
		liveSearchReq.onreadystatechange= liveSearchProcessReqChange;
		liveSearchReq.open("GET", liveSearchRoot + "index2.php?opcja=" + document.forms.searchform.q.value + liveSearchParams2,true);
		liveSearchLast = document.forms.searchform.q.value;
		liveSearchReq.send(null);
	} else if (window.ActiveXObject) {
		liveSearchReq = new ActiveXObject("Microsoft.XMLHTTP");
		liveSearchReq.onreadystatechange= liveSearchProcessReqChange;
		liveSearchReq.open("GET", liveSearchRoot + "index2.php?opcja=" + document.forms.searchform.q.value + liveSearchParams2,false);
		liveSearchLast = document.forms.searchform.q.value;
		liveSearchReq.send();
	}

	}
}

function liveSearchProcessReqChange() {
	if (liveSearchReq.readyState == 4) {
		if (liveSearchReq.status == 200) {
			var  res = document.getElementById("SearchResult");
			res.style.display = "block";
			var  sh = document.getElementById("SearchResult");
			sh.innerHTML = liveSearchReq.responseText;

			//var newdiv = document.createElement("div");
			//newdiv.innerHTML = liveSearchReq.responseText;
			//var container = document.getElementById("SearchResult");
			//container.appendChild(newdiv);

			MyResizeDialogToContent();
		} else {
			alert("There was a problem retrieving the XML data:\n" + liveSearchReq.statusText);
		}
	}
}


MyResizeDialogToContent = function()
{
  if (window.sizeToContent)
  {
    // gecko
    window.sizeToContent();
  }
  else
  {
    window.resizeTo(600, 500);
    dialog_chrome_width = 600 - document.body.clientWidth;
    dialog_chrome_height = 500 - document.body.clientHeight;
    window.resizeTo(50, 40);
    window.resizeTo(document.body.scrollWidth + dialog_chrome_width, document.body.scrollHeight + dialog_chrome_height);
  }
}