function TrimLeft( strInput)
{
  var l = strInput.length, i = 0;
  if( strInput.indexOf( ' ', 0) == 0)
    while( ( i < l) && ( strInput.charAt( i) == ' '))
      i++;
  return strInput.substring( i, l);
}

function TrimRight( strInput)
{
  var l = strInput.length, i = l - 1;
  if( strInput.lastIndexOf( ' ') == i)
    while( ( i > 0) && ( strInput.charAt( i) == ' '))
      i--;
  return strInput.substring( 0, i + 1);
}

function Trim( strInput)
{
  return TrimRight( TrimLeft( strInput));
}

function Check( Obj)
{
  var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
  var bResult = true;
  var i = 0;
  var doFormCheck = eval( 'Obj.' + Obj.bDoCheck + '.value');
  if( doFormCheck == 1)
    while( ( i < Obj.elements.length) && bResult)
    {
      var e = Obj.elements[ i++];
      if( ( e.type == 'text') || ( e.type == 'password') || ( e.type == 'textarea'))
      {
        if( e.doChech != null)
        {
          if( e.doChech == 'IsFilled')
            bResult = ( Trim( e.value) != '');
          else if( e.doChech == 'IsNumeric')
            bResult = ( ( Trim( e.value) != '') && !isNaN( e.value));
          else if( e.doChech == 'CheckLen')
            bResult = ( e.value.length >= e.minLen);
          else if( e.doChech == 'reEnter')
            bResult = ( e.value == eval( 'Obj.' + e.MasterInput + '.value'));
          else if( e.doChech == 'IsEmail')
            bResult = ( e.value.match( emailPat) != null);
          else
            bResult = eval( e.doChech + '( \'' + e.value + '\');');
          if( !bResult)
          {
            alert( e.ErrorMsg);
            e.focus();
            e.select();
          }
        }/* if( e.doChech != null) */
      }/* if( e.type...) */
    }/* while( ...) */
  return bResult;
}/* function */
