if(typeof MLUtil == 'undefined')
	MLUtil = {};
if(typeof MLUtil.Observe == 'undefined')
	MLUtil.Observe = {};
	
MLUtil.Observe.Info = function(avStrEventId, avStrEventType, avObjEventFunc) {	
	this.strEventId = avStrEventId;
	this.strEventType = avStrEventType;
	this.objEventFunc = avObjEventFunc;
}

MLUtil.Observe.Handle = function() {	
	this.nEventCount = 0;
	this.arrEventList = new Array();
	
	this.getList = function() {
		return arrEventList;
	}
	
	this.size = function() {
		return arrEventList.length;
	}
	
	this.get = function(avStrEventId) {
		this.arrEventList.each(function(avObj) {
			if (avStrEventId == avObj.strEventId)
				return avObj;
		});
	}
	
	this.addObj = function(avEventObj) {
		this.add(avEventObj.strEventId, avEventObj.strEventType, avEventObj.objEventFunc);
	}
	
	this.add = function(avStrEventId, avStrEventType, avObjEventFunc) {
		var objInfo = new MLUtil.Observe.Info(avStrEventId, avStrEventType, avObjEventFunc);
		
		Event.observe(objInfo.strEventId, objInfo.strEventType, objInfo.objEventFunc ); 
		this.arrEventList.push(objInfo);
	}

	this.toString = function() {
		var strBuff = "{";
		this.arrEventList.each(function(avObj) {
			strBuff = strBuff + "{strEventId: '" + avObj.strEventId + "', strEventType: '" + avObj.strEventType + "', objEventFunc: '" + avObj.objEventFunc + "},";
		});
		strBuff = strBuff + "}";
		
		return strBuff;
	}
	
	this.incEventCount = function() {
		this.nEventCount++;
	}
	
	this.decEventCount = function() {
		this.nEventCount--;
	}
}

MLUtil.Observe.AttachOnload = function(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

MLUtil.Observe.AttachEvent = function(strEventName, objFunctionName) {
	var oldunonload = eval("window." + strEventName);
	
	if (typeof eval("window." + strEventName) != 'function') {
		eval("window." + strEventName + " = " + objFunctionName);
	} else {
		objFunc = eval("window." + strEventName);
		eval("window." + strEventName + " = function() { oldunonload(); objFunctionName(); }");
	}
}