﻿function search_keyPress(ev)
{
    if (ev.keyCode == 13) 
    {
        var btnSubmit = document.getElementById("ctl00_ucSearch_btnSearch");
        btnSubmit.focus();
        
        // onclick work with firfox
        if(document.all)
        {
            btnSubmit.click();
        }
        else
        {
            btnSubmit.onclick();
        }

        //remove enter key
        if(window.event)
        {
            ev.returnValue = false;
            ev.cancel = true;
        }
        else
        {
            ev.preventDefault(); 
            ev.stopPropagation();

        }

    }
}

function search_click()
{
    var txtPhrase = document.getElementById("ctl00_ucSearch_txtPhrase");
     
    if (trim(String(txtPhrase.value)) == "")
    {
        location.href = search_pageAdvancedSearch;
    }
    else
    {
        var ddSection = document.getElementById("ctl00_ucSearch_ddSection");
        
        var strSection = "";
        if (ddSection.style.display == "")
        {
            if (ddSection.options[ddSection.selectedIndex].value != "")
            {
                strSection = ddSection.options[ddSection.selectedIndex].value;
            }
        }
 
        if (strSection != "")
        {
            var txtPhrase = document.getElementById("ctl00_ucSearch_txtPhrase");
            var bufParams = "Phrase=" + txtPhrase.value + "&UserName=" + strSection;
            
            location.href = search_pageSearchResultsWithParams.replace("{0}", bufParams);
        }
        else
        {
            location.href = search_pageSearchResults.replace("{0}", txtPhrase.value);
        }

    
    }
}

