// nsb_class.js
// (c) 2008 - noisybear.com
//

var Class = {
	
	Create: function() {
		// Déclaration des variables
		var parent = null,
		properties = Noisybear.$A(arguments);
		if (Noisybear.isFunction(properties[0])) parent = properties.shift();
		
		function klass() { this.initialize.apply(this, arguments); }
		
		Noisybear.extend(klass, Class.Methods);
		klass.superclass = parent;
		klass.subclasses = [];
		
		if (parent) {
		  var subclass = function() { };
		  subclass.prototype = parent.prototype;
		  klass.prototype = new subclass;
		  parent.subclasses.push(klass);
		}
		
		for (var i = 0; i < properties.length; i++) klass.addMethods(properties[i]);
		
		if (!klass.prototype.initialize) klass.prototype.initialize = Noisybear.emptyFunction;
		
		klass.prototype.constructor = klass;

    	return klass;
	}
}

Class.Methods = {
	addMethods: function(source) {
		var ancestor   = this.superclass && this.superclass.prototype;
		var properties = Noisybear.keys(source);
	
		if (!Noisybear.keys({ toString: true }).length) properties.push("toString", "valueOf");
	
		for (var i = 0, length = properties.length; i < length; i++) {
		  var property = properties[i], value = source[property];
		  if (ancestor && Noisybear.isFunction(value) && value.argumentNames().first() == "$super") {
			var method = value, value = Noisybear.extend((function(m) {
			  return function() { return ancestor[m].apply(this, arguments) };
			})(property).wrap(method), {
			  valueOf:  function() { return method },
			  toString: function() { return method.toString() }
			});
		  }
		  this.prototype[property] = value;
		}
	
		return this;
	  }
}

var ProgressBar = {
	
}

var Comments = {
	
}

var Radio = {
	
}

var Player = {
	
}