var GUIOverlay = new Class({
    element: false,
    content: false,
    lastUrl: false,
    refreshOnHide: true,

    initialize: function() {
        this.element = new Element('div', { 'class': 'GUIOverlay' }).inject( document.body );

        this.content = new Element('div').inject( this.element );
        this.close = new Element('div', { 'class': 'close', html: '<img src="assets/img/icon_close.png" border=0 title="Close">'}).addEvent('click', function() { this.hide(); }.bind(this) ).inject( this.element );
    },

    show: function() {
        iqOverlay.showOverlay();
        this.element.setStyles( { display: 'block'}).position();
    },

    hide: function() {
        iqOverlay.hideOverlay();
        this.element.setStyles( { display: 'none'});
        if (this.refreshOnHide) {
            window.location.reload();
        }
    },

    load: function(url) {
        new Request.HTML({update: this.content}).get(url);
        this.lastUrl = url;
    },

    reload: function() {
        this.load(this.lastUrl);
    }

} );

var my_overlay = false;

$( window ).addEvent( 'domready', function() {
    my_overlay = new GUIOverlay();
});
