  /* scrolls to the category identified by either an anchor: loc#1.2.3 or a
   "cat" param, eg loc?cat=1.2.3. using # is because otherwise we append a
   redundant-looking anchor, eg loc#1.2.3?cat=1.2.3
  */
  function findCat() {
    var cat = null;
    if (!document.location.search) {
      var url = document.location.toString();
      /* see if we can find a category of the form location#1.1.1 */
      if (url.indexOf('#') > -1) {
        anchor = url.substring(url.indexOf('#')+1);
        if (anchor.match('^[0-9]+(\.[0-9])*')) {
          return anchor;
        }
      }
    } else {
      /* use the search */
      var query = location.search.substring(1);
      var pairs = query.split('&');
      for (var p in pairs) {
        if (typeof pairs[p] != 'string') {
          /* skip vars of type 'function' that are added via Prototype */
          continue;
        }
        var attrName = pairs[p].split('=');
        if ('cat' == attrName[0]) {
          return attrName[1];
        }
      }
    }
  }