Adding functionality with JavaScript