(function($){

var Slider = {
  Slideshow : {
    Ready : function()
    {
      $('div.tmpSlide').hide();
      $('div.tmpSlideshowControl')
        .hover(
          function() {
            $(this).addClass('tmpSlideshowControlOn');
          },
          function() {
            $(this).removeClass('tmpSlideshowControlOn');
          }
        )
        .click(
          function() {
            Slider.Slideshow.Interrupted = true;

            $('div.tmpSlide').hide();
            $('div#tmpSlideshowControl-1').removeClass('tmpSlideshowControlActive');			
            $('div#tmpSlideshowControl-2').removeClass('tmpSlideshowControlActive');			
            $('div#tmpSlideshowControl-3').removeClass('tmpSlideshowControlActive');			
            $('div#tmpSlide-' + $(this).attr('id').split('-').pop()).show()
            $(this).addClass('tmpSlideshowControlActive');
          }
        );

      this.Counter = 1;
      this.Interrupted = false;

      this.Transition();
    },
    SplitID : function()
    {
      return this.attr('id').split('-').pop();
    },
    Transition : function()
    {
      if (this.Interrupted) {
        return;
      }

      this.Last = this.Counter - 1;

      if (this.Last < 1) {
        this.Last = 3;
      }
      $('div#tmpSlide-' + this.Last).fadeOut('slow',function() {
          
          $('div#tmpSlideshowControl-' + Slider.Slideshow.Last).removeClass('tmpSlideshowControlActive');
          $('div#tmpSlideshowControl-' + Slider.Slideshow.Counter).addClass('tmpSlideshowControlActive');
          $('div#tmpSlide-' + Slider.Slideshow.Counter).fadeIn('slow');
          Slider.Slideshow.Counter++;

          if (Slider.Slideshow.Counter > 3) {
            Slider.Slideshow.Counter = 1;
          }
          setTimeout(function(){ Slider.Slideshow.Transition();}, 5000);
        }
      );
    }
  }
};

$(document).ready(
  function() {
    Slider.Slideshow.Ready();
    
  }
);
})(jQuery);      

