(function() {
  $(function() {
    var doSearch, nextTerm, searchInProgress, titlesBeenHidden;
    nextTerm = "";
    searchInProgress = false;
    titlesBeenHidden = false;
    doSearch = function() {
      var term, url;
      if (searchInProgress) {
        ;
      } else if (nextTerm.length === 0) {
        ;
      } else {
        term = nextTerm;
        nextTerm = "";
        url = "/search/?term=" + encodeURIComponent(term);
        searchInProgress = true;
        $("#search").addClass('loading');
        return $("#result-container").load(url, function() {
          searchInProgress = false;
          $("#search").removeClass('loading');
          if (!titlesBeenHidden) {
            $(".title").hide('fast');
            titlesBeenHidden = true;
          }
          return doSearch();
        });
      }
    };
    return $("#search").keyup(function(e) {
      var key;
      key = e.which;
      nextTerm = $(this).val();
      return doSearch();
    });
  });
}).call(this);

