

GOverlayMessage = function ( container2,displayimage)
    {
    // Terminology:
    // +-----------------+
    // |wrapper          |
    // |+---------------+|
    // ||container      ||
    // ||   +-------+   ||
    // ||   |overlay|   ||
    // ||   +-------+   ||
    // ||               ||
    // |+---------------+|
    // +-----------------+

    // Get the parent.
    var parent = container2.parentNode;

    // Make the wrapper div.
    var wrapper = document.createElement( 'div' );
    wrapper.style.cssText = container2.style.cssText;
    parent.insertBefore( wrapper, container2 );

    // Move the container into the wrapper.
    parent.removeChild( container2 );
    wrapper.appendChild( container2 );
    container2.style.cssText = 'position: relative; width: 100%; height: 100%;';

    // Add the overlay div.
    this.overlay = document.createElement( 'div' );
    wrapper.appendChild( this.overlay );
    //this.visibleStyle = 'position: relative; top: -58%;left:47%; background-color: ' + GOverlayMessage.backgroundColor + '; text-align: center; margin-left: auto; margin-right: auto; padding: 2em; text-align:left; border: 2px thin' + GOverlayMessage.borderColor + '; background-image:url(loading.gif); background-repeat:no-repeat; background-position:center; z-index: 100; opacity: .75; filter: alpha(opacity=75);';
    this.visibleStyle = 'position: relative; top: -51%;left:47%; text-align: center; margin-left: auto; margin-right: auto; padding: 2em; text-align:left; border: 2px thin' + GOverlayMessage.borderColor + '; background-image:url(/app_themes/runmap/images/pics/busy.gif); background-repeat:no-repeat; background-position:center; z-index: 100;';
    this.invisibleStyle = 'display: none;';
    this.overlay.style.cssText = this.invisibleStyle;
    this.img = displayimage;
    };


    //GOverlayMessage.backgroundColor = '#ffffff';
    GOverlayMessage.backgroundColor = 'transparent';
GOverlayMessage.borderColor = '#666699';


GOverlayMessage.prototype.Set = function ( message )
    {
    if (null!=this.img)
        this.overlay.innerHTML = "<img border=0 src='"+this.img.src+"' />"+message;
     else    
       this.overlay.innerHTML = message;
    
    this.overlay.style.cssText = this.visibleStyle;
    };


GOverlayMessage.prototype.Clear = function ()
    {
    this.overlay.style.cssText = this.invisibleStyle;
    };


GOverlayMessage.SetBackgroundColor = function ( color )
    {
    GOverlayMessage.backgroundColor = color;
    };


GOverlayMessage.SetBorderColor = function ( color )
    {
    GOverlayMessage.borderColor = color;
    };
