Not exactly sure what your full translator is trying to do but to get the original mapping you only have to add an 'a' to the first regex.
$(document).ready(function(){
$("#ta_1").keyup(function(event) {
var text2 = $(this).val();
text2 = text2.replace(/al/g, "aL");
text2 = text2.replace(/([^L]|^)am/g, '$1m');
text2 = text2.replace(/\bLam\b/g, "Lm");
$("#ta_1").val(text2);
});
});