var gutmannNavi = {};

window.addEvent('domready', function(){

    var citychooser = $$('.citychooser')[0];

    if( citychooser ){
        citychooser.set('html', $('cityText').get('html'));

        var linkChooser = new Element('div', {
            style: 'position: absolute; left: 0px; bottom: 0px; height: 29px; width: 136px; cursor: pointer;'
        }).inject( citychooser );

        window.openedChooser = 0;

        linkChooser.addEvent('click', function(){
            if( window.openedChooser == 0 ){
                window.openedChooser = 1;
                citychooser.morph({
                    width: 700,
                    height: 220
                });
                citychooser.setStyle('background-image', 'url(/inc/template/th_gutmann/images/citychooserClose.jpg)');
            } else {
                window.openedChooser = 0;
                citychooser.morph({
                    width: 136,
                    height: 35
                });
                citychooser.setStyle('background-image', 'url(/inc/template/th_gutmann/images/citychooserOpen.jpg)');
            }
        });
    }

    
    $$('div.navi a.hasLinks').addEvent('mouseover', function(){
        var subnavi = this.getNext();
        this.store('allowToFadeout', false);
        if( subnavi.getStyle('display') == 'block' ) return;
        this.store('subnavi', subnavi);
        var pos = this.getPosition( this.getParent() );
        subnavi.setStyle('display', 'block');
        subnavi.setStyles({
            'top': pos.y-2
        });
        var _this = this;
    });

    $$('div.navi a.hasLinks').each(function(_this){
        var subnavi = _this.getNext();
        subnavi.addEvent('mouseout', function(){
            _this.fireEvent('mouseout');
        });
        subnavi.addEvent('mouseover', function(){
            _this.fireEvent('mouseover');
        });
    });

    $$('div.navi a.hasLinks').addEvent('mouseout', function(){
        this.store('allowToFadeout', true);
        var _this = this;
        (function(){
            if( _this.retrieve('allowToFadeout') )
                _this.retrieve('subnavi').setStyle('display', 'none');
        }).delay(50);
    });

});

gutmannNavi.over = function( e ){
    
}
