function ValidateLogin()
{
    var txt = $(".logintxt input");
    if (txt[0].value.replace(/^\s\s*/, '').replace(/\s\s*$/, '').length < 1) {
        alert('Please enter your email address.');
        return false;
    }
    else if (txt[1].value.replace(/^\s\s*/, '').replace(/\s\s*$/, '').length < 1) {
        alert('Please enter your password.');
        return false;
    }
}

function ValidateSearch()
{
    if ($('.txtsearch').val().length < 1)
    {
        alert("Please enter a search term.");
        return false;
    }
    return true;
}

//finds the element where 'enter' was pressed, then searches for the *next* input button and clicks it.
//searches up to 3 elements deep for it (parent() *3).
///note: the array definition on filteredInputCollection may not be necessary.
///note: obj may either be the textbox or a clickable button.
function EnterKeypress(obj, e) {
    if (e.keyCode == 13) {
        if (obj.click() != null) {
            obj.click();
        }
        else {
            var parent = $(obj).parent().parent().parent().find("input");
            var index = $(parent).index(obj);
            for (var i = index; i < parent.length; i++) {
                var filteredInputCollection = $(parent[i]).filter("input:submit, input:button, input:image");
                if (filteredInputCollection[0] != null)
                    filteredInputCollection[0].click();
            }
        }
        return false;
    }
}

function dbg(obj) {
    console.log(obj);
}