var fromFunction = "";
function CheckForID()
{
    if(window.event)
    {
        var nbr= event.keyCode;
        if(nbr == 13)
        {
            fromFunction = "CheckForID";
            GenerateURL();
        }
    }
}

function GenerateURL()
{	
    var strPathOption = "http://www.ca.com/us/securityadvisor/search/default.aspx?ct=210675050&col=sa";
    var strTemp = document.getElementById('rnFindThreats_txtSearch').value;
    var selectedIndex = document.getElementById('rnFindThreats_hdSelInd').value;
    if (selectedIndex.length > 0)
        strPathOption = selectedIndex;
    var strTempBlank = document.getElementById('rnFindThreats_txtSearch').value;
    strTempBlank = strTempBlank.replace(/\s*/, '');
    if(strTempBlank.length > 0)
    {	
        strTemp = strTempBlank.replace(/\s\s*/, ' ');
        strTemp = strPathOption + "&qt=" + cleanup(strTemp);
        window.open (strTemp,"mywindow"); 
        if(fromFunction == "CheckForID")
           fromFunction += ":GenerateURL";
    }
    else
    {
        alert('Please enter a search term.');
    }
}

function cleanup(search_term)
{
    var ret_string = search_term;

    var postfix_test = /\.\w\w/i.exec(ret_string);
    
    if(postfix_test!=null)
    {
        if(postfix_test.length>0)
        {
            var posit = ret_string.indexOf(postfix_test);
            
            //if suitable prefix and/or moniker then remove postfix
            if(posit>9){
                ret_string = ret_string.replace(/\.\w\w/g, "");
                //ret_string = ret_string.replace(".", "%2E");
            }
        }
    }
    ret_string = ret_string.replace("/", "%2F");
    
    return ret_string;
}

function SetSelectedItem(value)
{
    document.getElementById('rnFindThreats_hdSelInd').value = value;
}

