//Online Index Search page JavaScript code

function validateInputs(theForm) {
	//the keywords can not contain the default text
	defaultText = "--Enter a keyword, article title, or author--"
	if (ecTrim(theForm.searchTerm.value).toLowerCase() == defaultText.toLowerCase()) {
		theForm.searchTerm.value = "";
	}

	//the keywords can not be empty
	theForm.searchTerm.value = ecTrim(theForm.searchTerm.value);
	if (theForm.searchTerm.value.length == 0) {
		alert("You didn't enter any words.");
		theForm.searchTerm.focus();
		return false;
	}

	//the keywords can not be just "0" which is often used by auto programs trying to break the site.
	if (theForm.searchTerm.value == '0') {
		alert("You didn't enter any valid keywords.");
		theForm.searchTerm.focus();
		return false;
	}

	//the keywords can not be longer than 256 characters
	if (theForm.searchTerm.value.length > 256) {
		alert("The keywords cannot be more than 256 characters long.");
		theForm.searchTerm.focus();
		return false;
	}
	
	//if reached here, we're OK
	return true;	
}


//alway clear the instruction text for keyword search
function handleKeywordBoxClick(t) {
	defaultText = "--Enter a keyword, article title, or author--"
	if (ecTrim(t.value).toLowerCase() == defaultText.toLowerCase()) {
		t.value = "";
	}
}
