From http://james.padolsey.com/javascript/jquery-eventemitter/