/**
 *	A Class implementation for simply class creation with multiple inheritance
 *	@author:	<g.tavonius@gmail.com>
 *	@version:	1.0
 */
 

if(typeof Class == "undefined")
	var Class = {
		create: function() {
			var t = function() {if(this.initialize) this.initialize.apply(this, arguments);};
			t.prototype.super = function() {
				if(typeof this._super != "undefined")
					this._super.initialize.apply(this, arguments);
			};
			t.extend = function() {
				for(var i = 0; i < arguments.length; ++i) {
					if(typeof arguments[i] == "function")
						arguments[i] = new arguments[i]();
					for (var property in arguments[i]) {
						if(!t.prototype[property])
							t.prototype[property] = arguments[i][property];
					}
					if(typeof t._super == "undefined")
						t.prototype._super = arguments[i];
				}
			};
			t.extend.apply(t, arguments);
			return t;
		}
	};


var ParentClass = new Class.create({
	initialize: function(fooval) {this.foo = fooval;}
,	foo: "barent"
,	setFoo: function(val) { this.foo = val; }
});

var SubClass = new Class.create({
	initialize: function() {this.super("barent");}
,	foo2: "barcelona"
}, ParentClass);


$(document).ready(function() {

	var p = new ParentClass("bla");
	var mc = new SubClass();
	var mc2 = new SubClass();
	assert("mc.foo2", mc.foo2, "barcelona");
	assert("mc.foo -> "+mc.foo, mc.foo, "barent");
	if(typeof mc._super != "undefined")
		out("mc._super.foo: "+mc._super.foo);
	mc2.setFoo("kong-foo");
	assert("mc2.foo2 -> "+mc2.foo2, mc2.foo2, "barcelona");
	assert("mc2.foo -> "+mc2.foo, mc2.foo, "kong-foo");
	
	assert("p.Foo: "+p.foo, p.foo, "bla");
});


