// makeAjaxRequest() must also be defined in this page!

function CheckQuickSearchValues(form)
{
	return (form.kw.value != "")
}

document.idTimerSuggestions = null;
document.bKeywordboxUntouched = true;

function Empty(ctrl)
{
	if (document.bKeywordboxUntouched)
	{
		ctrl.value = "";
		document.bKeywordboxUntouched = false;
	}
}

function SuggestKeywords(sDir, ctrl)
{
	if (!ctrl.value)
		ShowKeywords("");
	else
	{
		if (document.idTimerSuggestions)
			clearTimeout(document.idTimerSuggestions);

		var sUrl = sDir + "suggestkeywords.php?val=" + ctrl.value + "&cache=no";
		document.idTimerSuggestions = setTimeout("makeAjaxRequest('" + sUrl + "', 'ShowKeywords')", 400);
	}
}

function ShowKeywords(sTxt)
{
	var obj = document.getElementById("idSuggestions");
	if (obj)
	{
		obj.innerHTML = sTxt;
		if (obj.style)
			obj.style.visibility = (sTxt.length ? "visible" : "hidden");
	}
}

function UseSuggestion(sKw)
{
	var ctrl = document.getElementById("idKw");
	if (ctrl)
		ctrl.value = sKw;
	obj = document.getElementById("idSuggestions");
	if (obj && obj.style)
			obj.style.visibility = "hidden";
	ctrl.form.submit();
}
