/* Search functionality
    - Captures all key presses on the screen
    - If SearchRequestBoxFocus is false, exit
    - Otherwise, if key code equals 13 (Enter), run search
*/
var SearchFieldName = 'txtRequest'; // name of the field
var SearchRequestBoxFocus; // set onfocus and onblur in the text box
var SearchPageURLPrefix; // set in the page

document.onkeypress =
	function checkKeyPress(e){
		if (SearchRequestBoxFocus){
			if (!e) e = window.event;
			var key = (typeof e.which == 'number')?e.which:e.keyCode;
			if (key == 13){
				doSearch();
				return false;
			}
		}
	}
if (document.captureEvents && !document.addEventListener){
	document.captureEvents(Event.KEYPRESS);
}
if (document.addEventListener){
	document.addEventListener("keypress",checkKeyPress, true);
}
function doSearch() {
	location.href = SearchPageURLPrefix + document.getElementById(SearchFieldName).value;
}
