/**
 * returns string with all leading and trailing characters
 * eliminated.
 */
function trim(str){
  var s = new String(str);
  //trailing spaces
  while (s.length>0 && isSpaceCharacter(""+s.charAt(s.length-1))){
    s = s.substring(0,s.length-1);
  }
  //leading spaces
  while (s.length>0 && isSpaceCharacter(""+s.charAt(0))){
    s = s.substring(1);
  }
  return s
}

var spaces = " \t\r\n"+String.fromCharCode(160);

function isSpaceCharacter(ch){
  return spaces.indexOf(ch) >-1;
}

function isEmpty(elem){
  return trim(elem.value).length==0;
}

function isEmptyText(text) {
  return trim(text).length==0;
}

function emptyIfNull(s) {
  if (s == 'null') {
    s = "";
  }
  return s;
}

function isNotNumeral(text){
    var symbCode;
    for(var i = 0; i<text.length; i++){
        symbCode = text.charCodeAt(i);
        if( ((symbCode<48) | (symbCode>58)) & (symbCode!=46)  ){
            return true;
        }
    }
    return false;
}
