Refactored javascript and added settings object to allow greater customization