/**
 * Dynamic overlays.
 *
 * @author EMV
 * @version $Id$
 * @package Video
 * @subpackage Modules.Tools
 */
Emv.VideodeJsoverlay = function (contextId, panelWidth) {

    this.CSS_PANEL_MASK = 'transparent';
    this.contextId      = contextId;
    this.panelWidth     = 300;
    this.panel;

    this.Dom            = YAHOO.util.Dom;

    this.createHtmlContainer = function(headerContent, bodyContent, containerType) {

        var htmlContainer1 = '';
        var htmlContainer2 = '';
        var overlayToClose = this.contextId + 'Overlay';

        htmlContainer1 =   '<div class="flyout-' + this.panelWidth + '">';
        htmlContainer1 +=	'    <div class="header-background"></div>';
		htmlContainer1 +=	'    <div class="content-background">';
		htmlContainer1 +=	'        <a class="close" href="javascript:" onfocus="this.blur()" onclick="Emv.Registry.getParam(\'' + this.contextId + 'Overlay\').hide();" title="Schließen">Schließen</a>';
		htmlContainer1 +=	'        <div class="content-gradient">';
        htmlContainer1 +=	'            <div><strong class="hd">' + headerContent + '</strong></div>';
		htmlContainer1 +=	'            <div class="flyout-content bd">' + bodyContent + '</div>';
		htmlContainer1 +=	'        </div>';
		htmlContainer1 +=	'    </div>';
		htmlContainer1 +=	'    <div class="footer-background"></div>';
		htmlContainer1 +=	'</div>';

		htmlContainer2 = '';

		if (containerType == 2) {

		    return htmlContainer2;
		}

		return htmlContainer1;
    }

    this.init = function(panelWidth) {

        if (panelWidth > 0) {

            this.panelWidth = panelWidth;
        }

        this.panel = new YAHOO.widget.Panel(this.contextId + "Overlay",
                {
                  close: false,
                  draggable: false,
                  modal: false,
                  visible: false,
                  fixedcenter : false,
                  constraintoviewport: true,
    	          context: [ this.contextId, "tl", "bl", ["beforeShow", "windowResize"] ],
                  effect: {effect:YAHOO.widget.ContainerEffect.FADE, duration: 0.25}
                }
        );
        Emv.Registry.setParam(this.contextId + "Overlay", this);
        this.panel.render(document.body);
    };

    this.show = function(headerContent, bodyContent) {

        // 1. Show the panel/overlay.
        this.panel.show();
		this.Dom.addClass(this.contextId + "Overlay_mask", this.CSS_PANEL_MASK);
		this.panel.cfg.setProperty("zIndex", 9999);
		this.panel.bringToTop();

        // 2. Push the html content into the overlay.
        this.Dom.get(this.contextId + "Overlay").innerHTML = this.createHtmlContainer(headerContent, bodyContent, 1);
    };

    this.hide = function() {

        this.panel.hide();
        Emv.Registry.setParam(this.contextId + "Overlay", '');
    }

    this.init(panelWidth);
};

Emv.VideodeJsoverlay.get = function (contextId, panelWidth) {

    return new Emv.VideodeJsoverlay(contextId, panelWidth);
};