﻿
// -----------------------------------------------------------------------------------------------
function Search(evt)
{
    var keyNum;
    if (window.event) { keyNum = evt.keyCode; } // IE
    else if (evt.which) { keyNum = evt.which; } // Netscape/Firefox/Opera

    if ((keyNum == 13) || (evt == 'do'))
    {
        var searchHeadInput = document.getElementById('search');
        var strSearch = trim(removeSpaces(searchHeadInput.value));

        if (strSearch != '')
        {
            if (document.domain == 'localhost')
            {
                setTimeout("window.location='http://localhost:1808/search.aspx?par1=" + strSearch + "'", 0);
            }
            else
            {
                setTimeout("window.location='http://www.bainesandernst.co.uk/search/" + strSearch + "/'", 0);
            }
        }
    }
}

// -----------------------------------------------------------------------------------------------
function removeSpaces(str)
{
    return str.replace(/\s+/, " ");
}

// -----------------------------------------------------------------------------------------------
function trim(str)
{
    var result = str.replace(/^\s+|\s+$/g, '');
    return result;
}
