searchBox = {
        /** $Header: /cvs/root/host/knova/help_uk/jslib/searchBox.js,v 1.1.1.1 2010/04/18 17:45:41 sitemike Exp $  */

        currentSelectedTab : 'aol_help',
        searchDocType : '',
        prevSearches : new Array(),

        /**
         * resets the target of the search form every time the Help Catagories
         * drop down menu is clicked.
         */
        setHelpCategoryAction : function() {
                var searchForm = document.getElementById( 'sw_menu_top_h_search' );
                var helpCategory = document.getElementById( 'temp_product' );


                searchForm.action = searchForm.action.split( '?' )[ 0 ] + '?product=' + 
                    helpCategory.value;
        },

        /**
         *  Submits the form defined in this JSP with the given search string.
         */
        runSearch : function ( searchString, submit ) {
            var srchBar = document.getElementById( 'help_search' );
            srchBar.value = searchString;

            if ( submit ) {
                var searchForm = document.getElementById( 'sw_menu_top_h_search' );
                searchFailureCheck();
                searchForm.submit();
            }
            else {
                redirectSearchInnerElements( 'sw_menu_top_h_search', true );
            }
        },


        /**
         * Sets the "product" value of the form before submition
         *
         * Also checks the search form to make sure a keyword was entered
         */
        submitSearchForm : function () {

            // Checks for an emptry string or only white space in the search
            // keyword field
            searchField = document.getElementById( 'search' );
            searchVal = searchField.value.replace( /^\s*(.*)\s*$/, '$1' );
            if ( searchVal == '' || searchVal == 'Search AOL Help') {
                alert( 'Please enter a keyword or phrase' );
                return false;
            }

            product = document.getElementById( "product" );

            if ( product != null ) {
                ver = document.getElementById( "version" );
                //// Connection has been removed.  Always use 'Broadband'
                //con_type = document.getElementById( 'con_type' );
                help_type = document.getElementById( 'help_type' );

                product.value = ver.value + ',' + 'Broadband' + ',' + help_type.value;
                // removes excess white space and commas, so we don't submit
                // something like 'product=SG_Movies,,'
                product.value = product.value.replace( /^[,\s]*(.*)[,\s]*$/, '$1');
            }
            return true;
        },

        /**
         * Taken from Header Footer.JS to change the alert string
         */
        validateSearch : function ( formID, submit ) {
            s = $(formID).searchString.value;
            s = s.replace(/^\s*(.*?)\s*$/,"$1");
            $(formID).searchString.value = s;
            if (s.replace(/ /g, '') == '') { 
                alert( 'Please enter a keyword or phrase' );
                return false;
            }
            else {
                if ( submit ) {
                        var webSearch = document.getElementById( 'radio_web_search' );
                            if(webSearch) {
                               if (webSearch.checked == true) {
                                    window.open("http://search.aol.com/aolcom/search?query="+s);
                                    //we dont want to also do the search in aol help.
                                    return false;                                    
                               }
                            }
                 }
                 $(formID).submit();
             }
             return true;
        },

        /**
         * On load of the search results page, call this function to highlight the correct tab.
         */
        setResultsTab : function() {
                if ( this.searchDocType != '' ) {
                        this.switchTabs( this.searchDocType );                        
                }
        },

        /**
         * Sets the AOL Version select box to a default value.
         */
        setSelectedAolVersion : function() {
            version = document.getElementById( 'ver' );
            if ( document.selectedAolVersion ) {
                version.value = document.selectedAolVersion;
            }
            else {
                version.value = 'SAL_9_0_Security_Ed__';
            }
        }

}




