(function(){


    /**
    * Display clickToShow effect.
    */
    aura.provide('s100g.effect.clickToShow');

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

    effect.process = function(node)
    {

        var o = {
            //stopEvent: aura.dom.getAttribute(node, 'clickToShowStopEvent') ? true : false,
            stopEvent: true,
            target: aura.byId(aura.dom.getAttribute(node, 'clickToShowTarget')),
            hideSelfOnClick: aura.dom.getAttribute(node, 'clickToShowHideSelfOnClick') ? true : false,
            cancel: aura.byId(aura.dom.getAttribute(node, 'clickToShowCancel'))
        };

        aura.event.on(node, 'click', function(e)
        {
            if ( o.stopEvent ) aura.event.stop(e);
            aura.style.show(o.target);
            if ( o.hideSelfOnClick ) aura.style.hide(node);
        });

        if ( o.cancel )
        {
            aura.event.on(o.cancel, 'click', function(e)
            {
                aura.event.stop(e);
                aura.style.hide(o.target);
                if ( o.hideSelfOnClick ) aura.style.show(node);
            });
        }

    };


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


})();
