/**
* -------------------------------------------------------------------------------
* @class Message
* 	Controla as mensagens amigáveis dos formulários.
* -------------------------------------------------------------------------------
*/
oMessage = $extend(
	new Storage({
		elementId: 'message-box',
		classNames: $A(['success-simple', 'warning-simple', 'error-simple', 'success', 'warning', 'error']),
		hideMsgTimeout: 7000
	}), 
	
	{
		
		show: function(hMyConfig){
			var hConfig = $H($extend({
				box: this.Store.get('elementId'),
				type: 'warning',
				text: '',
				autoHide: false,
				autoHideTimeout: this.Store.get('hideMsgTimeout'),
				scrollTo: false
			}, hMyConfig));
			
			var oElement	= $(hConfig.get('box'));
			var aClassNames = this.Store.get('classNames');
			
			if(!aClassNames.contains(hConfig.get('type')))
				return;
			
			aClassNames.each(function(sClassName){
				oElement.removeClass(sClassName);
			});
			
			oElement.addClass(hConfig.get('type')).setHTML(hConfig.get('text')).setStyle('display', 'block');
			
			if(hConfig.get('scrollTo'))
				new Fx.Scroll(window, {duration: 500}).toElement(oElement);
			
			if(hConfig.get('autoHide'))
				this.hide.delay(hConfig.get('autoHideTimeout'), this, hConfig.get('box'));
			
			return oElement;
		},
		
		hide: function(){
			var sBox = ($defined(arguments[0])) ? arguments[0] : this.Store.get('elementId');
			return $(sBox).setStyle('display', 'none').empty();
		}
		
	}
);