var fp = fp || {}; //namespace fp
fp.ui = fp.ui ||  {} //namespace ui


/* newsletter ui */
fp.ui.newsletter = {
    id : 'layerboxNewsletter',
    urlKey : 'newsletter',

    init : function(){
        /* todo prototype */
        var _this = this;
        document.observe("dom:loaded", function() {
            _this.initOnReady();
        });
    },
    initOnReady : function(){
        /* todo calling by event not by ready */
        if(window.location.href.split('?')[1] === this.urlKey){
            this.show();
        }
    },

    show : function(){
       fp.ui.overlay.show();
       /* todo prototype */
       $(this.id).show();
       
       // Todo : proper place for ...
       Event.observe('newsletterSignup','submit',function(event){
           Event.stop(event);
           event.preventDefault();
       },false);

    },

    hide : function(){
        fp.ui.overlay.hide();
        /* todo prototype */
        $(this.id).hide();
    },
    hideByTime : function(delay) {
      window.setTimeout(function() { fp.ui.newsletter.hide(); }, delay);
    }
}
fp.ui.newsletter.constructor = fp.ui.newsletter.init();

/* overlay */
fp.ui.overlay = {
    id : 'overlay',

    init : function(){
    },

    show : function(){
        fp.ui.effect.fade(this.id, 0, 0.4);
        $(this.id).show();
    },

    hide : function(){
        $(this.id).hide();
        $(this.id).setOpacity(0);
    }

}
fp.ui.overlay.constructor = fp.ui.overlay.init();

/* effects */
fp.effect = fp.effect ||  {} //namespace effect
fp.ui.effect = {

    /* todo prototype */
    fade : function(id, from, to){
        from = from || 0;
        to = to || 1;
        new Effect.Appear(id, {duration: from,  to: to});

    }

}
