var jQueryjQuery = jQuery.fn;

jQueryjQuery.extend({
  SplitID : function()
  {
    return this.attr('id').split('-').pop();
  },

  Slideshow : {
    Ready : function()
    {
      jQuery('div.tmpSlideshowControl')
        .hover(
          function() {
            jQuery(this).addClass('tmpSlideshowControlOn');
          },
          function() {
            jQuery(this).removeClass('tmpSlideshowControlOn');
          }
        )
        .click(
          function() {
            jQueryjQuery.Slideshow.Interrupted = true;

            jQuery('div.tmpSlide').hide();
            jQuery('div.tmpSlideshowControl').removeClass('tmpSlideshowControlActive');

            jQuery('div#tmpSlide-' + jQuery(this).SplitID()).show()
            jQuery(this).addClass('tmpSlideshowControlActive');
          }
        );

      this.Counter = 1;
      this.Interrupted = false;

      this.Transition();
    },

    Transition : function()
    {
      if (this.Interrupted) {
        return;
      }

      this.Last = this.Counter - 1;

      if (this.Last < 1) {
        this.Last = 4;
      }

      jQuery('div#tmpSlide-' + this.Last).fadeOut(
        'slow',
        function() {
          jQuery('div#tmpSlideshowControl-' + jQueryjQuery.Slideshow.Last).removeClass('tmpSlideshowControlActive');
          jQuery('div#tmpSlideshowControl-' + jQueryjQuery.Slideshow.Counter).addClass('tmpSlideshowControlActive');
          jQuery('div#tmpSlide-' + jQueryjQuery.Slideshow.Counter).fadeIn('fast');

          jQueryjQuery.Slideshow.Counter++;

          if (jQueryjQuery.Slideshow.Counter > 4) {
            jQueryjQuery.Slideshow.Counter = 1;
          }

          setTimeout('jQueryjQuery.Slideshow.Transition();', 5000);
        }
      );
    }
  }
});

jQuery(document).ready(
  function() {
    jQueryjQuery.Slideshow.Ready();
  }
);
