/** filterInput
  * applies the given filter function to the entered character
  * call with <tt>onkeypress="return filterInput(event);"</tt>
  * @param filterFunction the function that is applied
  * @param event (Optional)
  * @return
  */
function filterInput(event, filterFunction) {
  var keyCode, c;
  // Get the Key Code of the Key pressed if possible else - allow
  if(window.event) {
    keyCode = window.event.keyCode;
    event = window.event;
  } else if (event) {
    keyCode = event.which;
  }
  else {
    return true;
  }
  // If the Key Pressed is a CTRL key like Esc, Enter etc - allow
  if ( (keyCode==null) || (keyCode==0) || (keyCode==8) || (keyCode==9) || (keyCode==13) || (keyCode==27) ) {
    return true;
  }
  // Get the Pressed Character
  c = String.fromCharCode(keyCode);
  return filterFunction(c);
}

/** writeUppercase
  * write the uppercase of the given character (or string) to 
  * the given field
  * @param fieldid the id of the field to which the string must be written
  * @param s the character or string that is converted to uppercase and added to the field
  * @return false
  */
function writeUpperCase(fieldid, s) {
  var f = document.getElementById(fieldid);
  if (f) {
    f.value = f.value + s.toUpperCase();
  }
  return false;
}
