var Message = new Class( {
		
		delay: null,

		severity: {
			info: 'info',
			warning: 'warning',
			error: 'error'
		},

		initialize: function() {
			var container = new Element( 'div', { 'id': 'messageContainer' } );
			this.box = new Element( 'div', { 'id': 'messageBox' } );
			container.appendChild( this.box );
			document.body.appendChild( container );
			this.box.set( 'tween', { duration: 800 } );
			this.box.set( 'opacity', 0 );
			this.box.addEvent( 'click', function( e ) {
					this.hide();
			}.bind( this ) );
			this.messageList = new Array();
		},

		display: function( message, severity ) {
			$clear( this.delay );
			$clear( this.eraseDelay );
			this.box.erase( 'html' );
			var messageDiv = new Element( 'div', {
					'html': message,
					'class': severity || this.severity.info
			} );
			messageDiv.inject( this.box );
			this.box.tween( 'opacity', 0.95 );

			this.delay = this.hide.delay( 15000, this );
		},

		erase: function() {
			if( this.box.get( 'opacity' ) === 0 || this.box.get( 'opacity' ) == '0' )
  				this.box.erase( 'html' );
		},

		hide: function() {
			$clear( this.eraseDelay );
			this.box.tween( 'opacity', 0 );
			this.eraseDelay = this.erase.delay( 1000, this );
		}

} );

window.addEvent( 'domready', function( e ) {
		window.message = new Message();
} );
