var Flash = Class.create({
	element: null,
	initialize: function(args) {
		this.options = Object.extend({
			element_id: "flash", 
			showEffect: Effect.Appear,
			hideEffect: Effect.Fade, 
			showEffectOptions: {},
			hideEffectOptions: {},
			autoHideAfter:null
		},(args||{}));
		this.element = $(this.options.element_id);
		if(this.element.empty())
			this.element.hide();
	}, 
	toggle: function() {
		if(this.element.visible())
			this.hide();
		else
			this.show();
	},
	show: function(args) {
		var args = args || {};
		new this.options.showEffect(this.element, this.options.showEffectOptions);
		if(this.options.autoHideAfter || args.autoHideAfter) {
			setTimeout(function() {
				this.hide()
			}.bind(this), (this.options.autoHideAfter || args.autoHideAfter));
		}	
	}, 
	hide: function() {
		new this.options.hideEffect(this.element, this.options.hideEffectOptions);
	}, 
	append: function(message) {
		this.element.insert({bottom: message});
	},
	message: function(message,options) {
		this.element.update(message);
		this.element.className=options.className;
		this.show(options);
	},
	error: function(message,options) {
		
		this.message(message, Object.extend({className:"error"},(options||{})));
	},
	notice: function(message,options) {
		this.message(message, Object.extend({className:"notice"},(options||{})));
	},
	ok: function(message,options) {
		this.message(message, Object.extend({className:"ok"},(options||{})));
	}
});
var flash;
$(document).observe("dom:loaded", function(){
	flash = new Flash({autoHideAfter:5000});
});