
var loadEvent = {
	fnList : [],
	timer : null,
	domLoadElementId : "dom-load",
	add : function(fn)
	{
		loadEvent.fnList.push(fn)
		if(loadEvent.domLoaded == undefined)
		{
			loadEvent.domLoaded=false;
			loadEvent.domLoad();
			window.onload = function()
			{
				if(document.getElementById(loadEvent.domLoadElementId) == undefined)
				{
					window.defaultStatus = "Error: domLoadElementId[\""+loadEvent.domLoadElementId+"\"] is not embeded.";
				}
			}
		}
	},
	domLoad : function()
	{
		loadEvent.timer = setInterval(function() { // doesnt work in IE/Mac
		if((document.getElementsByTagName("body")[0] != null || document.body != null) && document.getElementById(loadEvent.domLoadElementId)) {
			loadEvent.runFnList();
			clearInterval(loadEvent.timer);
		}
		}, 250);
		if (typeof document.addEventListener != "undefined") {
			document.addEventListener("DOMContentLoaded", function() { loadEvent.runFnList(); clearInterval(loadEvent.timer); } , null); // Mozilla only
		}
	},
	runFnList : function()
	{
		if(loadEvent.domLoaded) return // for Mozilla, only execute once
		loadEvent.domLoaded = true; 
		for(var i=0,fn;fn=loadEvent.fnList[i];i++)
		{
			fn();
		}
	}
	
	
}


function hasClassName(elm,className)
{
	var re = RegExp("(^|\\s)"+className+"(\\s|$)");
	return re.test(elm.className);
}
