<!--
/*
checks if string is empty
*/
function isEmpty(s)
{
  return ((s==null)||(s.length==0)) ? true : false;
}

function isNumber(val)
{
  val = trimSpaces(val);

  for (var i=0; i<val.length; i++)
  {
    var digit = val.charAt(i);
    if (digit<"0" || digit>"9")
    {
      return false;
    }
  }

  return true;
}

/*
trims spaces from both ends of string using methods consistent across browsers
*/
function trimSpaces(x)
{
  // leading spaces
  while (x.charAt(0) == ' ')
  {
    x = x.substring(1);
  }

  // trailing spaces
  while (x.charAt(x.length - 1) == ' ')
  {
    x = x.substring(0, x.length - 1);
  }

  return x;
}

/*
pads # of spaces (=length) in front of string
*/
function rightJustify(val,length)
{
  var str = "" + val;

  while (str.length < length)
  {
    str = " " + str;
  }

  return str;
}

/*
selects text field in form (assumes form field ref is passed)
*/
function selectText(tf)
{
  tf.value = trimSpaces(tf.value);
  tf.focus();
  tf.select();
}
//-->