3 * Copyright (c) 2007 Andrew Tetlaw
\r
5 * Permission is hereby granted, free of charge, to any person
\r
6 * obtaining a copy of this software and associated documentation
\r
7 * files (the "Software"), to deal in the Software without
\r
8 * restriction, including without limitation the rights to use, copy,
\r
9 * modify, merge, publish, distribute, sublicense, and/or sell copies
\r
10 * of the Software, and to permit persons to whom the Software is
\r
11 * furnished to do so, subject to the following conditions:
\r
13 * The above copyright notice and this permission notice shall be
\r
14 * included in all copies or substantial portions of the Software.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
\r
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
\r
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
\r
28 * http://tetlaw.id.au/view/javascript/fastinit
\r
30 * Version 1.4.1 (2007-03-15)
\r
32 * http://dean.edwards.name/weblog/2006/03/faster
\r
33 * http://dean.edwards.name/weblog/2006/06/again/
\r
35 * http://www.cherny.com/webdev/26/domloaded-object-literal-updated
\r
39 onload : function() {
\r
40 if (FastInit.done) { return; }
\r
41 FastInit.done = true;
\r
42 for(var x = 0, al = FastInit.f.length; x < al; x++) {
\r
46 addOnLoad : function() {
\r
48 for(var x = 0, al = a.length; x < al; x++) {
\r
49 if(typeof a[x] === 'function') {
\r
50 if (FastInit.done ) {
\r
53 FastInit.f.push(a[x]);
\r
58 listen : function() {
\r
59 if (/WebKit|khtml/i.test(navigator.userAgent)) {
\r
60 FastInit.timer = setInterval(function() {
\r
61 if (/loaded|complete/.test(document.readyState)) {
\r
62 clearInterval(FastInit.timer);
\r
63 delete FastInit.timer;
\r
66 } else if (document.addEventListener) {
\r
67 document.addEventListener('DOMContentLoaded', FastInit.onload, false);
\r
68 } else if(!FastInit.iew32) {
\r
69 if(window.addEventListener) {
\r
70 window.addEventListener('load', FastInit.onload, false);
\r
71 } else if (window.attachEvent) {
\r
72 return window.attachEvent('onload', FastInit.onload);
\r
76 f:[],done:false,timer:null,iew32:false
\r
80 FastInit.iew32 = true;
\r
81 document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
\r
82 document.getElementById('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { FastInit.onload(); }};
\r