/* ********************************************************************* *
 * FILE: util.js                                                         *
 * PROJ: Personal web site at Cornell University                         *
 * DESC: Javascript utilities                                            *
 * AUTH: weigel                                                          *
 * VERS: $Id: util.js 3 2008-05-04 08:55:58Z felix $                     *
 * COPY: Copyright Cornell University 2008                               *
 * ********************************************************************* */
 
/**
 * Removes the first occurrence of the given object from the given array. 
 **/

function removeFromArray(array, item) {

  var i;
  var member;

  for (i = 0; i < array.length; i++) {
    member = array[i];
    if (member == item) {
      array.splice(i, 1);
      break;
    }
  }
  return array;

}


/**
 * Returns the given string, with leading and trailing whitespace removed. 
 **/

function trim(string) {

  return string.replace(/^\s*/, "").replace(/\s*$/, "");

}
