window.addEvent('domready', function(){ 
        InfoBox = new new Class({            
        initialize: function() {
            // privates
            var messageWidth = 560,
                attachEventsHnd,
                hideHnd,
				active = false,
                container = new Element('div', { 
                    style: 'position: absolute; z-index: 99999; width: ' + messageWidth + 'px; height: auto; top: 0px; background-color: #ffE0E0; border:3px solid #FF8080;',
                    opacity: 0 
                }),
                message = new Element('div', {
                    style: 'color: #000; margin: 15px auto; padding: 0 15px; text-align: center; font: 16px "Lucida Grande", Arial, Helvetica, Verdana, sans-serif;font-weight:700;',
                    opacity: 0 
                }).inject(container),
                // create fx
                fx = new Fx.Elements([container, message], {
                    duration: 800,
                    link: 'cancel',
                    onComplete: function() {  }
		        });

	        function show(text) {
				if (active) {hide();}
				active = true;
	            var leftStop = (window.getWidth() / 2) - (messageWidth /2);
				var scrollFrom = $(document.body).getScroll().y;
	            var topStop = scrollFrom + (window.getHeight() /2) - 150;
                container.setStyle('left', -leftStop);
                container.style.top = topStop; //'50px';
                message.innerHTML = text;        
                fx.start({ 0: { left: [-messageWidth, 100], opacity: [0, 0.9], top:[topStop] }, 1: { opacity: [0, 1] } });
                $clear(attachEventsHnd);
                $clear(hideHnd);
                attachEventsHnd = attachEvents.delay(700);
                hideHnd = hide.delay(4000);
            }
	            
            function attachEvents(){
                //document.addListener('mousemove', hide);
                document.addListener('click', hide);
                //document.addListener('keypress', hide);        
            }
            
            function hide() {
                // Remove message if mouse is moved or key is pressed
                //document.removeListener('mousemove', hide);
                document.removeListener('click', hide);
				var scrollFrom = $(document.body).getScroll().y;
                //document.removeListener('keypress', hide);                		        		
                fx.start({'0': {'opacity': [0], 'top': [scrollFrom + 300] }, '1': {'opacity': [0] }});
				active = false;
            }
            
            window.addEvent('domready', function() {
                container.inject($(document.body))                                		        
            });
            
            // public api
            this.show = show;
        }
    });
});