# Copyright (C) 2005 Bart van Kuik <bart@vankuik.nl>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
#    Free Software Foundation, Inc.
#    59 Temple Place, Suite 330
#    Boston, MA 02111-1307 USA

#
# Google Free Search code: http://www.google.com/searchcode.html
# Google Adsense Search:   http://www.google.com/adsense
#

$ModulesDescription .= '<p>A module to easily include a Google (AdSense or Free) search form</p>';

use vars qw($AdSenseSearchPageName, $GoogleSearchCode);

$AdSenseSearchPageName = "AdSenseSearch";
$GoogleSearchCode = "
<!-- Search Google -->
<center>
<FORM method=GET action=\"http://www.google.com/search\">
<input type=hidden name=ie value=UTF-8>
<input type=hidden name=oe value=UTF-8>
<TABLE bgcolor=\"#FFFFFF\"><tr><td>
<A HREF=\"http://www.google.com/\">
<IMG SRC=\"http://www.google.com/logos/Logo_40wht.gif\" 
border=\"0\" ALT=\"Google\" align=\"absmiddle\"></A>
<INPUT TYPE=text name=q size=25 maxlength=255 value=\"\">
<INPUT type=submit name=btnG VALUE=\"Google Search\">
</td></tr></TABLE>
</FORM>
</center>
<!-- Search Google -->
";


*OldGetSearchForm = *GetSearchForm;
*GetSearchForm = *NewGetSearchForm;

sub NewGetSearchForm {
  my $form;
  if ($ReplaceForm) {
    $form = T('Search:') . ' '
      . $q->textfield(-name=>'search', -size=>20, -accesskey=>T('f')) . ' ';
    $form .= T('Replace:') . ' '
      . $q->textfield(-name=>'replace', -size=>20) . ' ';
    if (%Languages) {
      $form .= T('Language:') . ' '
        . $q->textfield(-name=>'lang', -size=>10, -default=>GetParam('lang', '')) . ' ';
    }
    $form .= GetFormStart(0, 1, 'search') . $q->p($form . $q->submit('dosearch', T('Go!'))) . $q->endform;
  } else {
    $form = $GoogleSearchCode;
  }
  return $form;
}


