From http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript