function addEvent(obj,evt,fn) {
	if(obj.addEventListener) {
		obj.addEventListener(evt,fn,false);
	} else if(obj.attachEvent) {
		obj.attachEvent('on'+evt,fn);
	}
}
function submitTextSearch(serverPath, lid, textFieldId, otherParms) {
	var textFieldElement = document.getElementById(textFieldId);
	var textValue = textFieldElement.value;
	objRegExp = /^(\s*)([\W\w]*)(\b\s*$)/;
	if(objRegExp.test(textValue)) {
		 textValue = textValue.replace(objRegExp, '$2');
	}
	if(textValue.length > 0) {
		var srkValue = (document.getElementById('srk') != null) ? document.getElementById('srk').value : ('' + (new Date).getTime());
		document.location.href = serverPath + 'SampleBrowser.jsp?lid=' + lid + '&ts=' + textValue + '&srk=' + srkValue + otherParms;
	}
}
var searchFocus = new Object();
  searchFocus.ServerPath = null;
  searchFocus.lid = 0;
  searchFocus.textFieldId = 'hts';
  searchFocus.otherParms = '';
function setSearchFocus(serverPath, lid, searchInputElement, otherParms) {
	searchInputElement.value = "";
	searchInputElement.style.color = '#050505';
  searchFocus.ServerPath = serverPath;
  searchFocus.lid = lid;
  searchFocus.textFieldId = searchInputElement.id;
  searchFocus.otherParms = otherParms;
}
function clearSearchFocus(searchInputElement) {
  searchFocus.ServerPath = null;
  searchFocus.lid = 0;
  searchFocus.textFieldId = 'hts';
  searchFocus.otherParms = '';
}
function keyHandler(evt) {
	if(searchFocus != null && searchFocus.ServerPath != null) {
		var keyCode = evt ? (evt.which ? evt.which : evt.keyCode) : event.keyCode;
		if(keyCode == 13) {
			return submitTextSearch(searchFocus.ServerPath, searchFocus.lid, searchFocus.textFieldId, searchFocus.otherParms);
		}
	}
	return true;
}
addEvent(document, 'keydown',  keyHandler);