























    /**
    *
    *    HISTORY STAGE
    *
    **/
    
    c_history_stage = Class.create({
    
        //
        //    initialize
        //
        initialize: function() {
        
            // settings
            this._history_stage_elmt = $('history-stage');
            this._slider_elmt = this._history_stage_elmt.down('ul');
            this._slide_step = 120;
            this._slide_item_width = 224;
            this._slide_item_rightmargin = 13;
            
            // system vars
            this._slider_item_count = this._slider_elmt.select('li.item').length;
            
            // initialize
            this.prepare_dom();
            this.set_event_handlers();
        
        },
        
        //
        //    prepare dom
        //
        prepare_dom: function() {
        
            this._history_stage_elmt.down('div#history-slider').insert({
                top: '<a href="javascript:void(0)" id="btn-slide-left" style="display: none;">&nbsp;</a>',
                bottom: '<a href="javascript:void(0)" id="btn-slide-right">&nbsp;</a>'
            });
        
        },
        
        //
        //    set event handlers
        //
        set_event_handlers: function() {
        
            $('btn-slide-left').observe('click', function(e) {
                e.stop();
                this.slide(-1);
            }.bind(this));
            
            $('btn-slide-right').observe('click', function(e) {
                e.stop();
                this.slide(1);
            }.bind(this));
            
            this._slider_elmt.select('li.item').each(function(a) {
            
                a.observe('click', function(e) {
                    this.switch_content(a);
                }.bind(this));
                
                if(Browser.isMSIE6) {

                    a.observe('mouseenter', function(e) {
                        a.addClassName('item-hover');
                    }.bind(this));
                    
                    a.observe('mouseleave', function(e) {
                        a.removeClassName('item-hover');
                    }.bind(this));

                }
                
            }.bind(this));
        
        },
        
        //
        //    slide
        //
        slide: function(_dir) {
        
            _dir = _dir * (-1);
        
            _current_left = parseInt(this._slider_elmt.getStyle('left'));
            _new_left = _current_left + (_dir * this._slide_step);
            
            _max_left = -((this._slider_item_count * (this._slide_item_rightmargin+this._slide_item_width)) - this._slide_item_rightmargin - 835);
            
            if(_new_left >= 0) { 
                _new_left = 0; 
                (Browser.isMSIE) ? $('btn-slide-left').hide() : $('btn-slide-left').fade({duration: 0.3});
            } else {
                (Browser.isMSIE) ? $('btn-slide-left').show() : $('btn-slide-left').appear({duration: 0.3});
            }
            
            if(_new_left <= _max_left) {
                _new_left = _max_left;
                (Browser.isMSIE) ? $('btn-slide-right').hide() : $('btn-slide-right').fade({duration: 0.3});
            } else {
                (Browser.isMSIE) ? $('btn-slide-right').show() : $('btn-slide-right').appear({duration: 0.3});
            }
        
            if(this._slide_effect) this._slide_effect.cancel();
            this._slide_effect = new Effect.Morph(this._slider_elmt, {
                duration: 0.4,
                transition: Effect.Transitions.Cubic,
                style: 'left: ' + _new_left + 'px;'
            });
        
        },
        
        //
        //    switch content
        //
        switch_content: function(_item) {
        
            this._slider_elmt.select('li.item-active').invoke('removeClassName', 'item-active');
            _item.addClassName('item-active');
            
            $$('div#history-stage-content div.content')[0].remove();
        
            _node = _item.down('div.content').cloneNode(true);
            _node.hide();
            $('history-stage-content').insert({top: _node});
            _node.appear({duration: 0.2});
        
        }
    
    
    });













    /**
    *
    *    PODCAST STAGE
    *
    **/
    
    c_podcast_stage = Class.create({
    
        //
        //    initialize
        //
        initialize: function() {
        
            // settings
            this._stage_elmt = $('podcast-stage');
            this._slider_elmt = this._stage_elmt.down('ul#podcast-nav-list');
            this._slide_step = 90;
            
            // system vars
            this._slider_items = this._slider_elmt.select('li.item');
            this._slider_item_count = this._slider_items.length;
            this._slider_current_item = 0;
            this._overlay_effect = false;
            this._is_sliding = false;
            
            // initialize
            this.prepare_dom();
            this.set_event_handlers();
        
        },
        
        //
        //    prepare dom
        //
        prepare_dom: function() {
        
            this._stage_elmt.down('div#podcast-nav').insert({
                top: '<a href="javascript:void(0)" id="btn-slide-left" style="display: none;">&nbsp;</a>',
                bottom: '<a href="javascript:void(0)" id="btn-slide-right">&nbsp;</a>'
            });
        
        },
        
        //
        //    set event handlers
        //
        set_event_handlers: function() {
        
            $('btn-slide-left').observe('click', function(e) {
                e.stop();
                this.slide(-1);
            }.bind(this));
            
            $('btn-slide-right').observe('click', function(e) {
                e.stop();
                this.slide(1);
            }.bind(this));
            
            this._slider_elmt.select('li.item').each(function(a) {
            
                a.observe('click', function(e) {
                    this.switch_content(a);
                }.bind(this));
                
                if(Browser.isMSIE6) {

                    a.observe('mouseenter', function(e) {
                        a.addClassName('item-hover');
                    }.bind(this));
                    
                    a.observe('mouseleave', function(e) {
                        a.removeClassName('item-hover');
                    }.bind(this));

                }
                
            }.bind(this));
        
        },
        
        //
        //    slide
        //
        slide: function(_dir) {
        
            if(!this._is_sliding) {
            
                this._is_sliding = true;

                _dir = _dir * (-1);

                _current_left = parseInt(this._slider_elmt.getStyle('top'));
                _new_left = _current_left + (_dir * this._slide_step);            
                _max_left = -((this._slider_item_count * this._slide_step) - this._slide_step*3);            
                _current_item = this._slider_current_item + (_dir * (-1));

                if(_new_left >= 0) { 
                    _new_left = 0; 
                    _current_item = 0;
                    (Browser.isMSIE) ? $('btn-slide-left').hide() : $('btn-slide-left').fade({duration: 0.3});
                } else {
                    (Browser.isMSIE) ? $('btn-slide-left').show() : $('btn-slide-left').appear({duration: 0.3});
                }

                if(_new_left <= _max_left) {
                    _new_left = _max_left;
                    _current_item = this._slider_item_count-1;
                    (Browser.isMSIE) ? $('btn-slide-right').hide() : $('btn-slide-right').fade({duration: 0.3});
                } else {
                    (Browser.isMSIE) ? $('btn-slide-right').show() : $('btn-slide-right').appear({duration: 0.3});
                }
                
                

                this._slider_current_item = _current_item;

                if(this._slide_effect) this._slide_effect.cancel();
                this._slide_effect = new Effect.Morph(this._slider_elmt, {
                    duration: 0.3,
                    transition: Effect.Transitions.Cubic,
                    style: 'top: ' + _new_left + 'px;',
                    afterFinish: function() {
                        this._is_sliding = false;
                    }.bind(this)
                });
                
            }
        
        },
        
        //
        //    switch content
        //
        switch_content: function(_item) {
        
            this._slider_elmt.select('li.item-active').invoke('removeClassName', 'item-active');
            _item.addClassName('item-active');
            
            $$('div#podcast-player div.content')[0].remove();
        
            _node = _item.down('div.content').cloneNode(true);
            _node.hide();
            $('podcast-player').insert({top: _node});
            _node.appear({duration: 0.2});
        
        }
    
    
    });



      














    /**
    *
    *    BELLA ITALIA STAGE
    *
    **/
    
    c_bella_italia_stage = Class.create({
    
        //
        //    initialize
        //
        initialize: function() {
        
            // settings
            this._stage_elmt = $('bella-italia-stage');
            this._slider_elmt = this._stage_elmt.down('ul#bella-italia-list');
            this._slide_step = 443;
            
            // system vars
            this._slider_items = this._slider_elmt.select('li.item');
            this._slider_item_count = this._slider_items.length;
            this._slider_current_item = 0;
            this._overlay_effect = false;
            this._is_sliding = false;
            
            // initialize
            this.prepare_dom();
            this.set_event_handlers();
            this.jump( Math.floor( Math.random() * this._slider_item_count ) );
            
        },
        
        //
        //    prepare dom
        //
        prepare_dom: function() {
        
            this._stage_elmt.down('div#bella-italia-slider').insert({
                top: '<a href="javascript:void(0)" id="btn-slide-left" style="display: none;">&nbsp;</a>',
                bottom: '<a href="javascript:void(0)" id="btn-slide-right">&nbsp;</a>'
            });
            
            $('wallpaper-list').select('a').each(function(a) {
                a.observe('click', function(e) {
                    e.stop();
                    this.jump(a.href.substring(a.href.indexOf('#')+1));
                }.bind(this));
            }.bind(this));
        
        },
        
        //
        //    set event handlers
        //
        set_event_handlers: function() {
        
            $('btn-slide-left').observe('click', function(e) {
                e.stop();
                this.slide(-1, false);
            }.bind(this));
            
            $('btn-slide-right').observe('click', function(e) {
                e.stop();
                this.slide(1, false);
            }.bind(this));
            
            this._slider_elmt.select('li.item').each(function(a, b) {

                a.observe('mouseenter', function(e) {
                    this.show_overlay(a);
                }.bind(this));

                a.observe('mouseleave', function(e) {
                    this.hide_overlay(a);
                }.bind(this));
                
                if(b == this._slider_item_count-1) {
                    a.addClassName('last-item');
                }
                
            }.bind(this));
        
        },
        
        //
        //    slide
        //
        slide: function(_dir, _index) {
        
            if(!this._is_sliding) {
            
                this._is_sliding = true;

                _dir = _dir * (-1);

                _current_left = parseInt(this._slider_elmt.getStyle('left'));
                _new_left = _current_left + (_dir * this._slide_step);            
                _max_left = -((this._slider_item_count * this._slide_step) - this._slide_step);            
                _current_item = this._slider_current_item + (_dir * (-1));
                
                this._slider_items[this._slider_current_item].down('div.overlay').hide();
                
                // slide to hash index?
                if(!_dir && !isNaN(_index)) {
                
                    _new_left = -(_index * this._slide_step);
                    _current_item = parseInt(_index);
                    if(_current_item < 0) _current_item = 0;
                    if(_current_item >= this._slider_item_count) _current_item = (this._slider_item_count-1);

                    this._slider_items[_current_item].down('div.overlay').show();
                
                }

                if(_new_left >= 0) { 
                    _new_left = 0; 
                    _current_item = 0;
                    (Browser.isMSIE) ? $('btn-slide-left').hide() : $('btn-slide-left').fade({duration: 0.3});
                } else {
                    (Browser.isMSIE) ? $('btn-slide-left').show() : $('btn-slide-left').appear({duration: 0.3});
                }

                if(_new_left <= _max_left) {
                    _new_left = _max_left;
                    _current_item = this._slider_item_count-1;
                    (Browser.isMSIE) ? $('btn-slide-right').hide() : $('btn-slide-right').fade({duration: 0.3});
                } else {
                    (Browser.isMSIE) ? $('btn-slide-right').show() : $('btn-slide-right').appear({duration: 0.3});
                }
                
                

                this._slider_current_item = _current_item;

                if(this._slide_effect) this._slide_effect.cancel();
                this._slide_effect = new Effect.Morph(this._slider_elmt, {
                    duration: 0.4,
                    transition: Effect.Transitions.Cubic,
                    style: 'left: ' + _new_left + 'px;',
                    afterFinish: function() {
                        this._is_sliding = false;
                    }.bind(this)
                });
                
            }
        
        },
        
        //
        //    show overlay
        //
        show_overlay: function(_item) {
        
            _pos = this._slider_items.indexOf(_item);

            if(_pos == this._slider_current_item) {
            
                if(this._overlay_effect) this._overlay_effect.cancel();
                this._overlay_effect = new Effect.Appear(_item.down('div.overlay'), {
                    duration: 0.2
                });
            
            }
        
        },
        
        //
        //    hide overlay
        //
        hide_overlay: function(_item) {
        
            _overlay = _item.down('div.overlay');
            
            if(_overlay.visible()) {
            
                if(this._overlay_effect) this._overlay_effect.cancel();
                this._overlay_effect = new Effect.Fade(_overlay, {
                    duration: 0.2
                });
            
            }
        
        },
        
        //
        //    jump to hash index
        //
        jump: function(_index) {
        
            this.slide(false, _index);
        
        }    
    
    });




















    /**
    *
    *    HASH NAVIGATION
    *
    **/
    c_location = Class.create({

        //
        //    initialize
        //
        initialize: function() {

            this.initlocation = this.getcleanlocation();
            //this.checkinterval = window.setInterval(function() { this.check(); }.bind(this), 100);
            this.check();
            this.handlers = new Hash();

        },

        //
        //    set
        //
        set: function(which) {

            window.location.href = this.initlocation = this.getcleanlocation() + '#' + which;

        },

        //
        //    get clean location
        //
        getcleanlocation: function() {

            return window.location.href.replace(/\#.+/,"");

        },

        //
        //    get identifier
        //
        getidentifier: function() {

            var locID;
            loc = window.location.href;
            hashPos = loc.indexOf('#');

            if(hashPos != -1) {

                tmpLocID = loc.substring((hashPos+1));
                locID = tmpLocID;

                }

            if(locID == '') {return false;}
            else {return locID;}

        },

        //
        //    check
        //
        check: function() {

            if(window.location.href != this.initlocation) {
                this.initlocation = window.location.href;
                this.call_function(this.getidentifier());
            }

        },
        
        //
        //    call function
        //
        call_function: function(_lid) {
        
            if($('bella-italia-stage')) _bella_italia_stage.jump(_lid);
        
        }

    });




















    /**
    *
    *    PIZZA STAGE
    *
    **/
    
    c_pizza_stage = Class.create({
    
        //
        //    initialize
        //
        initialize: function() {
        
            // settings
            this._pizza_stage_elmt = $('pizza-stage');
            
            this._item_width_medium = 143;
            this._item_width_max = 143;
            this._item_width_min = 95;
            this._item_padding_max = 252;
            this._img_width_max = 161;
            this._img_width_medium = 122;
            this._img_width_min = 82; 
            
            this._scale_effect_duration = 0.3;
            
            // system vars
            this._text_item = false;
            this._swap_is_running = false;
            this._current_item = false;
            this._last_body_classname = false;
            
            // initialize
            this.prepare_dom();
            this.set_event_handlers();
            this.set_zindex();
        
        },
        
        //
        //    prepare dom
        //
        prepare_dom: function() {
        
            this._pizza_stage_elmt.down('ul').insert({
                top: '<li class="text-item" style="display: none;">&nbsp;</li>'
            });
            
            this._text_item = this._pizza_stage_elmt.down('li.text-item');
            
            if(Browser.isMSIE6) {
            
                this._pizza_stage_elmt.select('div.image a img').each(function(a) {
                
                    a.src = a.src.replace(/\.png/, '.gif');
                
                });
            
            }
        
        },
        
        //
        //    set event handlers
        //
        set_event_handlers: function() {
        
            this._pizza_stage_elmt.select('li.item a').each(function(a, b) {
            
                a.observe('click', function(e) {
                    e.stop();
                    this.enlarge_pizza(e, a, b);
                }.bind(this));
            
                if(Browser.isMSIE6) {
                    a.observe('mouseover', function(e) {
                        a.down('strong').show();
                    });
                    a.observe('mouseout', function(e) {
                        a.down('strong').hide();
                    });
                }
            
            }.bind(this));
        
        },
        
        //
        //    set z-index
        //
        set_zindex: function() {
        
            _z = 7;
            this._pizza_stage_elmt.select('li.item').each(function(a) {

                a.setStyle('z-index: '+(_z--));
            
            });
        
        },
        
        //
        //    enlarge pizza
        //
        enlarge_pizza: function(e, elmt, index) {
        
            if(!this._swap_is_running) {
            
                if(elmt == this._current_item) {
                    this.reset_pizzas();
                }
                
                else {
                
                    this._current_item = elmt;
                    this._swap_is_running = true;

                    _li = elmt.up('li.item');
                    
                    this.set_background(elmt);

                    this.shrink_all_pizzas(_li);

                    // left or right?
                    _padding = (_li.hasClassName('left')) ? 'padding-right' : 'padding-left';

                    // li.item
                    new Effect.Morph(_li, {
                        style: 'width: '+this._item_width_max+'px; '+_padding+': '+this._item_padding_max+'px; padding-top: 0px; margin-top: -30px;',
                        duration: this._scale_effect_duration
                    });

                    // li.item img
                    new Effect.Morph(_li.down('img'), {
                        style: 'width: '+this._img_width_max+'px;',
                        duration: this._scale_effect_duration,
                        afterFinish: function() {
                            this._swap_is_running = false;
                        }.bind(this)
                    });

                    // copy and show text contents
                    this.show_text_contents(_li, index);
                    
                }
                
            }
        
        },
        
        //
        //    shrink all pizzas
        //
        shrink_all_pizzas: function(except) {
        
            this._pizza_stage_elmt.select('li.item').each(function(a) {
            
                if(a != except) {
                
                    // li.item
                    new Effect.Morph(a, {
                        style: 'width: '+this._item_width_min+'px; padding-left: 0px; padding-right: 0px; padding-top: 30px; margin-top: 0px;',
                        duration: this._scale_effect_duration
                    });
                    
                    // li.item img
                    new Effect.Morph(a.down('img'), {
                        style: 'width: '+this._img_width_min+'px;',
                        duration: this._scale_effect_duration
                    });
                
                }
            
            }.bind(this));
        
        },
        
        //
        //    show text contents
        //
        show_text_contents: function(_item, index) {

            _left_offset = (index > 2) ? (index * this._item_width_min) : ((index * this._item_width_min) + this._item_width_max - 66);
        
            this._text_item.hide();
            this._text_item.id = 'text-item-'+_item.id;

            this._text_item.update(_item.down('div.text').innerHTML);
            this._text_item.appear({duration: this._scale_effect_duration});
            new Effect.Morph(this._text_item, {

                style: 'left: '+_left_offset+'px;',
                duration: this._scale_effect_duration

            });
        
        },
        
        //
        //    reset pizzas
        //
        reset_pizzas: function() {
        
            if(!this._swap_is_running) {
            
                this._swap_is_running = true;
                
                this.set_background(false);
                
                this._pizza_stage_elmt.select('li.item').each(function(a) {

                    // li.item
                    new Effect.Morph(a, {
                        style: 'width: '+this._item_width_medium+'px; padding-left: 0px; padding-right: 0px; padding-top: 0px; margin-top: 0px;',
                        duration: this._scale_effect_duration,
                        afterFinish: function() {
                            this._swap_is_running = false;
                            this._current_item = false;
                        }.bind(this)
                    });

                    // li.item img
                    new Effect.Morph(a.down('img'), {
                        style: 'width: '+this._img_width_medium+'px;',
                        duration: this._scale_effect_duration
                    });

                }.bind(this));
                
                this._text_item.fade({
                    duration: this._scale_effect_duration,
                    afterFinish: function(a) {
                        a.element.update('');
                    }
                });
            
            }
        
        },
        
        //
        //    set background
        //
        set_background: function(_item) {
        
            // reset background
            $$('body')[0].removeClassName(this._last_body_classname);
            
            // set background
            if(_item) {
            
                _classname = _item.up('li.item').id;
                this._last_body_classname = _classname;
                $$('body')[0].addClassName(_classname);
            
            }
        
        }
    
    
    });





    /**
    *
    *    PIZZA STAGE NEU
    *
    **/
    
    c_pizza_stage_7 = Class.create({
    
        //
        //    initialize
        //
        initialize: function() {
        
            // settings
            this._pizza_stage_elmt = $('pizza-stage-7');
            /*
            this._item_width_medium = 143;
            this._item_width_max = 143;
            this._item_width_min = 95;
            this._item_padding_max = 252;
            this._img_width_max = 161;
            this._img_width_medium = 122;
            this._img_width_min = 82;
            */
            this._item_width_medium = 120;
            this._item_width_max = 143;
            this._item_width_min = 75;
            this._item_padding_max = 252;
            this._img_width_max = 161;
            this._img_width_medium = 110;
            this._img_width_min = 72; 
            
            this._scale_effect_duration = 0.3;
            
            // system vars
            this._text_item = false;
            this._swap_is_running = false;
            this._current_item = false;
            this._last_body_classname = false;
            
            // initialize
            this.prepare_dom();
            this.set_event_handlers();
            this.set_zindex();
            this.reset_pizzas();
            
            // preload images
            _leftImage = new Image();
            _leftImage.src = "http://www.tradizionale.de/fileadmin/templates/imgs/sorten/pizza-funghi-left.png";
            _rightImage = new Image();
            _rightImage.src = "http://www.tradizionale.de/fileadmin/templates/imgs/sorten/pizza-funghi-right.png";

        },
        
        //
        //    prepare dom
        //
        prepare_dom: function() {
        
            this._pizza_stage_elmt.down('ul').insert({
                top: '<li class="text-item" style="display: none;">&nbsp;</li>'
            });
            
            this._text_item = this._pizza_stage_elmt.down('li.text-item');
            
            if(Browser.isMSIE6) {
            
                this._pizza_stage_elmt.select('div.image a img').each(function(a) {
                
                    a.src = a.src.replace(/\.png/, '.gif');
                
                });
            
            }
        
        },
        
        //
        //    set event handlers
        //
        set_event_handlers: function() {
        
            this._pizza_stage_elmt.select('li.item a').each(function(a, b) {
            
                a.observe('click', function(e) {
                    e.stop();
                    this.enlarge_pizza(e, a, b);
                }.bind(this));
            
                if(Browser.isMSIE6) {
                    a.observe('mouseover', function(e) {
                        a.down('strong').show();
                    });
                    a.observe('mouseout', function(e) {
                        a.down('strong').hide();
                    });
                }
            
            }.bind(this));
        
        },
        
        //
        //    set z-index
        //
        set_zindex: function() {

            _sz = [1,3,5,7,6,4,2];
            this._pizza_stage_elmt.select('li.item').each(function(a, i) {
                _z = _sz.shift();
                a.setStyle('z-index: '+ _z);
            
            });
        
        },
        
        //
        //    enlarge pizza
        //
        enlarge_pizza: function(e, elmt, index) {
        
            if(!this._swap_is_running) {
            
                if(elmt == this._current_item) {
                    this.reset_pizzas();
                }
                
                else {
                    this.set_zindex();

                    this._current_item = elmt;
                    this._swap_is_running = true;

                    _li = elmt.up('li.item');

                    // set z-index for overlapping
                    _li.setStyle('z-index:22;');
                    $$('.text-item')[0].setStyle('z-index:20;');

                    this.set_background(elmt);

                    // left or right?
                    _padding = (_li.hasClassName('left')) ? 'padding-right' : 'padding-left';

                    // li.item
                    if(index == 3){
                    
                        $$('#pizza-funghi .image img')[0].src = "http://www.tradizionale.de/fileadmin/templates/imgs/sorten/pizza-funghi.png";

                        // switch middle image
                        new Effect.Morph(_li, {
                            style: 'width: '+ this._item_width_max +'px; '+_padding+': '+this._item_padding_max+'px; padding-top: 0px; margin-top: -18px;margin-left: -30px;',
                            duration: this._scale_effect_duration
                        });
                        // li.item img
                        new Effect.Morph(_li.down('img'), {
                            style: 'width: 239px;margin-left:0px;margin-top:-27px;',
                            duration: this._scale_effect_duration,
                            afterFinish: function() {
                                this._swap_is_running = false;
                            }.bind(this)
                        });
                    }else {
                        new Effect.Morph(_li, { 
                            style: 'width: '+this._item_width_max+'px; '+_padding+': '+this._item_padding_max+'px; padding-top: 0px; margin-top: -30px;',
                            duration: this._scale_effect_duration
                        });
                        // li.item img
                        new Effect.Morph(_li.down('img'), {
                            style: 'width: '+this._img_width_max+'px;margin-left:0px;margin-top:0px;',
                            duration: this._scale_effect_duration,
                            afterFinish: function() {
                                this._swap_is_running = false;
                            }.bind(this)
                        });
                        
                        // switch middle image
                        if(index > 3) {
                            $$('#pizza-funghi .image img')[0].src = "http://www.tradizionale.de/fileadmin/templates/imgs/sorten/pizza-funghi-left.png";
                        }else {
                            $$('#pizza-funghi .image img')[0].src = "http://www.tradizionale.de/fileadmin/templates/imgs/sorten/pizza-funghi-right.png";
                            
                        }
                    }


                    this.shrink_all_pizzas(_li);
                    
                    // copy and show text contents
                    this.show_text_contents(_li, index);
                    
                }
                
            }
        
        },
        
        //
        //    shrink all pizzas
        //
        shrink_all_pizzas: function(except) {

            this._pizza_stage_elmt.select('li.item').each(function(a, i) {
                if(a != except) {
                
                    /*
                    if(i == 3) {
                        // li.item
                        new Effect.Morph(a, {
                            //style: 'width: '+this._item_width_min+'px; padding-left: 0px; padding-right: 0px; padding-top: 30px; margin-top: -69px;margin-left:-123px;',
                            style: 'width: '+this._item_width_min+'px; padding-left: 0px; padding-right: 0px; padding-top: 30px; margin-top: 16px;margin-left:45px;',
                            duration: this._scale_effect_duration
                        });
                    
                        // li.item img
                        new Effect.Morph(a.down('img'), {
                            //style: 'width: 239px;',
                            style: 'width: 125px;',
                            duration: this._scale_effect_duration
                        });                        
                    }else { 
                    */
                        // li.item
                        new Effect.Morph(a, {
                            style: 'width: '+this._item_width_min+'px; padding-left: 0px; padding-right: 0px; padding-top: 30px; margin-top: 0px; margin-left: 0px;',
                            duration: this._scale_effect_duration
                        });
                    
                        // li.item img
                        new Effect.Morph(a.down('img'), {
                            style: 'width: '+this._img_width_min+'px;margin-left:0px;margin-top:0px;',
                            duration: this._scale_effect_duration
                        });
                    //}
                
                }
            
            }.bind(this));
        
        },
        
        //
        //    show text contents
        //
        show_text_contents: function(_item, index) {

            _left_offset = (index > 3) ? (index * this._item_width_min) : ((index * this._item_width_min) + this._item_width_max - 66);
            if(index == 3) {
                _left_offset = 320;
            }
        
            this._text_item.hide();
            this._text_item.id = 'text-item-'+_item.id;

            this._text_item.update(_item.down('div.text').innerHTML);
            this._text_item.appear({duration: this._scale_effect_duration});
            new Effect.Morph(this._text_item, {

                style: 'left: '+_left_offset+'px;',
                duration: this._scale_effect_duration

            });
        
        },
        
        //
        //    reset pizzas
        //
        reset_pizzas: function() {
        
            if(!this._swap_is_running) {
            
                this._swap_is_running = true;
                
                this.set_background(false);

                $$('#pizza-funghi .image img')[0].src = "http://www.tradizionale.de/fileadmin/templates/imgs/sorten/pizza-funghi.png";
                
                this.set_zindex();
                
                this._pizza_stage_elmt.select('li.item').each(function(a, index) {


                    if(index == 3) {
                        // li.item
                        new Effect.Morph(a, {
                            style: 'width: '+this._item_width_medium+'px; padding-left: 0px; padding-right: 0px; padding-top: 0px; margin-top: 0px; margin-left: 0px;',
                            duration: this._scale_effect_duration,
                            afterFinish: function() {
                                this._swap_is_running = false;
                                this._current_item = false;
                            }.bind(this)
                        });

                        // li.item img
                        new Effect.Morph(a.down('img'), {
                            style: 'width: 205px;margin-left: -45px;margin-top: -26px;',
                            duration: this._scale_effect_duration
                        });
                    }else { 
                        // li.item
                        new Effect.Morph(a, {
                            style: 'width: '+this._item_width_medium+'px; padding-left: 0px; padding-right: 0px; padding-top: 0px; margin-top: 0px; margin-left: 0px;',
                            duration: this._scale_effect_duration,
                            afterFinish: function() {
                                this._swap_is_running = false;
                                this._current_item = false;
                            }.bind(this)
                        });

                        // li.item img
                        new Effect.Morph(a.down('img'), {
                            style: 'width: '+this._img_width_medium+'px;margin-left:0px;margin-top:0px;',
                            duration: this._scale_effect_duration
                        });
                        
                    }

                }.bind(this));
                
                this._text_item.fade({
                    duration: this._scale_effect_duration,
                    afterFinish: function(a) {
                        a.element.update('');
                    }
                });
            
            }
        
        },
        
        //
        //    set background
        //
        set_background: function(_item) {
        
            // reset background
            $$('body')[0].removeClassName(this._last_body_classname);
            
            // set background
            if(_item) {
            
                _classname = _item.up('li.item').id;
                this._last_body_classname = _classname;
                $$('body')[0].addClassName(_classname);
            
            }
        
        }
    
    
    });









    /**
    *
    *    HOME SLIDESHOW
    *
    **/
    
    c_pizza_slideshow = Class.create({
    
        //
        //    initialize
        //
        initialize: function() {

            // settings
            this._slide_duration = 2;
            this._interval_duration = 5;
            this._img_elmts = $$('.slideshow-images .item'); 
            
            // system variables
            this._zindex = 1;
            this._current_img_index = -1;
            this._img_count = this._img_elmts.length;
            this._text_was_changed = false;
            
            // initialize
            this.prepare_dom();
                 this.start_slideshow();
                 
        }, 
        
        //
        //    prepare dom
        //
        prepare_dom: function() {
        
            this._img_elmts.invoke('setOpacity', 0);
        
        },
        
        //
        //    start slideshow
        //
        start_slideshow: function() {
        
            window.setTimeout(function() {
            
                this.slide_image();
            
                new PeriodicalExecuter(function(pe) {
                    this.slide_image();
                }.bind(this), this._interval_duration);
                
            }.bind(this), 500);
        
        },
        
        //
        //    slide image
        //
        slide_image: function() {
        
            _next_index = (this._current_img_index+1 <= this._img_count-1) ? this._current_img_index+1 : 0;
            this._current_img_index = _next_index;
            this._zindex++;
            
            _img = this._img_elmts[_next_index];
            _img.setOpacity(0);
            _img.setStyle('z-index: '+this._zindex);
            _img.appear({
                duration: this._slide_duration
            });
            
            /*
            if(this._current_img_index == 4 && !this._text_was_changed) {
                $('slideshow').down('p.first').hide();
                if($('slideshow').down('p.second')) {
                    $('slideshow').down('p.second').appear({
                        duration: this._slide_duration
                    });
                }
                this._text_was_changed = true;
            }
            if(this._current_img_index == 0 && this._text_was_changed) {
                $('slideshow').down('p.second').hide();
                $('slideshow').down('p.first').appear({
                    duration: this._slide_duration
                });
                this._text_was_changed = false;
            }
            */
        
        }
        
    }); 


   
    /**
    *
    *    META LINKS
    *   make meta links strict valid external targets
    *
    **/
    
    c_meta_links = Class.create({
    
        //
        //    initialize
        //
        initialize: function()
        {                                                                                                                
             this.addBehaviour();
        },  
        
        addBehaviour: function()
        {
            // onclick="window.open(this.href, 'datenschutz', 'width=800, height=500, scrollbars=yes, top=100, left=100'); return false;"

            $$('#footer p.left a').each( function( element ) 
            {
                element.observe('click', function(e) {
                    e.stop();
                               
                    if( this.className == 'external') {        
                         //window.open( this.href );//, 'external', 'menubar=yes,statusbar=yes,toolbar=yes,scrollbars=yes, top=100, left=100');
                    }else {                                                                      
                        window.open( this.href, 'datenschutz', 'width=800, height=500, scrollbars=yes, top=100, left=100');                                                          
                    }                                                                                                 
                });   
            });

            $$('a.btn-pizzabus').each( function( element ) 
            {
                element.observe('click', function(e) {
                    e.stop();                                   
                    window.open( this.href, 'pizzabus', 'width=800, height=600, scrollbars=yes, top=100, left=100');                                                                                                                                                          
                });   
            });
            $$('.facebook a').each( function( element ) 
            {
                element.observe('click', function(e) {
                    e.stop();                                   
                    window.open( this.href ); //, 'facebook', 'menubar=yes,statusbar=yes,toolbar=yes,scrollbars=yes, top=100, left=100')                                                                                                                                                        
                });   
            });  
            
                                                                     
        }
        
        
    }); 




    /**
    *
    *    BROWSER DETECTION
    *
    **/

    var Browser = {
        detect: function() {
            var UA = navigator.userAgent;
            this.isKHTML = /Konqueror|Safari|KHTML/.test(UA);
            this.isGecko = (/Gecko/.test(UA) && !this.isKHTML);
            this.isOpera = /Opera/.test(UA);
            this.isMSIE = (/MSIE/.test(UA) && !this.isOpera);
            this.isMSIE7 = this.isMSIE && !(/MSIE 6\./.test(UA) && !this.isOpera);
            this.isMSIE6 = this.isMSIE && !this.isMSIE7;
            this.isIPHONE = /iPhone|iPod/.test(UA);
        }
    }
    Browser.detect();





















    /**
    *
    *    ON DOM LOADED
    *
    **/
    
    document.observe('dom:loaded', function() {

        if($('pizza-stage')) {_pizza_stage = new c_pizza_stage();}                                                                    

        if($('pizza-stage-7')) {_pizza_stage = new c_pizza_stage_7();}

        if($('slideshow')) {_pizza_slideshow = new c_pizza_slideshow();}

        if($('history-stage')) {_history_stage = new c_history_stage();}

        if($('bella-italia-stage')) {_bella_italia_stage = new c_bella_italia_stage();}

        if($('footer')) {_meta_links = new c_meta_links();}

        _location = new c_location();

        /*if($('gewinnspiel')) {
            $('gewinnspiel').observe('click', function(e) {
                e.stop();
                window.open( this.href, 'gewinnspiel', 'width=796, height=468, scrollbars=yes, top=100, left=100');                                                                                                                                                         
            });
        }*/
        if($('gewinnspiel_layer_link')) {
            $('gewinnspiel_layer_link').observe('click', function(e) {
                e.stop();
                window.open( this.href, 'gewinnspiel', 'width=796, height=468, scrollbars=yes, top=100, left=100');                                                                                                                                                         
            });
        }
        

        $$('.external').each(function(element) {
            element.observe('click', function(event) {
                event.stop();                                   
                window.open( this.href );                                                                                                                                                         
            });
        });

        
        
        
        
        
        
        
        $$('.has-placeholder').each(function(a) {
          
          a.observe('focus', function(e) { 
            if(a.value == a.readAttribute('data-placeholder')) {
              a.value = '';
            }
          });
          
          a.observe('blur', function(e) {
            if(a.value == '') {
              a.value = a.readAttribute('data-placeholder');
            }
          });
          
          if(a.value == '') {a.value = a.readAttribute('data-placeholder');}
          
        });
        
        

        $$('.btn-gewinnspiel').each(function(a) {
             a.observe('click', function(e) {
                 e.stop();
                 var dimmer  = new Element('div', { 'class': 'gewinnspiel-dimmer' }).update("&nbsp;");
                 var overlay = new Element('div', { 'class': 'gewinnspiel-overlay' });
                 var loading = new Element('div', { 'class': 'loading' });
                 $('body').appendChild(dimmer);
                 $('body').appendChild(overlay);
                 overlay.appendChild(loading);   

                 // track click
                 s          = s_gi('droetkersteinofentradizionale');
                 s.prop22   = (a.href.indexOf('id=35') == -1) ? 'tradizionaleipad2' : 'tradizionaleipad1';
                 s.t();

                 new Ajax.Request(a.href + '&type=777',{
                     method:'get',
                     onSuccess: function(transport){
                         var response = transport.responseText || "no response text";
                         $$('.gewinnspiel-overlay').first().update(response);
                         overlayBehaviour();
                         ajaxFormBehaviour();
                         if($$('.gewinnspiel-overlay').length > 0) {
                             $$('.gewinnspiel-overlay').first().scrollTo();
                         }
                           
                        if($$('.tx-srfreecap-pi2-image').length > 0) {                           
                            var captchaKey = $$('.tx-srfreecap-pi2-image').first().id.substr(-5);
                            newFreeCap(captchaKey, '');
                            $$('.tx-srfreecap-pi2-image').first().show();
                        }
                     },
                     onFailure: function(){
                         //alert('Something went wrong...')
                     }
                 });
             });
         });

        function ajaxFormBehaviour() {              
            Event.observe('form-code', 'submit', function(event) {

                if($$('.gewinnspiel-overlay').length > 0) {
                    $$('.gewinnspiel-overlay').first().scrollTo();
                }

                $('form-code').request({
                    onFailure: function() {
                        //alert("ajax form fehler");
                    },
                    onSuccess: function(t) {
                        //alert(t.responseText); 
                        $$('.gewinnspiel-overlay').first().update(t.responseText);
                        overlayBehaviour();
                        ajaxFormBehaviour(); 
                        if($$('.tx-srfreecap-pi2-image').length > 0) {                           
                            var captchaKey = $$('.tx-srfreecap-pi2-image').first().id.substr(-5);
                            newFreeCap(captchaKey, '');
                            $$('.tx-srfreecap-pi2-image').first().show();
                        }                                        
                    }
                });

                Event.stop(event); // stop the form from submitting 
            }); 
        }

        function overlayBehaviour() {
            $$('.btn-gewinnspiel-close, .gewinnspiel-dimmer').each(function(a) {
              a.stopObserving();
              a.observe('click', function(e) {
                e.stop();
                $$('.gewinnspiel-overlay').first().remove();
                $$('.gewinnspiel-dimmer').first().remove();
              });
          
            });            
        }
        
        overlayBehaviour();
        
        
        
        

    });
    
    
 
 /***************************************************************
*  Copyright notice
*
*  (c) 2007-2011 Stanislas Rolland <typo3(arobas)sjbr.ca>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*  A copy is found in the textfile GPL.txt and important notices to the license
*  from the author is found in LICENSE.txt distributed with these scripts.
*
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/*
 * Javascript functions for TYPO3 plugin freeCap (sr_freecap)
 *
 * TYPO3 CVS ID: $Id$
 */

/*
 * Loads a new freeCap image
 *
 * @param	string		id: identifier used to uniiquely identify the image
 *
 * @return	void
 */
function newFreeCap(id, noImageMessage) {
	if (document.getElementById) {
			// extract image name from image source (i.e. cut off ?randomness)
		var theImage = document.getElementById('tx_srfreecap_pi2_captcha_image_' + id);
		var parts = theImage.src.split('&set');
		theImage.src = parts[0] + '&set=' + Math.round(Math.random()*100000);
	} else {
		alert(noImageMessage ? noImageMessage : 'Sorry, we cannot autoreload a new image. Submit the form and a new image will be loaded.');
	}
}

/*
 * Plays the audio captcha
 *
 * @param	string		id: identifier used to uniquely identify the wav file
 * @param	string		wavURL: url of the wave file generating script
 *
 * @return	void
 *
 * Note: In order for this to work with IE8, [SYS][cookieDomain] must be set using the TYPO3 Install Tool
 */
function playCaptcha(id, wavURL, noPlayMessage) {
	if (document.getElementById) {
		var theAudio = document.getElementById("tx_srfreecap_pi2_captcha_playAudio_"+id);
		var wavURLForOpera = wavURL + "&nocache=" + Math.random();
		while (theAudio.firstChild) {
			theAudio.removeChild(theAudio.firstChild);
		}
		var objectElement = document.createElement("object");
		objectElement.setAttribute("id", "tx_srfreecap_pi2_captcha_playAudio_object"+id);
		objectElement.setAttribute("type", "audio/x-wav");
		objectElement.setAttribute("data", wavURLForOpera);
		objectElement.setAttribute("height", 0);
		objectElement.setAttribute("width", 0);
		try {
			objectElement.innerHTML = '<a href="' + wavURLForOpera + '">' + (noPlayMessage ? noPlayMessage : 'Sorry, we cannot play the word of the image.') + '</a>';
		} catch (e) {
				// IE8 does not allow any element other than param as child of object
			objectElement.setAttribute("altHTML", '<a href="' + wavURLForOpera + '">' + (noPlayMessage ? noPlayMessage : 'Sorry, we cannot play the word of the image.') + '</a>');
		}
		theAudio.appendChild(objectElement);
			// IE8 needs a delay before the param children are appended...
		window.setTimeout("addAudioCaptchaParams('" + id + "');", 50);
	} else {
		alert(noPlayMessage ? noPlayMessage : "Sorry, we cannot play the word of the image.");
	}
}

function addAudioCaptchaParams(id) {
	var theAudio = document.getElementById("tx_srfreecap_pi2_captcha_playAudio_"+id);
	var objectElement = theAudio.firstChild;
	var url = objectElement.getAttribute("data");
	var parameters = {
		"type"		: "audio/x-wav",
		"filename"	: url,
		"src"		: url,
		"autoplay"	: true,
		"autoStart"	: 1,
		"hidden"	: true,
		"controller"	: false
	};
	for (var parameter in parameters) {
		if (parameters.hasOwnProperty(parameter)) {
			var paramElement = document.createElement("param");
			paramElement.setAttribute("value", parameters[parameter]);
			paramElement.setAttribute("name", parameter);
			paramElement = objectElement.appendChild(paramElement);
		}
	}
}

   
    
    
