document.onreadystatechange for init