document.write('<div id="SearchInput" class="DivSearch" onmouseover="SearchInputOver();" onmouseout="SearchInputOut();"></div>');

SearchInputTimer = null;
SearchInputEvent = 0;

function SearchInputKeyPress(Object, Search, Variable, Prefix)
{
	if (typeof(Prefix)=="undefined")
		Prefix = "";

	if (SearchInputTimer)
		clearTimeout(SearchInputTimer);

	SearchInputTimer = window.setTimeout(function () { SearchInputSearch(Object, Search, Variable, Prefix); } , 1000);
}

function SearchInputFocus()
{
	SearchInputEvent++;
}

function SearchInputBlur()
{
	if (SearchInputTimer)
		clearTimeout(SearchInputTimer);
	SearchInputHide();
}

function SearchInputOver()
{
	SearchInputEvent++;
}

function SearchInputOut()
{
	window.setTimeout(function () { SearchInputHide(); } , 500);
}

function SearchInputSearch(Object, Search, Variable, Prefix)
{
	DivSearch = document.getElementById("SearchInput");

	DivSearch.style.height = null;
	DivSearch.style.width = Object.offsetWidth;
	DivSearch.style.top = GetElementPositionY(Object)+Object.offsetHeight;
	DivSearch.style.left = GetElementPositionX(Object);

	XMLHTTPObject = getXMLHTTPObject();

	XMLHTTPObject.open('GET', Search+'?object=SearchInput&type='+Object.name+'&formobject='+Object.name+'&search='+Object.value+'&variable='+Variable+'&prefix='+Prefix, true);
	XMLHTTPObject.onreadystatechange = function() { if (XMLHTTPObject.readyState==4) eval(XMLHTTPObject.responseText); };
	XMLHTTPObject.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	XMLHTTPObject.send('');
}

function SearchInputShow()
{
	DivSearch = document.getElementById("SearchInput");

	DivSearch.style.display = "block";

	if (DivSearch.offsetHeight>52)
		DivSearch.style.height = 52;
}

function SearchInputHide()
{
	SearchInputEvent--;

	if (SearchInputEvent==0)
	{
		DivSearch = document.getElementById("SearchInput");
		DivSearch.style.display = "none";
	}
}

function SearchInputSelect(Search, Variable, Prefix, ID)
{
	DivSearch = document.getElementById("SearchInput");
	DivSearch.style.display = "none";

	XMLHTTPObject = getXMLHTTPObject();

	XMLHTTPObject.open('GET', Search+'?object=SearchInput'+'&variable='+Variable+'&prefix='+Prefix+'&id='+ID, true);
	XMLHTTPObject.onreadystatechange = function() { if (XMLHTTPObject.readyState==4) eval(XMLHTTPObject.responseText); };
	XMLHTTPObject.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	XMLHTTPObject.send('');
}

function SearchInputFieldValue(Field, Value)
{
	for(LoopForm=0;LoopForm<document.forms.length;LoopForm++)
	{
		for(LoopElement=0;LoopElement<document.forms[LoopForm].length;LoopElement++)
		{
			if (document.forms[LoopForm].elements[LoopElement].name==Field)
			{
				switch(document.forms[LoopForm].elements[LoopElement].type)
				{
					case "select-one":
						for(Loop=0;Loop<document.forms[LoopForm].elements[LoopElement].options.length;Loop++)
						{
							if (document.forms[LoopForm].elements[LoopElement].options[Loop].value==Value)
								document.forms[LoopForm].elements[LoopElement].selectedIndex = Loop;
						}
						break;

					case "radio":
						for(Loop=0;Loop<document.forms[LoopForm].elements[document.forms[LoopForm].elements[LoopElement].name].length;Loop++)
						{
							if (document.forms[LoopForm].elements[document.forms[LoopForm].elements[LoopElement].name][Loop].value==Value)
								document.forms[LoopForm].elements[document.forms[LoopForm].elements[LoopElement].name][Loop].checked = true;
							else
								document.forms[LoopForm].elements[document.forms[LoopForm].elements[LoopElement].name][Loop].checked = false;
						}
						break;

					default:
						document.forms[LoopForm].elements[LoopElement].value = Value;
						break;
				}
			}
		}
	}

}

