﻿// Determine if the character typed is "Enter" and execute the search results.
function SearchBoxSearchOnEnter(event1)
{
    var kCode = (event1.which) ? String.fromCharCode(event1.which) : String.fromCharCode(event1.keyCode);
    if(kCode == "\n" || kCode == "\r")
    {
        SearchBoxSubmit();
    }
}

// Format and send the search request.
function GoSearch(TbId, DDId, Url)
{
    var k = document.forms[0].elements[TbId].value;
    k = k.replace( /\s*$/, '' );
                           
    if(k == ''){
        alert('Please enter one or more search words.');
        return;
    }
    var sch = '?k=' + encodeURIComponent(k);
    
    // Specify scope in request if defined
    var s='', selVal='';
    var d = document.forms[0].elements[DDId];
    if (d)
    {
        //var fIsCS = false;
        s = d.options[d.selectedIndex].text;
        selVal = d.options[d.selectedIndex].value;
        if (s != '') {
            sch += "&s=" + encodeURIComponent(s);
        }
    }
    
    // Needed to fix a FireFox javascript bug.  This initialized something (not sure what).
    document.write();
    
    window.location = Url + sch;

    try {if(null    != event) event.returnValue = false;} catch (err) {}
    return;
}
