/*
 * Image rotator by Drawain
 */
$().ready(function() {
  (function() {
      var timer = 5000;    // time between tweens
      var fadeTime = 500;  // time to fade out/in an image
      var position = 0;    // the start image by the index
  
      var $images = $("#header div.headerPics img")
          .hide()
          .eq(position)
              .show()
          .end();
  
      var rotate = function() {
          var $toHide = $images.eq(position);
  
          position++;
          var $toShow = $images.eq(position);
          if (!$toShow.length) {
              $toShow = $images.eq(0);
              position = 0;
          }
  
          $toHide.fadeOut(fadeTime, "swing");
          $toShow.fadeIn(fadeTime, "swing");
          setTimeout(rotate,timer);        
      }
  
      setTimeout(rotate,timer);
      
  })();
});

$().ready(function() {
  (function() {
     
      var $menu = $('#leftContent div.leftMenu');
      if (!$menu || !$menu.length) return;

      $menu.removeClass('menuSlider');

      var $links = $menu.find('a');

      $links.each(function(){
          var $this = $(this);
          $this.before($('<div class="menuSliderBackground"></div>').html($this.html()))
              .css({ left: '-10px', opacity: 0 })
              .hover(
                  function() {
                      var $this = $(this);
                      $this.stop().animate({ left: '0', opacity: 1 }, 200, "swing", function(){ if ($.browser == 'msie') $(this).get(0).style.removeAttribute('filter'); });
                      $this.prev().stop().animate({ left: '5px', opacity: 0 }, 200, "swing");                     
                  },
                  function() {
                      var $this = $(this);
                      $this.stop().animate({ left: '-10px', opacity: 0 }, 200, "swing");
                      $this.prev().stop().animate({ left: '0', opacity: 1 }, 200, "swing", function(){ if ($.browser == 'msie') $(this).get(0).style.removeAttribute('filter'); });
                  }
              );                
      });
  
  })();
});
