// Uses predefined controls to generate a querystring search results path.
function BeginSearch(txtSearchId, radioListId, listCount) {
    var referal = "/Pages/Results.aspx";

    var txtSearchBox = document.getElementById(txtSearchId);
    var selectionMade = false;

    var thisForm = document.forms['aspnetForm'];
    var radioList = thisForm.elements[radioListId];

    if (txtSearchBox != null) {
        if (txtSearchBox.value != "") {
            referal = referal + "?k=" + txtSearchBox.value;
            if (radioList) {
                // Cycle through list items
                for (var i = 0; i <= listCount; i = i + 1) {
                    if (radioList[i] != null) {
                        if (radioList[i].checked) {
                            referal = referal + "&s=" + radioList[i].value;
                            selectionMade = true;
                            break;
                        }
                    }
                }
            }else{selectionMade = true;}
        }
    }

    if (selectionMade) {
        window.location = referal;
    }
    else {
        alert('Please enter a search keyword!');
    }
}