// Copyright © 2006 by Jef Poskanzer <jef@mail.acme.com>.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
//    notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
//    notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE.
//
// For commentary on this license please see http://www.acme.com/license.html

OverlayMessage = function ( container )
    {
    // Terminology:
    // +-----------------+
    // |wrapper          |
    // |+---------------+|
    // ||container      ||
    // ||   +-------+   ||
    // ||   |overlay|   ||
    // ||   +-------+   ||
    // ||               ||
    // |+---------------+|
    // +-----------------+

    // Get the parent.
    var parent = container.parentNode;

    // Make the wrapper div.
    var wrapper = document.createElement( 'div' );
    wrapper.style.cssText = container.style.cssText;
    parent.insertBefore( wrapper, container );

    // Move the container into the wrapper.
    parent.removeChild( container );
    wrapper.appendChild( container );
    container.style.cssText = 'position: relative; width: 100%; height: 100%;';

    // Add the overlay div.
    this.overlay = document.createElement( 'div' );
    wrapper.appendChild( this.overlay );

    this.backgroundColor = 'rgb(222,230,239)';
    this.borderColor = '#666699';

    this.overlay.style.position = 'relative';

	var b_version=navigator.appVersion;

	if (navigator.appName=="Netscape") {
		this.overlay.style.top = '0%';
	}else{
		if (b_version.indexOf('MSIE 6.0') > 0) 	{
			this.overlay.style.top = '-65%';
			this.overlay.style.width = '100%';
			this.overlay.style.marginLeft = '40%';
		}else{
			this.overlay.style.top = '-80%';
			this.overlay.style.width = '40%';
			this.overlay.style.marginLeft = 'auto';
		}
	}
    
	this.overlay.style.marginRight = '15%';
    this.overlay.style.backgroundColor = this.backgroundColor;
    this.overlay.style.textAlign = 'left';
    this.overlay.style.padding = '2em';
    this.overlay.style.borderWidth = '6px;';
    this.overlay.style.borderStyle = 'ridge';
    this.overlay.style.borderColor = this.borderColor;
    this.overlay.style.zIndex = '100';
    this.overlay.style.opacity = '.95';
    this.overlay.style.filter = 'alpha(opacity=85)';
	
    this.overlay.style.display = 'none';
    };




OverlayMessage.prototype.Set = function ( message )
    {
    this.overlay.innerHTML = "<table border=0 width='100%'><tr><td class='pdMsg'>"+message+"</td></tr><tr><td align='right'><input type='button' value='Close' onclick='javascript:CloseMsg();'></td></tr></table>";

    this.overlay.style.display = 'block';
    };


OverlayMessage.prototype.Clear = function ()
    {
    this.overlay.style.display = 'none';
    };


OverlayMessage.prototype.SetBackgroundColor = function ( color )
    {
    this.backgroundColor = this.overlay.style.backgroundColor = color;
    };


OverlayMessage.prototype.SetBorderColor = function ( color )
    {
    this.borderColor = this.overlay.style.borderColor = color;
    };
