// addEvent and removeEvent
// cross-browser event handling for IE5+,	NS6 and Mozilla
// By Scott Andrew
function addEvent(elm, evType, fn, useCapture)
{
	if (elm.addEventListener)
	{
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} 
	else if (elm.attachEvent)
	{
		var r = elm.attachEvent("on"+evType, fn);
		return r;
	}
}

function addEventById(Id, evType, fn, useCapture)
{
	addEvent(document.getElementById(Id), evType, fn, useCapture);
}

if (!Function.prototype.apply)
{
	Function.prototype.apply = function(oScope, args)
	{
		var sarg = [];
		var rtrn, call;

		if (!oScope)
			oScope = window;
		if (!args)
			args = [];

		for (var i = 0; i < args.length; i++)
			sarg[i] = "args["+i+"]";

		call = "oScope.__applyTemp__(" + sarg.join(",") + ");";

		oScope.__applyTemp__ = this;
		rtrn = eval(call);

		try {
			delete oScope.__applyTemp__;
		}
		catch(ex){}

		return rtrn;
	}
}

function bindParameter(_func, _params)
{
	return function()
	{
		_func.apply(this, _params)
	};
}