var Growl = new Abstract({
	
	options: {
		type: 'smoke',
		image: false,
		title: false,
		content: '',
		persist: false,
		duration: 3000
	},
	
	create: function(){
		this.container = new Element('div', { 'id': 'growl' }).injectInside(document.body);
		this.block = new Element('div').adopt([
			new Element('div', { 'class': 'background' }).setOpacity(.90),
			new Element('img', { 'alt': '' }),
			new Element('h1'),
			new Element('span')
		]);
	},
	
	show: function(options){
		if(!this.block) this.create(options);
		options = $merge(this.options, options);
		
		var last = this.container.getLast(),
		    block = this.block.clone(true).addClass(options.type),
		    children = block.getChildren();
		options.image   ? children[1].setProperty('src', options.image) : children[1].setStyle('display', 'none');
		options.title   ? children[2].setHTML(options.content) : children[2].setStyle('display', 'none');
		options.content ? children[3].setHTML(options.content) : children[3].setStyle('display', 'none');
		
		block.addEvent('click', this.hide.bind(this, block));
		block.setStyles({ 'opacity': 0, 'top': last ? last.getCoordinates().bottom + 5 : 5 });
		block.injectInside(this.container);
		block.$attributes.fade = block.effect('opacity', { wait: false }).start(1);
		if(!options.persist) block.$attributes.timer = this.hide.delay(options.duration, this, block);
	},
	
	hide: function(block){
		$clear(block.$attributes.timer);
		block.$attributes.fade.start(0).chain(block.remove.bind(block));
	}
	
});
