window.addEvent('domready',function() {
  
  // Sliding TOP navigation from Fabian Beiner
  if ($('.current_page_item')) {
    var currActive = $('.current_page_item').setStyle('background-position', '0 -40px');
  }
  var active = new Fx.Tween(currActive, {
    duration: 200,
    link: 'cancel'
  });
  $$('div#navigation li a').each(function(el) {
    if (el.get('class') != 'current_page_item') {
      var tweenEnter = new Fx.Tween(el, {
          duration: 200,
          link: 'cancel'
      });
      var tweenLeave = new Fx.Tween(el, {
          duration: 200,
          link: 'cancel'
      });
      el.setStyle('background-position', '0 0').addEvents({
        'mouseenter': function(e) {
          if (currActive) active.start('background-position', '0 0');
          tweenEnter.start('background-position', '0 -40px');
        },
        'mouseleave': function(e) {
          if (currActive) active.start('background-position', '0 -40px');
          tweenLeave.start('background-position', '0 0');
        }
      });
    }
  });
  
  // SmoothScroll
  new SmoothScroll({ duration: 1000 })

  // Suchfeld ein-/ausblenden
  var suchenbox = new Fx.Slide('suchenbox').hide();
  $('toggle').addEvent('click', function(el){
    el.stop();
    suchenbox.toggle();
    if ($('toggle').get('class')!='aktiv') {
      $('toggle').addClass('aktiv');
    } else {
      $('toggle').removeClass('aktiv');
    }
  });
  
});