	// MT1.11 Compat
	var $E = function(selector, filter){
		return ($(filter) || document).getElement(selector);
	};
	
	var $ES = function(selector, filter){
		return ($(filter) || document).getElements(selector);
	};
	
	var top_msg = [];
	
	
	
	window.addEvent('domready', function() {
		showTopMsg(top_msg);
	});
	
	
	
	var _msgtimer = null;
	showTopMsg = function(messages) {
		var _cnt = $('msg_top');
		var _msg = $E('.messages', _cnt);
		if(!_cnt || !_msg) return false;
		
		if(!messages || !messages.length || messages.length == 0) return false;
		var messages = $A(messages);
		
		_msg.set('html', '');
		
		var _ul = $(document.createElement('ul'));
		messages.each(function(m) {
			var _li = $(document.createElement('li'));
			if(m[1] != '') {
				_li.className = m[1];
			}
			_li.set('html', m[0]);
			_ul.appendChild(_li);
		});
		_msg.appendChild(_ul);
		
		var sl = new Fx.Slide(_msg, {duration: 400});
		sl.hide();
		
		_msg.setStyles({
			display: 'block',
			margin: '0 auto'
		});
		sl.slideIn();
		
		if(!_msgtimer) _msgtimer = new Timer(12000)
		var _fncloseslide = function(e) {
			sl.slideOut();
		}.bind(this);
		_msgtimer.end = _fncloseslide;
		
		_msgtimer.stop();
		_msgtimer.start();
		
		_cnt.removeEvents('click');
		_cnt.addEvent('click', function(e) {
			sl.hide();
		});
	}
	
	var Timer = new Class({
		initialize: function (ms) {
			this.start_ms	=	0;
			this.ms			=	ms;
			this.is_started	=	false;
		},
	
		start: function () {
			d=new Date();
			this.start_ms	=	d.getTime();
			this.is_started	=	true;
			this.run.delay(50, this);
		},
	
		run: function () {
			if(!this.is_started) return;
			d=new Date();
			t=d.getTime();
			
			if((t - this.start_ms) >= this.ms) {
				this.end();
			} else {
				this.run.delay(50, this);
			}
		},
	
		reset: function () {
			d=new Date();
			this.start_ms = d.getTime();
		},
		
		stop: function () {
			this.initialize(this.ms, this.name);
		}
	});
	Timer.implement(new Events, new Options);
	
	