update document.attachEvent for IE8 compatibility