Javascript method to allow the text direction the be changed on the fly based on language