/////////////////////////////////////start custom search engine stuff/////////////////////////////////////////
      // the cse class encapsulates a left and right search control
      // both controls are driven by a shared search form
      function cse() {
        var sFormDiv = document.getElementById("searchForm");
        var rightScDiv = document.getElementById("rightSearchControl");

        // create a left, right search control
        // create a custom search form
        this.rightControl = new GSearchControl();
        this.searchForm = new GSearchForm(true, sFormDiv);

        // bind clear and submit functions
        this.searchForm.setOnSubmitCallback(this, cse.prototype.onSubmit);
        this.searchForm.setOnClearCallback(this, cse.prototype.onClear);

        // set up for small result sets
        this.rightControl.setResultSetSize(GSearch.LARGE_RESULTSET);

        var searcher;
        var options;

        // configure right control for
        // -- cse for comparisons
        // -- cse for community
        // -- cse for shopping
        // -- blog search
        // -- video search
        searcher = new GwebSearch();
        options = new GsearcherOptions();
        searcher.setSiteRestriction("aberdeenidaho.us");
        searcher.setUserDefinedLabel("Aberdeen City - Results");
		options.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
        this.rightControl.addSearcher(searcher, options);

/*          For Video Searching tab   */
//        searcher = new GvideoSearch();
//        options = new GsearcherOptions();
//		searcher.setResultOrder(GSearch.ORDER_BY_RELEVANCE);
//        searcher.setUserDefinedLabel("Video");
//        this.rightControl.addSearcher(searcher, options);

/*          For Web Searching Tab       */
        searcher = new GwebSearch();
        this.rightControl.addSearcher(searcher);


/*          For News Searching Tab       */
//        searcher = new GnewsSearch();
//        this.rightControl.addSearcher(searcher);

        // draw the left and right controls
        // the right control is drawn in tabbed mode
        var drawOptions = new GdrawOptions();
        drawOptions.setDrawMode(GSearchControl.DRAW_MODE_TABBED);

        this.rightControl.draw(rightScDiv, drawOptions);

        // bind in a videobar
/*        var videoBarDiv = document.getElementById("videoBar");
        var videoPlayerDiv = document.getElementById("videoPlayer")
        var vboptions = {
          largeResultSet : true,
          horizontal : false
        }

        this.videoBar = new GSvideoBar(videoBarDiv, videoPlayerDiv, vboptions);
*/
        // execute a starter search
        //this.searchForm.execute("Apple iPod");

      }

      // when the form fires a submit, grab its
      // value and call the left and right control
      cse.prototype.onSubmit = function(form) {
        var q = form.input.value;
        if (q && q!= "") {
          this.rightControl.execute(q);
          //this.videoBar.execute(q);
          //this shows the search results
          document.getElementById("searchContainer").style.display = "block";
          document.getElementById("mainBody").style.display = "none";
        }
        return false;
      }

      // when the form fires a clear, call the left and right control
      cse.prototype.onClear = function(form) {
        this.rightControl.clearAllResults();
        this.videoBar.clearAllResults();
        form.input.value = "";
		hide_search_results();
        return false;
      }

      function OnLoad() {
        new cse();
      }
      function hide_search_results() {
        document.getElementById("searchContainer").style.display = "none";
         document.getElementById("mainBody").style.display = "block";
      }
///////////////////////////////////////////////////////////////end custom search engine stuff//////////////////////

