var AjaxLoader = new Class({
	
	initialize: function() {
	
		this.centerX = (window.getWidth()/2)-16;
		this.centerY = (window.getHeight()/2)-16;
		
		this.Overlay = new Element('div', {
			'id'    : 'AjaxLoaderOverlay',
			'styles': {
	          		'display'           : 'none',
	          		'position'          : 'absolute',
	          		'top'               : '0',
	          		'left'              : '0',
	          		'opacity'           : 0.7,
	          		'z-index'           : 65559,
	          		'background-color'  : '#000',
	          		'height'            : window.getScrollHeight() + 'px',
	          		'width'             : window.getScrollWidth() + 'px'
				}
		});
		this.Picture = new Element('img', {
			 src: 'framework/js/mootools/img/loading.gif',
			 'styles': {
			 	'height' : '32px',
			 	'width' : '32px',
				'z-index': 65561,
				'position': 'absolute',
			 	'top' : this.centerY + 'px',
			 	'left' : this.centerX + 'px'
				}
		});
		
		this.Overlay.adopt(this.Picture);
		this.Overlay.injectInside(document.body);
	},

	togFlashObjects: function(state) {
		var hideobj=new Array("embed", "iframe", "object");
		for (y = 0; y < hideobj.length; y++) {
			var objs = document.getElementsByTagName(hideobj[y]);
			for(i = 0; i < objs.length; i++) {
				objs[i].style.visibility = state;
			}
		}
	},
	
	show: function() {
		if(Browser.Engine.trident4)
			$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' });
		    
		this.togFlashObjects('hidden');
		$('AjaxLoaderOverlay').set('styles', {'display': 'block'});
	},

	hide: function() {
		if(Browser.Engine.trident4)
			$$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' });
		
		this.togFlashObjects('visible');
		$('AjaxLoaderOverlay').set('styles', {'display': 'none'});
	}
});

//window.addEvent('domready', function() {
	// var ajaxLoader  = new AjaxLoader();
	// ajxLoader.show();
//});		
