//document.write("<script type='text/javascript' src='../Browser.js'></script>");

// Inheritance
Type.prototype = new Object();
Type.prototype.constructor = Type;
Type.prototype.baseClass = Object.prototype.constructor;

// Constructor
function Type(obj)
{
	this._object = obj;
};

// Public Methods
Type.prototype =
{
	isUndefined: function()
	{
		return typeof (this._object) == "undefined";
	},
	
	isNull: function()
	{
		return typeof (this._object) == "object" && !this._object;
	},
	
	isFunction: function()
	{
		return typeof (this._object) == "function";
	},
	
	isObject: function()
	{
		return typeof (this._object) == "object";
	},
	
	isArray: function()
	{
		return this.isObject() && (this._object instanceof Array);
	},

	isBoolean: function()
	{
		return typeof (this._object) == "boolean";
	},

	isNumber: function()
	{
		return typeof (this._object) == "number" && isFinite(this._object);
	},

	isString: function()
	{
		return this.isObject() && (this._object instanceof String);
	},
	
	toString: function()
	{
		if (this.isString())
			return "ThreeFifteen.String";
		else if (this.isArray())
			return "ThreeFifteen.Array";
		else if (this.isNumber())
			return "ThreeFifteen.Number";
		else if (this.isBoolean())
			return "ThreeFifteen.Boolean";
		else if (this.isFunction())
			return "ThreeFifteen.Function";
		else if ((this._object instanceof Type))
			return "ThreeFifteen.Type";
		else if ((this._object instanceof Browser))
			return "ThreeFifteen.Browser";
		else if ((this._object instanceof Cookie))
			return "ThreeFifteen.Cookie";
		else if ((this._object instanceof Coordinate))
			return "ThreeFifteen.Coordinate";
		else if ((this._object instanceof CSS))
			return "ThreeFifteen.CSS";
		else if ((this._object instanceof Event))
			return "ThreeFifteen.Event";
		else if ((this._object instanceof Validate))
			return "ThreeFifteen.Validate";
		else
			return this._object.toString();
	}
};

//---------------------------------------------------------------------------------------------//

// All class that derive from Object will receive the getType method
Object.prototype.getType = function() { return new Type(this); }

Object.isUndefined = function(property) { return (typeof property == "undefined"); }

Object.getElementsByClassName = function(searchClass, node, tag) 
{
	var classElements = new Array();
	
	if (node == null)
		node = document;
		
	if (tag == null)
		tag = '*';
		
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) 
	{
		if ( pattern.test(els[i].className) ) 
		{
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
};

Object.required = function(libraryName)
{
	var path = "";
	var scriptTags = document.getElementsByTagName("script");
	
	for (var i=0; i<scriptTags.length; i++)
	{
		if (scriptTags[i].src && scriptTags[i].src.match(/Domain\.js(\?.*)?$/))
			path = scriptTags[i].src.replace(/Domain\.js(\?.*)?$/,'');
	}
	
	document.write("<script type='text/javascript' src='" + path + libraryName + "'></script>");
};

Object.required("Array.js");
Object.required("Browser.js");
Object.required("Cookie.js");
Object.required("Coordinate.js");
Object.required("CSS.js");
Object.required("Date.js");
Object.required("DOM.js");
Object.required("Event.js");
Object.required("Number.js");
Object.required("String.js");
Object.required("Validate.js");

//---------------------------------------------------------------------------------------------//

// Inheritance
ThreeFifteen.prototype = new Object();
ThreeFifteen.prototype.constructor = ThreeFifteen;
ThreeFifteen.prototype.baseClass = Object.prototype.constructor;

// Constructor
function ThreeFifteen()
{
	this.version = "1.0.0";
	
	this.browser = new Browser();
	this.cookie = new Cookie();
	this.coordinate = new Coordinate(0,0);
	this.css = new CSS();
	this.date = new Date();
	this.dom = new DOM();
	this.validate = new Validate();
};

// Public Methods
ThreeFifteen.prototype =
{
	toString: function()
	{
		return "ThreeFifteen. Version: " + this.version;
	}
};

//---------------------------------------------------------------------------------------------//