function GoogleSearch() {
    // create a search control
    this.searchControl = new google.search.SearchControl();
}

GoogleSearch.prototype.searchPatents = function (resultsControl, searchValues) {
    // patents
    this.searchControl.addSearcher(new google.search.PatentSearch());

    this.searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);

    // create a drawOptions object
    this.drawOptions = new google.search.DrawOptions();

    // tell the searcher to draw itself in linear mode
    this.drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);

    // tell the searcher to draw itself and tell it where to attach
    this.searchControl.draw(document.getElementById(resultsControl), this.drawOptions);

    //Set Google Analytics tracking in the callback.
    this.searchControl.setSearchCompleteCallback(this, setGooglePatentsAnalytics);

    // execute an inital search
    this.searchControl.execute(searchValues);
}

GoogleSearch.prototype.searchBooks = function (resultsControl, searchValues) {
    // books
    this.searchControl.addSearcher(new google.search.BookSearch());

    this.searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);

    // create a drawOptions object
    this.drawOptions = new google.search.DrawOptions();

    // tell the searcher to draw itself in linear mode
    this.drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);

    // tell the searcher to draw itself and tell it where to attach
    this.searchControl.draw(document.getElementById(resultsControl), this.drawOptions);

    //Set Google Analytics tracking in the callback.
    this.searchControl.setSearchCompleteCallback(this, setGoogleBooksAnalytics);

    // execute an inital search
    this.searchControl.execute(searchValues);
}

//Set Google Analytics tracking in the callback.
function setGoogleBooksAnalytics() {
    $("a", "#googleBooks").click(function () { partnerLink('', 'Google Books', 'link'); });
}

function setGooglePatentsAnalytics() {
    $("a", "#patentsGoogle").click(function () { partnerLink('', 'Google Patents', 'link'); });
}
