/**
@author bibby
Base class from which all "physical objects" are derived.
Offers only extensibility and execution of the subclass's load() method
when initialized with paramters [ new Whatever().init(params) ]
**/

var Element = function()
{
	this.dim=[0,0];
	this.id=null;
	this.pos={left:0,top:0};
	
	this.extend = function(o)
	{
		if(!is(o,'object'))
			return;
		
		for(var i in o)
			this[i]=o[i];
		
		return this;
	};
	
	this.init=function(params)
	{
		if(is(params,'object'))
			this.extend(params);
		
		if(is(this.load,'function'))
			this.load();
		
		return this;
	};
	
	
	/* returns the coordinal area taken up by this object.
	@param string optional propery to fake for previewing an area to enter
	@param int optional value to fake
	*/
	this.area = function(alterProp, alterVal)
	{
		var t,l;
		t = this.pos.top;
		l = this.pos.left;
		if(is(alterProp))
		{
			
			t = alterProp == 'top' ? alterVal : this.pos.top;
			l = alterProp == 'left' ? alterVal : this.pos.left;
		}
		return [l,t, (l + this.dim[0]), (t + this.dim[1])];
	};
}

