/**
* -------------------------------------------------------------------------------
* @class Message
* 	Controla as mensagens amigáveis dos formulários.
* -------------------------------------------------------------------------------
*/
oMessage = $extend(
	new Storage({
		elementId: 'message-box',
		classNames: $A(['information-simple', 'success-simple', 'warning-simple', 'error-simple', 'information', 'success', 'warning', 'error']),
		hideMsgTimeout: 7,
		timeoutId: null
	}), {
		
		show: function(){
			var hConfig = $H($extend({
				box: this.Store.get('elementId'),
				type: 'warning',
				text: '',
				autoHide: false,
				autoHideTimeout: this.Store.get('hideMsgTimeout'),
				scrollTo: false
			}, arguments[0] || {}));
			
			if(null != this.Store.get('timeoutId'))
				window.clearTimeout(this.Store.get('timeoutId'));
			
			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')){
				var oFx = new Fx.Scroll(window, {}).toElement(oElement);
				delete oFx;
			}
			
			if(hConfig.get('autoHide'))
				this.Store.replace('timeoutId', oMessage.hide.delay((hConfig.get('autoHideTimeout') * 1000), this, hConfig.get('box')));
			
			return oElement;
		},
		
		hide: function(){
			var sBox = arguments[0] || this.Store.get('elementId');
			return $(sBox).setStyle('display', 'none').empty();
		}
		
	}
);
