var selectedIndex = 0, itemCount = 0;
function keyPressed(evt) {
	switch (evt.charCode || evt.keyCode) {
		case 38: // UP
			if (--selectedIndex < 0)
				selectedIndex = 0;
			updateSelection('key');
			break;
		case 40: // DOWN
			if (++selectedIndex >= itemCount)
				selectedIndex = itemCount - 1;
			updateSelection('key');
			break;
	}
	return true;
}
function updateSelection(origin) {
	itemCount = 0;

	var list = document.getElementById('txtHint');
	var item = list.firstChild;
	while (item) {
		if (item.nodeName == 'DIV' && item != list.lastChild) {
			if(origin == 'key' && itemCount == selectedIndex) 
			{
				item.className = 'zoeksuggestitemover';
				// Let op: hieronder stond waarde uit InnerHtml halen, maar dat leverd niet gedecode waardes op. Nu uit speciaal attribuut.
				document.getElementById('Query').value=item.getAttribute('HintValue');}				
			else
			{
				item.className = 'zoeksuggestitem';
			}
			++itemCount;
		}
		item = item.nextSibling;
	}
}

function clearSelection() {
	var list = document.getElementById('txtHint');
	var item = list.firstChild;
	while (item) {
		if (item.nodeName == 'DIV' && item != list.lastChild) {
			item.className = 'zoeksuggestitem';
		}
		item = item.nextSibling;	
	}
	selectedIndex = -1
}

