﻿
//Navigates to the search results page with the value to be searched as the query string parameter.
function search() {
	var searchForValue = trim(document.getElementById("txtSearchFor").value);
	if (searchForValue != "") {
		searchForValue = escape(searchForValue);
		document.forms[0].action
			 = document.getElementById("hdnSearchResultsUrl").value+'?search='+searchForValue; 
		document.forms[0].submit();	
	}
}

//Invokes the search upon pressing the enter key.
function onEnterKeyPress(event)
{
	if (event.keyCode==13 || event.which==13)
	{ 
		search();
	}
}

//Trim the given string.
function trim(str)
{
	str = str.replace(/^\s+/, '');
	return str.replace(/\s+$/, '');
}
