function require(script_path){
     var scripts = document.getElementsByTagName('script');
     for(var i=0; i<scripts.length; i++){
        if(scripts[i].getAttribute('src') == script_path){
            return;
        }
     }
     var head = document.getElementsByTagName('head').item(0);
     var script = document.createElement('script');
     script.setAttribute('src',script_path);
     script.setAttribute('type','text/javascript');
     for(var i=0; i<scripts.length; i++){
        if(scripts[i].getAttribute('src') == this_script){
            break;
        }
     }
     script = head.insertBefore(script,scripts[i]);
     head.insertBefore(document.createTextNode("\r\n"),script.nextSibling);
     eval(script.innerHTML);
}
/******************************************************************/
//http://www.cherny.com/demos/onload/domloaded.js
/*
    DomLoaded.load(testIt);
	DomLoaded.load(function() {
	    alert('foo');
	});
*/
var DomLoaded ={
	onload: [],
	loaded: function(){
		if (arguments.callee.done) return;
		arguments.callee.done = true;
		for (i = 0;i < DomLoaded.onload.length;i++){
            if(typeof(DomLoaded.onload[i])=='function') DomLoaded.onload[i]();
        }
	},
	load: function(fireThis){
		this.onload.push(fireThis);
		if (document.addEventListener)
			document.addEventListener("DOMContentLoaded", DomLoaded.loaded, null);
		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)
        if(!document.getElementById("__ie_onload")){
		    var proto = "javascript:void(0)";
		    if (location.protocol == "https:") proto = "//0";
		    document.write("<scr"+"ipt id=__ie_onload defer src=" + proto + "><\/scr"+"ipt>");
		    var script = document.getElementById("__ie_onload");
		    script.onreadystatechange = function() {
		        if (this.readyState == "complete") {
		            DomLoaded.loaded();
		        }
		    };
        }
		/*@end @*/
	   window.onload = DomLoaded.loaded;
	}
};
