// this is the javascript array holding the function list
var functionlist = Array(
"AGC",
"Automatyczny balans bieli AWB",
"BTS",
"CCTV",
"Ciągłe nadgrywanie",
"Codec",
"Czujnik zmierzchowy",
"D1",
"Demodulacja",
"DualWatch",
"Efekt przesterowania",  
"Funkcja ARW",
"Geofence",
"Geo ogrodzenie",
"GPS",
"Heterodyna",
"Interpolacja",
"IR",
"Irda",
"Klasa szczelności IP",
"Kodek",
"Kompresja video H.264",
"Licznik klatek",
"Lokalizacja BTS",
"Lux",
"Matryca",
"Modulacja WFM",
"Nadpisywanie",
"Nagrywanie czasowe",
"Nagrywanie kalendarzowe",
"Obiektyw typu piniole",
"Oświetlacz IR",
"Pentaplex",
"PAL D1",
"Przesterowanie",
"Przetwornik obrazu",
"Radiator",
"Rozdzielczość analizatora",
"Rozdzielczość D1",
"SATA",
"Stabilizacja częstotliwości ARCz",
"Stempel daty i czasu",
"Squelch",
"Triplex",
"Web Server",
"Wirtualny płot",
"VOX");

// This is the function that refreshes the list after a keypress.
// The maximum number to show can be limited to improve performance with
// huge lists (1000s of entries).
// The function clears the list, and then does a linear search through the
// globally defined array and adds the matches back to the list.
function handleKeyUp(maxNumToShow)
{
	selectObj = document.forms[0].functionselect;
	textObj = document.forms[0].functioninput;

	if(document.forms[0].functionradio[1].checked == true)
	{
		strText = "^"+textObj.value;
	}
	else
	{
		strText = textObj.value;
	}
	var numShown;

	re = new RegExp(strText,"gi");

	ClearOptionsFast('functionselect');
	selectObj = document.forms[0].functionselect;

	numShown = 0;
	for(i = 0; i < functionlist.length; i++)
	{
		if(functionlist[i].search(re) != -1)
		{
			selectObj[numShown] = new Option(functionlist[i],"");
			numShown++;
		}
		if(numShown == maxNumToShow)
		{
			break;
		}
	}
	if(selectObj.length == 1)
	{
		selectObj.options[0].selected = true;
	}
}

function ClearOptionsFast(id)
{
	var selectObj = document.getElementById(id);
	var selectParentNode = selectObj.parentNode;
	var newSelectObj = selectObj.cloneNode(false); // Make a shallow copy
	selectParentNode.replaceChild(newSelectObj, selectObj);
	return newSelectObj;
}


// this function gets the selected value and loads the appropriate
// php reference page in the display frame
// it can be modified to perform whatever action is needed, or nothing
function handleSelectClick()
{
	selectObj = document.forms[0].functionselect;
	textObj = document.forms[0].functioninput;
	if(selectObj.selectedIndex == -1) {
		return;
	}

	selectedValue = selectObj.options[selectObj.selectedIndex].text;

	selectedValue = selectedValue.replace(/_/g, '-') ;
	parent.frames["functiondisplay"].location.href= "slownik/index.php?s="+selectedValue+"";

}

function initpage() {
	handleKeyUp(20);
	document.forms[0].functioninput.focus();
}
