/**
 * jsFx Framework :: Class() 
 *
 * Part of the jsFX Javascript Framework
 *  
 * 
 *
 * Warning !! Do not modify this file , Defines the top level Class 
 * 
 *
 * @version 1.00.01
 * @author Sal Bordonaro, designertechnology.com.au
 *
 *
 */

 
/**
 *
 * Define Class() as a function
 *
 */
function Class() { }

/**
 * 
 *
 *
 */
Class.prototype.construct = function() {};


/**
 *
 * Attatch anonymous function
 *
 */
Class.__asMethod__ = function(func, superClass) {    
	return function() {
		var currentSuperClass = this.$;
		this.$ = superClass;
		var ret = func.apply(this, arguments);        
		this.$ = currentSuperClass;
		return ret;
	};
}; 


/**
 * Allow for extention to the class (ie object inheritance)
 *
 *
 */
Class.extend = function(def) {

    var classDef = function() {
        if (arguments[0] !== Class) { this.construct.apply(this, arguments); }
    };
    
    var proto = new this(Class);
    var superClass = this.prototype;
    
    for (var n in def) {
        var item = def[n];                        
        
        if (item instanceof Function) {
            item = Class.__asMethod__(item, superClass);
        }
        
        proto[n] = item;
    }

    proto.$ = superClass;
    classDef.prototype = proto;
    
    //Give this new class the same static extend method    
    classDef.extend = this.extend;        
    return classDef;
}; 


