added ready function, replaced event attributes with delegated event handlers