Javascript Event Queue