var ajaxLoader = {
     init: function(){
         this.panel = new Element('div', {'id': 'ajaxLoading_panel','styles': {'display': 'none','position':'absolute','left':'50%','top': '50%','z-index':'10000','text-align':'center','margin-top':'-50px','margin-left': '-'+(300/2)+'px','opacity': '0','width': '300px'}}).inject(document.body);
         this.panel.set('tween', {duration: 'long'});
         this.content = new Element('div', {'styles': {'border': '1px solid #808080','vertical-align': 'middle'}}).inject(this.panel);
         this.header = new Element('div', {'id': 'ajaxLoading_header','styles': {'white-space': 'nowrap','background': 'url(/img/background_silver.jpg)','padding': '0 5px','color': '#000','font-size':'9pt','font-weight': 'bold','font-family': 'arial','line-height': '1.9'}}).inject(this.content);
         this.body = new Element('div', {'id': 'ajaxLoading_body','styles': {'background-color': '#fff'}}).inject(this.header, 'after');
         this.loadingimg = new Element('img', {'src': '/img/AJAX_LoadingBar.gif'}).inject(this.body);
         this.overlay = new Element('div', {'id': 'ajaxLoading_wrapper','styles':{'position':'absolute','left':'0','width': Window.getWidth()+'px','height': Window.getHeight()+'px','display': 'none','opacity': '0','z-index':'99999'}}).wraps(this.panel);
         this.eventPosition = this.position.bind(this);
     },
     show: function(msg){
         this.position();
         this.setup(true);
         this.overlay.setStyles({'display': 'block'});
         this.overlay.tween('opacity', [0,.8]);
         this.panel.setStyles({'display': ''});
         this.panel.tween('opacity', [0,1]);
         this.header.set('text', msg);
     },
     position: function(){
         this.overlay.setStyles({top: window.getScrollTop()+'px'});
     },
     setup: function(open){
         var toggleThese = $A($$('object'));
         toggleThese.extend($$(window.ActiveXObject ? 'select' : 'embed'));
         toggleThese.each(function(el){el.style.visibility = open ? 'hidden' : '';});
         var fn = open ? 'addEvent' : 'removeEvent';
         window[fn]('scroll', this.eventPosition)[fn]('resize', this.eventPosition);
     },
     hide: function(){
         this.setup(false);
         this.panel.tween('opacity', 0);
         this.panel.setStyles({'display': 'none'});
         this.header.set('text', '');
         this.body.set('html', '<img src="/img/AJAX_LoadingBar.gif">');
         this.overlay.tween('opacity', [0]);
         this.overlay.setStyles({'display': 'none'});
     }   
};
window.addEvent('domready', ajaxLoader.init.bind(ajaxLoader));