/**
 * Extend a class with another class for more elegant subclassing & polymorphism 
 * @function
 * @param {Function} subClass reference to class function that will be inherit superclass.
 * @param {Function} baseClass reference to class function that will be inherited.
 */
var OopExtend = function(subClass, baseClass) {
	function inheritance() {
	}
	inheritance.prototype = baseClass.prototype;
	subClass.prototype = new inheritance();
	subClass.prototype.constructor = subClass;
	subClass.baseConstructor = baseClass;
	subClass.superClass = baseClass.prototype;
};


/**
 * Observable - streamlined observable pattern - makes implementors observable by multiple, anonymous observers.  
 * Observers must implement a "broadcast" method to receive updates.
 * @class Extend this class to make a target class "observable"
 */
function Observable() {
	this.observers = [];
};

/**
 * Add a particular observer
 * @public
 * @param {Object} obj
 */
Observable.prototype.addObserver = function(obj) {
	if (!this.observers)
		this.observers = [];
	if ($.inArray(obj, this.observers) == -1) 
		this.observers.push(obj);
};

/**
 * Remove a particular observer
 * @param {Object} obj
 */
Observable.prototype.removeObserver = function(obj) {
	var n = $.inArray(obj, this.observers);
	if (n > -1) this.observers.splice(n, 1);
};

/**
 * Broadcasts an event to all observers
 * @private
 * @param {Object} [eventStr]
 */
Observable.prototype.broadcast = function(eventStr) {
	$.each(this.observers, function() {
		this.broadcast(eventStr);
	});
};

/**
 * Override in subclasses to return appropriate state from observers
 */
Observable.prototype.getState = function() {
};
