var GrowlMessage = new Class({

	Implements: Options,
	
	options : {
		
	},
		
	initialize : function(options){
		
		this.setOptions(options)
		this.elements = {};
		this.timers = {};
		this.animations = {};
		
		this.create_message_display();
				
	},
	
	create_message_display : function(){
		
		this.elements.display = new Element('div',
		{	'id' : 'growl_message' }).inject(document.body)
		
		this.animations.growl_fade = new Fx.Tween(this.elements.display);
		this.animations.growl_fade.set('opacity',0);	
	},
	
	set_message : function(msg,data){
		
		
		var t = this
	
		this.clear_message();
			
		this.elements.display.set('text',msg.substitute(data))
				
		//this.elements.display.inject($('master_container'))
		
		//this.elements.display.removeClass('hide')
		
		this.animations.growl_fade.start('opacity', 0, 0.8);
		
		this.timers.hide_timer = this.hide_message.delay(2500,t); //Waits 5 seconds then executes myFunction.
		
		//this.elements.display.set('0.8); 
		//this.elements.display.fade(0.8); 
		
		
	},
	
	clear_message : function(){
		
		this.timers.hide_timer = $clear(this.timers.hide_timer);
		this.animations.growl_fade.set('opacity',0)
		this.elements.display.set('text','')
		
	},
	
	success : function(msg){
		
		this.set_message(msg);
		
	},
	
	notice : function(msg){
		
		this.set_message(msg);
		
	},
	
	error : function(msg,code){
	
		this.set_message(msg);	
		
	},
	
	hide_message : function(){
		
		var t = this
			
		this.animations.growl_fade.start('opacity', 0);
	
		this.timers.hide_timer = $clear(this.timers.hide_timer);

		/*this.animations.growl_fade.complete = function(){
			t.elements.display.addClass('hide')
		}*/
		
		
	}
});