(function(){


    /**
    * Display inline container popup effect.
    */
    aura.provide('s100g.effect.inlineContainerPopup');

    var effect = aura.namespace('s100g.effect.inlineContainerPopup');

    effect.process = function(node)
    {
        effect.launch(node, aura.byId(aura.dom.getAttribute(node, 'inlineContainerPopupId')));
    };

    effect.launch = function(linkId, panelId)
    {

        var o = {
            linkNode: aura.byId(linkId),
            panelNode: aura.byId(panelId)
        };

        aura.event.on(o.linkNode, 'click', function(e)
        {
            aura.event.stop(e);
            if ( ! ( 'panel' in o ) )
            {
                aura.style.removeClass(o.panelNode, 'hideOnLoad');
                o.panel = effect.createPanel(o.panelNode);
                o.panel.render();
            }
            o.panel.show();
        });
    };

    effect.createPanel = function(panelId)
    {

        var panel = new YAHOO.widget.Panel(panelId,{
            fixedcenter: true,
            close: true,
            draggable: false,
            modal: true,
            visible: false,
            effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration:0.5}
        });

        return panel;

    };

    /**
    * Register us with the effects manager.
    */
    aura.effect.registerEffect(
        's100g.effect.inlineContainerPopup',
        effect.process
    );

})();
