Variable Javascript String Functions Replace Lost