var MPL_URL = 'http://mahometpubliclibrary.org';
var LT_BASE = 'http://lincpac.lincolntrail.info:8080/ipac20/ipac.jsp?';
function MyMahomet () {
   /* Here are the catalog search URL constants. */
   this.catalog_keyword = LT_BASE+"menu=search&npp=25&profile=man&index=.GW&term=";
   this.catalog_title   = LT_BASE+"menu=search&npp=25&profile=man&index=PALLTI&term=";
   this.catalog_author  = LT_BASE+"menu=search&npp=25&profile=man&index=PAUTHOR&term=";
   this.catalog_subject = LT_BASE+"menu=search&npp=25&profile=man&index=PSUBJ&term=";
   this.catalog_video   = LT_BASE+"menu=search&npp=25&profile=man&index=.VW&term=";
   this.site_search     = "http://www.google.com/search?hl=en&sitesearch=mahometpubliclibrary.org&q=";
   this.google_search   = "http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=";

   /* These are constants for the "How Do I:" field. */
   this.howto = new Object();
   this.howto['renewing_items'] = MPL_URL+'/about/how-do-i-renew-items/';
   this.howto['find_book_dvd_cd'] = LT_BASE+'profile=man#focus';
   this.howto['check_account'] = LT_BASE+'session=11A9911OH7390.4104&profile=man&menu=account&ts=1199911567406#focus';
   this.howto['learn_pin'] = MPL_URL+'/about/how-do-i-learn-my-pin/';
   this.howto['library_card'] = MPL_URL+'/about/how-do-i-get-a-library-card/';
   this.howto['first_search'] = 'http://newfirstsearch.oclc.org';
   this.howto['media_mall'] = MPL_URL+'/download-books-movies/';
   this.howto['donate'] = MPL_URL+'/get-involved/';
   this.howto['library_job'] = MPL_URL+'/library-employment/';
   this.howto['hours'] = MPL_URL+'/about/';
   this.howto['web_resources'] = MPL_URL+'/databases/';
   this.howto['volunteer'] = MPL_URL+'/get-involved/';
   this.howto['ask_away'] = 'http://www.askawayillinois.info/';

   this.goto_howto = function (form_id) {
      var where = $(form_id).how.value;

      if (where.length == 0) {
         return false;
      }

      document.location.href = this.howto[where];
      return false;
   };

   this.search_site = function (form_id) {
      return this.perform_search(form_id,
        this.site_search);
   };

   this.search_catalog = function (form_id) {
      return this.perform_search(form_id,
         this.catalog_keyword);
   };

   /* Search function */
   this.perform_search = function (form_id, base_url) {
      var sform = $(form_id);
      var term = escape(sform.s.value.replace(" ", "+"));

      document.location.href = base_url+term;

      return false;
   };
}
var Mahomet = new MyMahomet();
