﻿// Activates a button when the Enter key is pressed within a text box.
// =========================================================================================
function ButtonSubmitOnEnter(e, buttonId)
{
    if (e.keyCode == 13)
    {
        var button = document.getElementById(buttonId);
        if (button)
        {
            button.focus();
        }
    }
}

// Performs a dictionary search.
// =========================================================================================
function DictionarySearchOnKey(e, searchBoxId)
{
    if (e.keyCode == 13)
    {
        DictionarySearch(searchBoxId);
        return false;
    }
    return true;
}


function DictionarySearch(searchBoxId) 
{
    var searchValue = document.getElementById(searchBoxId).value;
    if (searchValue.length > 0)
    {
        var windowUrl = "http://xmlwords.infomine.com/xmlwords.htm?term=" + searchValue;
        var newWindow = window.open(windowUrl, "_blank");
        if (newWindow)
        {
            if (newWindow.focus)
            {
                newWindow.focus();
            }
        }
    }
}

