searchBox = {
        /** $Header: /cvs/root/host/help/jslib/searchBox.js,v 1.3 2009/04/08 14:36:08 mhauer 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 ( tID, submit ) {
            s =$(tID).searchString.value;
            s = s.replace(/^\s*(.*?)\s*$/,"$1");
            $(tID).searchString.value = s;
            if (s.replace(/ /g, '') == '' || s.replace(/^\s*(.*)\s*$/, '$1') == 'Search AOL Help') { 
                alert( 'Please enter a keyword or phrase' );
                return false;
            }
            else {
                if ( submit ) {
                        var form = document.getElementById( 'sw_menu_top_h_search' );

                        // Check to see which tab is selected.  If it's the
                        // default tab, check the advanced search to see if a
                        // specific doctype was chosen
                        if ( document.getElementById( 'aol_help' ) && 
                             document.getElementById( 'aol_help' ).className == 'selected') {
                             //form.action = "/help/microsites/searchEntry.do?document=" + document.getElementById( 'document' ).value;
                             //check for websearch

                            if(document.forms['sw_menu_top_h_search'].search_type) {
                               if (document.forms['sw_menu_top_h_search'].search_type[1].checked == true) {
                                    //why would we need to change the form action?
                                    //form.action = "/help/microsites/searchEntry.do?document=" + document.getElementById( 'document' ).value;
                                    window.open("http://search.aol.com/aolcom/search?query="+s);
                                    //return true; //we dont want to also do the search in aol help.
                                    return false;                                    
                                }
                             }
                        }
                        /*else if ( this.currentSelectedTab != "aol_help" ) {
                            form.action = "/help/microsites/searchEntry.do?document=" + this.currentSelectedTab;
                        }
                        else {
                                form.action = '/help/microsites/searchEntry.do';
                             if(document.forms['sw_menu_top_h_search'].search_type) {
                               if (document.forms['sw_menu_top_h_search'].search_type[1].checked == true) {
                                    //form.action = "/help/microsites/searchEntry.do?document=" + document.getElementById( 'document' ).value;
                                    window.open("http://search.aol.com/aolcom/search?query="+s);
                                    //return true; //we dont want to also do the search in aol help.
                                    return false;
                                }
                             }
                        }*/
                        /*if ( document.getElementById( 'temp_product' ) &&
                             document.getElementById( 'temp_product' ).value != '' ) {
                                form.action += '&product=' + document.getElementById( 'temp_product' ).value;
                        }*/
                       /* if ( document.getElementById( 'ver' ) ) {
                                var sal = document.getElementById( 'ver' ).value + 'Broadband'; //document.getElementById( 'con_type' ).value;
                                form.action += '&sal=' + sal;
                        }*/
                        $(tID).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__';
            }
        }

}



