
function ObjectRegistry()
{
	this.objects = new Array();

	this.add = function (object)
	{
		this.objects[this.objects.length] = object;
	}
	
	this.get = function(index)
	{
		return this.objects[index];
	}
	
	this.count = function()
	{
		return this.objects.length;
	}

	this.remove = function(index)
	{
		return this.objects.splice(index,1);
	}
	
	this.clear = function(index)
	{
		this.objects.length = 0;
	}
		
	this.forEach = function(func,p1,p2)
	{
		for (i=0;i<this.objects.length;i++)
		{
			func(this.objects[i],p1,p2);
		}
	}
	
    this.findWithElementId = function(elementId)
    {
        for (i=0;i<this.objects.length;i++)
        {
            iterId = this.objects[i].type + '_' + this.objects[i].id;
            if (iterId == elementId)
            {
                return i;
            }
        }
        
        return -1;
    }
        
	this.findWithId = function(type,id)
	{
		for (i=0;i<this.objects.length;i++)
		{
			if (this.objects[i].id == id &&
				this.objects[i].type == type)
			{
                return i;
			}
		}
		
		return -1;
	}
	
	ObjectRegistry.prototype.add = this.add;
	ObjectRegistry.prototype.get = this.get;
	ObjectRegistry.prototype.remove = this.remove;
	ObjectRegistry.prototype.count = this.count;
	ObjectRegistry.prototype.clear = this.clear;
	ObjectRegistry.prototype.forEach = this.forEach;	
}	
