/**
 * @author Chris Lambe
 */
var Registry = {
	_debug:false,
	_components: new Object(),
	_registry: new Array(),
	init: function() {
		$.extend({
			scope: function(fn, scope) {
				return function() {
					return fn.apply(scope, arguments);
				}
			}
		});
		$(Registry._registry).each(function(){
			if (Registry.getComponent(this)) {
				Registry.getComponent(this).init();
			} else {
				//if(console && Registry._debug) console.warn(this + " hasn't been registered!");
			}
		});
	},
	add: function(component) {
		if (component.NAME) {
			Registry._components[component.NAME] = component;
			Registry._registry.push(component.NAME);
		} else {
			//if(console && Registry._debug) console.warn("A component is missing the _name variable!");
		}
	},
	getComponent:function(componentName) {
		if(Registry._components[componentName])
			return Registry._components[componentName];
		return false;
	}
}