
function updateSearch(id)
{
    var searchField;
    searchField = document.getElementById(id);
    
    if (searchField.value == "") {
        searchField.value = "Type in Keyword or SKU";
    } else if (searchField.value == "Type in Keyword or SKU") {
        searchField.value = "";
    }
}
/**
 * Lawrence 4/17/2008: Perform search redirect when ENTER is pressed.
 * TN_Search_JS must exist as an HTML textfield on the page.
 * Assumes that a global variable called 'globalFullSubStoreUrl' is already set.
 */
function runSearchForField(eventObj, id)
{
    if ((eventObj.which == 13) || (eventObj.keyCode == 13)) 
    {
        var searchTerm = escape(document.getElementById(id).value); // must use escape() function to urlencode search term to avoid issues with '&' and '=' symbols
         //Bjorn 02/03/2010: Perform client side validation for HTML <tag> in search
        if (checkSearchTerm(document.getElementById(id).value)) {
            var url = location.protocol + '//' + globalFullSubStoreUrl + '/Category/CategoryListNoCache.aspx?category_id=0&search_term=' + searchTerm;
            window.location = url;
            return false;
        }
        return false;
    }
    return true;
}
/**
 * Lawrence 4/17/2008: Perform search redirect.
 * TN_Search_JS must exist as an HTML textfield on the page.
 * Assumes that a global variable called 'globalFullSubStoreUrl' is already set.
 */
function runSearchForButton(id)
{
    var searchTerm = escape(document.getElementById(id).value); // must use escape() function to urlencode search term to avoid issues with '&' and '=' symbols
    //Bjorn 02/03/2010: Perform client side validation for HTML <tag> in search
    if (checkSearchTerm(document.getElementById(id).value)) {
        var url = location.protocol + '//' + globalFullSubStoreUrl + '/Category/CategoryListNoCache.aspx?category_id=0&search_term=' + searchTerm;
        window.location = url;
    }
}

//------------------------------------------------------------------------------------------------------------------------
//Bjorn 02/03/2010: Perform client side validation for HTML <tag> in search 
function checkSearchTerm(searchTerm) {
    var re = new RegExp("&#|<!|<\/|<[A-Za-z]");
    if (searchTerm.match(re)) {
        alert('Search contains invalid characters. Please re-enter Search term.');
        return false;
    } else {
        return true;
    }

}
//----------------------------------------------------------------------------------------------------------------------------
