var AjaxWindow = new Class({
    Implements: Options,
    
    options: {
		'indicatorSource': ''
	},
    
   initialize: function(options) {
		this.setOptions(options);
        
		this.render();
	},
    
	render: function() {
		this.container = new Element('div', {
            'id': 'AjaxWindow',
            'styles': {
                'height': $(document.window).getScrollSize().y,
                'width': $(document.window).getScrollSize().x
            }
        }).injectInside(document.body);
        
        this.overlay = new Element('div', {
            'class': 'overlay',
            'styles': {
                'visibility': 'hidden',
                'opacity': 0,
                'height': $(document.window).getScrollSize().y
            },
            'events': {
                'click': function(e) {
                    e.stop();
                    this.hide();
                }.bind(this)
            }
        }).injectInside(this.container);
        
        this.window = new Element('div', {
            'class': 'window',
            'events': {
                'click': function(e) {
                    e.stop();
                }
            }
        }).injectInside(this.overlay);
        
        this.indicator = new Element('img', {
            'class': 'indicator',
            'src': this.options.indicatorSource
        }).injectInside(this.window);
        this.showIndicator();
	},
    
    show: function() {
		this.overlay.fade(1);
	},
    
    hide: function() {
		this.overlay.fade(0);
	},
    
    load: function(url) {
        this.showIndicator();
        this.show();
        var ajax = new Request.HTML({
            'url': url,
            'update': this.window,
            onComplete: function() {
                this.window.getElement('.closeButton').addEvent('click', function(e) {
                    e.stop();
                    this.hide();
                }.bind(this));
            }.bind(this)
        }).get();
    },
    
    showIndicator: function() {
        this.window.empty();
        this.indicator.injectInside(this.window);
    }
});

