// sendSearchRedirect() 
// handles search submit 
// ***edit with caution!! shared by dl, mdl, vdl***
// action = original form action
// formId = name of the form
// searchTypeId = name of field used for type of search, use '' if there is none
function sendSearchRedirect(host, action, formId, searchTypeId, oId, siteId) {

    var searchForm = document.forms[formId];
    
    // put everything in a try catch just in case
    try { 

        var qs = "?";

        // UE tracking
        var usrAction = "37"; // default = internal
    
        // if a search type is defined find set the use action id
        // else assume this is internal
        if (searchTypeId != '') {
            var sel = searchForm[searchTypeId].selectedIndex;
            var searchType = searchForm[searchTypeId].options[sel].value;
            if (searchType == 'nw') {usrAction = "98";} // all cnet
            if (searchType == 'wb') {usrAction = "97";} // the web
            // re-add search type to qs
            qs += searchTypeId + "=" + searchType + "&";
        }
    
        // the rest of the query args
        // todo: strip off the trailing '&'
        for (i=0; i<searchForm.childNodes.length; i++) {
            if (searchForm.childNodes[i].tagName == "INPUT") {
                if ((searchForm.childNodes[i].type == "text") || (searchForm.childNodes[i].type == "hidden")) {
                    qs += searchForm.childNodes[i].name + "=" + searchForm.childNodes[i].value + "&";
                }
            }            
        }
        // trim off the last &
        qs = qs.substring(0, qs.length-1);
        
    
        var destURL = host + action + escape(qs);
        var url = 'http://dw.com.com/redir?usraction=' + usrAction + '&oId=' + oId + '&siteId=' + siteId + '&destUrl=' + destURL;
        //alert(url);

        window.location=url;
    
    } catch (e) {
    
        searchForm.action = action;
        searchForm.submit();
        
    }
}