var onloadManager = {    debug: true,    domQueue: [],    pageQueue: [],    init: function() {        if (window.attachEvent) {  // IE            window.attachEvent("onload", function() {                     onloadManager.runQueue("dom");                     onloadManager.runQueue("page");                     });            // dom is handled by script call - maybe document.write it here?            // nope! big sike on that one.            /*document.write("<!--[if IE]>\n" +                    "   <script type=\"text/javascript\" defer=\"defer\">\n" +                    "       onloadManager.runQueue(\"dom\");\n" +                    "   </script>" +                    "<![endif]-->");*/                        } else if (window.addEventListener) {  // FX and others            if (document.addEventListener) {  // FX only                document.addEventListener("DOMContentLoaded", function() {                        onloadManager.runQueue("dom"); }, false);            } else {                window.addEventListener("load", function() {                        onloadManager.runQueue("dom"); }, false);            }            window.addEventListener("load", function() {                    onloadManager.runQueue("page"); }, false);        } else if (document.addEventListener) {            // second crappiest way - for opera - doesnt have real dom level            document.addEventListener("load", function() {                    onloadManager.runQueue("dom");                    onloadManager.runQueue("page"); }, false);        } else {            // the super crappiest.  just set onload            if (window.onload) this.pageQueue.push(window.onload);            window.onload = function() {                onloadManager.runQueue("dom");                onloadManager.runQueue("page");            }        }    },    runQueue: function(queueName) {        var queue = this[queueName + "Queue"];        var func;        while (func = queue.shift()) {            if (typeof(func) == "string") eval(func);            else func();        }    },    addOnload: function(func, type) {        this[type + "Queue"].push(func);    }}onloadManager.init();
