$(document).observe('dom:loaded',function(){
        var box = $('box-loading');
        if(!box){
            box = new Element('div',{id:'box-loading'});
            load = new Element('div',{id:'loading'});
            box.insert(load);
            $(document.body).insert({'top':box});
        }
        box.setStyle({'position':'relative','float':'left','zIndex':'999999'});
        
        Ajax.Responders.register({
             'count':0,
            'onComplete':function(){
                this.count--;
                if(!this.count){
                    $('loading').hide();
                    this.timer = 0;
                }

            },
            
            'onCreate':function(){
                var load = $('loading');
                  if(!this.count){
                      var height =  document.viewport.getScrollOffsets()[1]+$(document).viewport.getHeight();
                      var width = $(document).viewport.getWidth()+document.viewport.getScrollOffsets()[0];
                      load.setStyle({  'width':width+'px',
                                       'height':height+'px',
                                       'background':'#666',
                                       'position':'absolute',
                                       'top':'0',
                                       'left':'0',
                                       'bottom':'0',
                                       'right':'0',
                                       'z-index':'65535',
                                       'padding-top':height / 2
                                   });
                                   load.setOpacity(0.5);

                    this.count++;                     
                    load.show();
                  }
                  
            }
           
        });

})