/**
* Adds dynamic behaviour to the page
* 
* @author Philipp Wintermantel <p.wintermantel@netzbewegung.com>
* @version $Id$
*/
Nb_Page = new Class({
    Implements: Events,
    loadContent: function(url)
    {      
        $('contentMainBody').set('load',{
            onRequest: function()
            {
                $('contentMain').setStyle('height', $('contentMainBody').getScrollSize().y + 32);
                this.startLoader();
                
            }.bind(this),
            onComplete: function()
            {
                this.fireEvent('contentChanged', $('contentMainBody'));
            
                var animation = new Fx.Tween($('contentMain'), {onComplete: function() {
                    this.stopLoader();
                }.bind(this)});

                animation.start('height', $('contentMainBody').getScrollSize().y + 32);
                
            }.bind(this)
        });
        $('contentMainBody').load(url);
    },
    loadTeaser: function(url, position)
    {
        /* @todo uncomment this if recipe extension is live and visible
        if (position == 0)
        {
            
            var teaser = $$('#teaserRow .teaser')[0];
            
            if (teaser.hasClass('teaser-30'))
            {
                var width = 30;
            }
            else
            {
                var width = 50;
            }
            
            
            teaser.set('load', {
                onComplete: function()
                {
                }.bind(this) 
            });
            
            teaser.load(url + '&width=' + width);
        }
        */
    },
    startLoader: function()
    {
        loader = new Element('div');
        loader.id = 'loader-content';
        img = new Element('img');
        img.src = '/assets/global/img/ajax-loader.gif';
        img.alt = 'Bitte warten';
        img.id = 'loader-content-img';
        img.inject(loader);
        loader.inject('contentMain');  
    },
    stopLoader: function()
    {
        if ($('loader-content'))
        {
            $('loader-content').destroy();
        } 
    }
});
