/**
@author bibby
Block, Wall, and Pushable classes.
Walls and Pushables are Blocks with unique colors and a moveable boolean,
Blocks have dimensions and position, and a methods to show it
**/

var Block = function()
{
	this.extends(Tangible)
	.extend({
		'class':'Block',
		id:null,
		moveable:null,
		color:'black',
		img:null,
		
		makeimg: function()
		{
			if(is(this.id,'null'))
			{
				this.id='block_'+(Math.floor(Math.random()*78000));
			};
			
			elm = document.createElement('DIV');
			with(elm.style)
			{
				position='absolute';
				backgroundColor=this.color;
			}
			elm.id = this.id;
			this.img= elm;
			return this;
		},
		
		display:function()
		{
			if(!is(document.getElementById(this.id)))
			{
				with(this.img.style)
				{
					top = this.pos.top;
					left = this.pos.left;
					width = this.dim.width;
					height = this.dim.height;
				}
				
				document.body.appendChild(this.img);
			};
		},
		
		load:function(){
			this.makeimg().display();
			if(is(Contact,'object'))
				Contact.register(this,'Block');
		}
	})
};


var Wall = function(params)
{
	this.extends(Block)
	.extend({
		moveable:false,
		color:'gray'
	},true)
	.extend(params,true)
	.init();
};

var Pushable = function(params)
{
	this.extends(Block)
	.extend({
		moveable:true,
		color:'#abcdef'
	},true)
	.extend(params,true)
	.init();
};
