// pns.js

// newFunction
function newFunction() {
}

// Function to allow one JavaScript file to be included by another.
// Copyright (C) 2006 www.cryer.co.uk
function inc2(jsFile)
{
  document.write('<script type="text/javascript" src="'
    + jsFile + '"></script>'); 
}
//inc2('js2.js');



function inc(filename)
{
	var body = document.getElementsByTagName('body').item(0);
	script = document.createElement('script');
	script.src = filename;
	script.type = 'text/javascript';
	body.appendChild(script);
}

//Defines the top level Class
function Class() { }
Class.prototype.construct = function() {};
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.$ = superClass;        
		proto[n] = item;    
	}    
	classDef.prototype = proto;        
	
	//Give this new class the same static extend method        
	classDef.extend = this.extend;            
	return classDef;
};

// Working Example
//Hey, this class definition approach
//looks much cleaner than then others.
var BaseClass = Class.extend({    
	construct: function() { /* optional constructor method */ },            
	
	getName: function() {        
		return "BaseClass(" + this.getId() + ")";    
	}, 
	       
	getId: function() {        
		return 1;    
	}
});
var SubClass = BaseClass.extend({    
	getName: function() {        
		//Calls the getName() method of BaseClass        
		return "SubClass(" + this.getId() + ") extends " +            
			arguments.callee.$.getName.call(this);    
	},        
	getId: function() {        
		return 2;    
	}
});
var TopClass = SubClass.extend({    
	getName: function() {        
		//Calls the getName() method of SubClass        
		return "TopClass(" + this.getId() + ") extends " +            
			arguments.callee.$.getName.call(this);    
	},        
	getId: function() {        
		//Just like the last example, this.getId()        
		//always returns the proper value of 2.                
		return arguments.callee.$.getId.call(this);    
	}
});
//Alerts "TopClass(2) extends SubClass(2) extends BaseClass(2)"
//Looks good again, and there's no intermediate functions!
//alert(new TopClass().getName());