some refactoring to simplify jquery method and make applyMask signature clearer. Now the smaller mask functions (derived form addChar) are always private.