Betting functionality added.  Refactored code based on solution to make javascript easier to manage