since it seems to work as I want that means that goal achieved :D

as to why is because it replaces only the first occurrence... on how to replace more: http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript