function checkInput( motiv, line )
{
  var entry = document.getElementById('m_' + motiv + '_line_' + line );
  var le = entry.value.length;
  var newtext = '';
  var width = 0;
  var ascii, c2, c2 ;
  var typeWidth = typeWidthL[motiv][line-1];

  for (iChar = 0; iChar < le; iChar++)
  {
    ascii = entry.value.charCodeAt(iChar);
    if (typeWidth[ascii] > 0)
    {
      width += typeWidth[ascii]*Kerning[motiv][line-1];
      if (iChar < le - 1)
      {
        width += charSpaceL[motiv][line-1];
      }
      if (width <= maxWidthL[motiv][line-1])
      {
        newtext = newtext + String.fromCharCode(ascii);
      }
      else
      {
        width -= typeWidth[ascii];
        if (iChar < le - 1)
        {
          width -= charSpaceL[motiv][line-1];
        }
      }
    }
    else
    {
      var substCnt = substL[ascii].length;
      if (substCnt > 0)
      {
        for (c = 0; c < substCnt; c++)
        {
          var substitute = substL[ascii][c];
          var le = substitute.length;
          var f = 1;

          for (c2 = 0; c2 < le; c2++)
          {
            if (typeWidth[substitute.charCodeAt(c2)] == 0) { f = 0; }
          }
          if (f == 1)
          {
            for (c2 = 0; c2 < le; c2++)
            {
              ascii = substitute.charCodeAt(c2);
              width += typeWidth[ascii];
              if (iChar < le - 1)
              {
                width += charSpaceL[motiv][line-1];
              }
              if (width <= maxWidthL[motiv][line-1])
              {
                newtext = newtext + String.fromCharCode(ascii);
              }
              else
              {
                width -= typeWidth[ascii];
                if (iChar < le - 1)
                {
                  width -= charSpaceL[motiv][line-1];
                }
              }
            }
            break;
          }
        }
      }
    }
  }
  entry.value = newtext;
}