/*****************************************
  general.js
  
  general.js is linked to by every page.
*****************************************/
    
  /**
    function addEventHandler
  */
  function addEventHandler (obj, eventType, functionName, useCapture)
  {
      if (document.getElementById) {
          if (typeof (obj) != "object")
            obj = document.getElementById (obj);
          if (obj.addEventListener)
            // Standards-based browsers.
            return obj.addEventListener (eventType, functionName, useCapture);
          else
            if (obj.attachEvent)
              // IE.
              return obj.attachEvent ("on"+eventType, functionName);
      }
    return;
  }
  
  /**
    function removeEventHandler
  */
  function removeEventHandler (obj, eventType, functionName, useCapture)
  {
      if (document.getElementById)  {
          if (typeof (obj) != "object")
           obj = document.getElementById (obj);
          if (obj.removeEventListener)
            // Standards-based browsers.
            return obj.removeEventListener (eventType, functionName, useCapture);
          else
              if (obj.detachEvent)
                // IE.
                return obj.detachEvent ("on"+eventType, functionName);
      }
    return;
  }

  /**
    function isEmpty ()
    
    Checks if string is empty. Returns true if:
      a) str is null.
      b) str is "".
      c) str contains nothing but spaces.
    Returns false otherwise.
  */
  function isEmpty (str)
  {
    str = trimString (str);
      if (str.length == 0)
        return true;
    return false;
  } // end funtion isEmpty ()

  /**
    function popUpWindow ()
    
    Creates a pop up window.
  */  
  function popUpWindow (e)
  {
  var location = this.href;  
    if (location === undefined)
      // I can't get IE to retrieve the link's href. There will 
      // be no pop up for IE.
      return true;
  var newWin = window.open (location, "popUp");
  newWin.focus ();  
    if (e.preventDefault)
      e.preventDefault ();
  return false;
  } // end function popUpWindow ()

  function trimString (str)
  {
    str = str.replace ( /^\s+/g, "" );// strip leading
    return str.replace ( /\s+$/g, "" );// strip trailing
  } // end function trimString ()
