/*
* DOMLoaded - Taken and adapted from Rob Cherry (http://www.cherny.com/webdev/27/domloaded-updated-again)
*
* To use: call DOMLoaded.load one or more times with functions, ie:
*
*    function something() {
*       // do something
*    }
*    DOMLoaded.load(something);
*
*    DOMLoaded.load(function() {
*        // dosomething else
*    });
*
*/

var DOMLoaded = {
	onload: [],
	loaded: function() {
		if (arguments.callee.done) {
			return;
		}
		arguments.callee.done = true;
		for (i = 0;i < DOMLoaded.onload.length;i++) {
			DOMLoaded.onload[i]();
		}
	},
	
	load: function(fireThis) {
		this.onload.push(fireThis);
		if (document.addEventListener) {
			document.addEventListener("DOMContentLoaded", DOMLoaded.loaded, null);
		} else if (/KHTML|WebKit/i.test(navigator.userAgent)) {
			var _timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					clearInterval(_timer);
					delete _timer;
					DOMLoaded.loaded();
				}
			}, 10);
		}
		/*@cc_on @*/
		/*@if (@_win32)
		var proto = "src='javascript:void(0)'";
		if (location.protocol == "https:") proto = "src=//0";
		document.write("<scr"+"ipt id=__ie_onload defer " + proto + "><\/scr"+"ipt>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
		    if (this.readyState == "complete") {
		        DOMLoaded.loaded();
		    }
		};
		/*@end @*/
	   window.onload = DOMLoaded.loaded;
	}
};
