﻿            google.load('search', '1');
            
            // store the search terms
            function StoreQuery(searchControl, searcher, query) {
                sSearchTerms = query;
            }
        
            function OnLoad() {
                // create a search control
                var searchControl = new google.search.SearchControl();

                // Set the Search Control to get the most number of results
                searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
                searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);

                var webSearch = new google.search.WebSearch();
                if (sSiteRestriction != "") {
                    webSearch.setSiteRestriction(sSiteRestriction);
                }
                // Create 2 searchers and add them to the control
                searchControl.addSearcher(webSearch);

                // Set the options to draw the control in tabbed mode
                var drawOptions = new google.search.DrawOptions();
                drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);

                // Draw the control onto the page
                searchControl.draw(document.getElementById("searchcontrol"), drawOptions);
                searchControl.setSearchStartingCallback(this, StoreQuery);

                // Search, if we have some terms
                if (sSearchTerms != "") {
                    searchControl.execute(sSearchTerms);
                }
            }
            google.setOnLoadCallback(OnLoad);
            
            // when a different search option is chosen, change the restriction
            function ChangeSearchRestriction(list) {
                // update the restriction
                sSiteRestriction = list.options[list.selectedIndex].value;
                // and reload the Google form with that restriction
                OnLoad();
            }
            
            

