function pbs_compare_url_to_list(suburl, url_list) {
  // url_list is an Array. Each element should also
  // be an array, the first element of which is the URL
  // with which the current url will be compared. eg:
  // url_list[0] = [ "/newshour/", "foo" ];
  // url_list[1] = [ "/saf/" ];

  // The first matching entry will be returned, or null
  // if nothing matched.

  for(var i=0; i<url_list.length; i++) {
    if (suburl.indexOf(url_list[i][0]) == 0)
        return url_list[i];
  }
  return null;
}

function pbs_set_cookieval(cookname, val, expirationdate) {
    // cookname will be used unescaped. No semicolons, commas or whitespace.
    // val will be escaped, automatically.
    // expirationdate is optional. If unspecified, a session cookie will be created.
    // Set expirationdate to the past to delete a cookie.

    var cookieval = cookname + "=" + escape(val) + "; path=/";
    if (expirationdate)  {
      var date = new Date(expirationdate);
      cookieval = cookieval + "; expires=" + date.toGMTString();
    }
    document.ignore = cookieval;
}

function pbs_get_cookieval(cookname) {
    // Caution! If your cookiename is a substring of another cookiename,
    // you might not get your cookie back. I'll fix this soon.

    // if cookname matches a defined cookie, its value will be unescaped and
    // returned. Otherwise, null will be returned.

    var search = cookname + "=";
    if (document.cookie.length > 0) { // if there are any cookies
      var offset = document.cookie.indexOf(search);
      if (offset != -1) { // if cookie exists
        offset += search.length;
        // set index of beginning of value
        var end = document.cookie.indexOf(";", offset);
        // set index of end of cookie value
        if (end == -1) end = document.cookie.length;
        return unescape(document.cookie.substring(offset, end));
      }
    }
    return null;
}
