http://www.sitepoint.com/javascript-custom-events/