AnimalsGame.StageElement = new Class({
	
	initialize: function(opts) {
		var this_ = this;
		
		this.element = this.element || opts['element'];
		this.children = opts['children'] || [];
		
		if (opts['position']) {
			this.setPosition(opts['position']);
		}
		
		$(this.element).addClass('stage-element');
		
		if (opts['className']) {
			$(this.element).addClass( opts['className'] );
		}
		
		if ( opts.interactive !== false ) {
			// this.element.tabIndex = 0;
			this.interactive = true;
			this.element.className += ' interactive';
		} else {
			this.interactive = false;
		}
		
		if (opts['click']) {
			$(this_.element).on('click', function() {
				if (this_.interactive) {
					opts['click'].call(this_);
				}
			});
		}
		
		if (opts['autoAppend'] !== false) {
			$(AnimalsGame.STAGE).append(this.element);
		}
		
		this.children.each(function(e) {
			$(e.element).addClass('child');
			$(this_.element).append(e.element);
		});
	},
	
	setPosition: function(positionProperties) {
		for (var prop in positionProperties) {
			if (!positionProperties.hasOwnProperty(prop)) { continue }
			
			this.element.style[ prop ] = positionProperties[ prop ];
		}
	},
	
	activate: function() {
		this.interactive = true;
		$(this.element).addClass('interactive');
	},
	
	deactivate: function() {
		this.interactive = false;
		$(this.element).removeClass('interactive');
	},
	
	destroy: function() {
		$(this.element).remove();
		this.children.each('destroy');
	}
	
});
