var $$ = $.fn;

$$.extend({
  SplitID : function()
  {
    return this.attr('id').split('-').pop();
  },

  Slideshow : {
    Ready : function()
    {
      /*$('div.tmpSlideshowControl')
        .hover(
          function() {
            $(this).addClass('tmpSlideshowControlOn');
          },
          function() {
            $(this).removeClass('tmpSlideshowControlOn');
          }
        )
        .click(
          function() {
            $$.Slideshow.Interrupted = true;

            $('div.tmpSlide').hide();
            $('div.tmpSlideshowControl').removeClass('tmpSlideshowControlActive');

            $('div#tmpSlide-' + $(this).SplitID()).show()
            $(this).addClass('tmpSlideshowControlActive');
          }
        );*/

      this.Counter = 6;
      this.Interrupted = false;

      this.Transition();
    },

    Transition : function()
    {
      if (this.Interrupted) {
        return;
      }

      //this.Last = this.Counter - 1;
	  this.Next =  $$.Slideshow.Counter + 1;
	  
		if (this.Next > 6) {
        this.Next = 1;
      }
	  
      /*if (this.Last < 1) {
        this.Last = 6;
      }*/
		 
	  $('div#tmpSlide-' + $$.Slideshow.Counter).css({'z-index' : '100', display:'block'});
      $('div#tmpSlide-' + this.Next).css({display:'block'});
		
	  $('div#tmpSlide-' + $$.Slideshow.Counter).fadeOut(
        'slow',
        function() {
          //$('div#tmpSlideshowControl-' + $$.Slideshow.Last).removeClass('tmpSlideshowControlActive');
          //$('div#tmpSlideshowControl-' + $$.Slideshow.Counter).addClass('tmpSlideshowControlActive');
          
		 // $('div#tmpSlide-' + this.Next).fadeIn('slow');
		 $('div#tmpSlide-' + $$.Slideshow.Counter).css({'z-index' : '10'});
		  
          $$.Slideshow.Counter++;

          if ($$.Slideshow.Counter > 6) {
            $$.Slideshow.Counter = 1;
          }

          setTimeout('$$.Slideshow.Transition();', 5000);
        }
      );
    }
  }
});

$(document).ready(
  function() {
    $$.Slideshow.Ready();
  }
);
