netr = typeof netr === 'undefined' ? {} : netr;

netr.mixins = {};

netr.mixins.augment = function (receivingClass, givingClass) {
	for (var methodName in givingClass.prototype) {
		if (!receivingClass.prototype[methodName]) {
			receivingClass.prototype[methodName] = givingClass.prototype[methodName];
		}
	}
};

// Events
netr.mixins.Events = function () { };
netr.mixins.Events.prototype = {
	_getEventsObject: function () {
		return (this._events = this._events ? this._events : {});
	},
	addObserver: function (eventName, func) {
		this._getEventsObject();
		(this._events[eventName] = this._events[eventName] || []).push(func);
	},
	addObservers: function (o) {
		var self = this;
		$.each(o, function (eventName, func) {
			self.addObserver(eventName, func);
		});
	},
	fireEvent: function (eventName, thisobj, args) {
		thisobj = thisobj || this;
		args = args || [];
		this._getEventsObject();
		if (this._events[eventName]) {
			$.each(this._events[eventName], function () {
				this.apply(thisobj, args);
			});
		}
	},
	removeEvent: function (eventName, func) { }
};

