// Java Script to Handle AutoSearch

// set up the variable that will maintain the current key value
var_keys = "";

function onSelectKeyDown()
{

	if(window.event.keyCode == 46)
		clr();

	if(window.event.keyCode == 13)
		document.forms[0].submit();
		
}

function selectKeyPress()
{
	// Notes:
	//	1) previous keys are cleared onBlur/onFocus and with Delete key
	//	2) if the search doesn't find a match, this returns to normal 1 key search
	//		setting returnValue = false below for ALL cases will prevent
	//		default behavior
	
	

	var sndr = window.event.srcElement;
	var pre = var_keys;
	var key = window.event.keyCode;
	var char = String.fromCharCode(key);

	var re = new RegExp("^" + pre + char, "i"); // "i" -> ignoreCase
	for(var i=0; i<sndr.options.length; i++)
	{
		if(re.test(sndr.options[i].text))
		{
			sndr.options[i].selected=true;
			var_keys += char;
			window.event.returnValue = false;
			break;
		}
	}
}
function clr()
{
	var_keys = "";
}


