<!--
/**
 * Blank the search form input only if there isn't any ongoing search.
 */
function blankSearchFormInput(previousSearchValue, formElem) {
    if (previousSearchValue == '') {
        formElem.value = '';
    }
}

/**
 * Return whether the search form is empty or not.
 * This script is to be used to avoid to request a search for an empty request,
 * to save the server from useless load.
 */
function checkEmptySearch(formElem) {
    var searchGadget = document.getElementById('searchGadget');
    if (!searchGadget) {
        return false;
    }

    var query = searchGadget.value;
    if (query != '') {
        // formElem.SearchableText.value = query;
        searchGadget.value = query;
        return true;
    }
    searchGadget.value = query;
    searchGadget.focus();
    return false;
}

/**
 * Return a copy of the string with leading and trailing characters removed.
 */
function trim(s) {
    if (s) {
        return s.replace(/^\s*|\s*$/g, "");
    }
    return "";
}

//-->