
function is_numeric(value)
{
	return (typeof(value) == 'number');
}

function is_string(value)
{
	return (typeof(value) == 'string');
}

function is_object(value)
{
	return (typeof(value) == 'object');
}

function empty(value)
{
	var ret = false;
	if (typeof(value) == 'number' && (value == 0 || isNaN(value)))
	{
		ret = true;
	}
	if (typeof(value) == 'string' && value == '')
	{
		ret = true;
	}else if (typeof(value) == 'object' && value == null)
	{
		ret = true;
	}
	return ret;
}

function trim(strValue)
{
	if (is_string(strValue) && strValue != '')
	{
		var start = 0;
		var end = strValue.length;
		while (start < strValue.length && (strValue[start] == ' ' || strValue[start] == '\r' || strValue[start] == '\n' || strValue[start] == '\t')) start++;
		while (end > 0 && (strValue[end - 1] == ' ' || strValue[end - 1] == '\r' || strValue[end - 1] == '\n' || strValue[end - 1] == '\t')) end--;
		if (start < end)
		{
			return strValue.substring(start, end);
		}
	}
	return '';
}

function JInformeObject()
{
	this.id = '';

	this.bind = function ()
	{
		if (this.id == '')
		{
			if (typeof(window.InformeRegistry) != 'object' || window.InformeRegistry == null)
			{
				window.InformeRegistry = new Object();
			}

			do
			{
				this.id = 'iobj' + Math.floor(1000000 * Math.random());
			}while (typeof(window.InformeRegistry[this.id]) == 'object' && window.InformeRegistry[this.id] != null);
			window.InformeRegistry[this.id] = this;
		}
		return true;
	}

	this.unbind = function ()
	{
		if (this.id != '')
		{
			if (typeof(window.InformeRegistry[this.id]) == 'object' && window.InformeRegistry[this.id] != null)
			{
				window.InformeRegistry[this.id] = null;
			}
			this.id = '';
		}
		return true;
	}

	this.getRegsitryPath = function ()
	{
		if (this.id != '')
		{
			return 'window.InformeRegistry.' + this.id;
		}
		return '';
	}

	this.isBound = function ()
	{
		return this.id != '';
	}
}

function JInformeEvent()
{
	this.name = 'any';
	this.checkExp = new RegExp('^[a-zA-Z_][a-zA-Z0-9_]*$');
	this.workers = new Array();
	this.eventObject = null;

	this.addFunctionWorker = function (func)
	{
		if (typeof(func) == 'function' && func != null)
		{
		        var j=0;
			while(j<this.workers.length && this.workers[j] != func) j++;
			if (j>=this.workers.length)
			{
				this.workers[this.workers.length] = func;
			}
			return true;
		}
		return false;
	}

	this.addObjectWorker = function (theObject, theMethod)
	{
		if (typeof(theObject) == 'object' && theObject != null && typeof(theMethod) == 'string' && theMethod != null && this.checkExp.test(theMethod))
		{
		        var j=0;
			while(j<this.workers.length && (typeof(this.workers[j]) != 'object' || this.workers[j].theObject != theObject)) j++;
			if (j>=this.workers.length)
			{
			        j = this.workers.length;
				this.workers[j] = new Object();
				this.workers[j].theObject = theObject;
				this.workers[j].theMethod = theMethod;
			}
			return true;
		}
		return false;
	}

	this.callEvent = function (params)
	{
		for(var i=0;i<this.workers.length;i++)
		{
			if (typeof(this.workers[i]) == 'object')
			{
				if (typeof(this.workers[i].theObject[this.workers[i].theMethod]) == 'function')
				{
					this.workers[i].theObject[this.workers[i].theMethod](this, params);
				}
			}
			else if (typeof(this.workers[i]) == 'function')
			{
				this.workers[i](this, params);
			}
		}
	}
}

