﻿/** Common javascript for my library
*   Common utilities and main namespace
*   @author: James Diacono
*   @date: 29th of April, 2010
*/

/** Namespace: jdiacono
*  Contains: My javascript library
*/
if (typeof jdiacono === 'undefined') {
	var jdiacono = {};
}

/** Method: The Douglas Crockford prototypal inheritance for the Object function
*   Reference: http://javascript.crockford.com/prototypal.html
*   Usage: newObject = Object.create(oldObject);
*/
if (typeof Object.create !== 'function') {
	Object.create = function (o) {
		function F() { }
		F.prototype = o;
		return new F();
	};
}

/** Method:  Adds a method to a function's prototype
*   Reference: "Javascript: The Good Parts" by Douglas Crockford.  Chapter 5.
*   Usage:  If 'thang' is a function and 'doIt' is a method we want to apply,
*           call thang.method('doIt', doIt).  All function which inherit from
*           thang.prototype now have access to the 'doIt' method.
*/
Function.prototype.method = function (name, func) {
	if (!this.prototype[name]) {
		this.prototype[name] = func;
		return this;
	}
};

