// Catch cases where $(document).ready() is called after the browser event has already occurred.// we once tried to use readyState "interactive" here, but it caused issues like the one// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15if(document.readyState==="complete"){// Handle it asynchronously to allow scripts the opportunity to delay readysetTimeout(jQuery.ready);// Standards-based browsers support DOMContentLoaded}elseif(document.addEventListener){// Use the handy event callbackdocument.addEventListener("DOMContentLoaded",completed,false);// A fallback to window.onload, that will always workwindow.addEventListener("load",completed,false);// If IE event model is used}else{// Ensure firing before onload, maybe late but safe also for iframesdocument.attachEvent("onreadystatechange",completed);// A fallback to window.onload, that will always workwindow.attachEvent("onload",completed);// If IE and not a frame// continually check to see if the document is readyvartop=false;......