    var slideInterval;

    function slideSwitch(slideshow) {
      var $active = $(slideshow +'> div.active');
      if ( $active.length == 0 ) $active = $(slideshow +'> div:last');
      var $next =  $active.next().length ? $active.next() : $(slideshow +'>  div:first');
      
      var position = $(slideshow + "> div").index($next);
      $("#controlpanel li").find("input")[position].checked = true;
      $.uniform.update($("#controlpanel li").find("input"));
      $active.addClass('last-active');
 
      $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
    }
    
    function sliderClick(e) {
      if (slideInterval) clearInterval(slideInterval);
      
      var position = $("input[name=controlpanel]").index($("input[name=controlpanel]:checked"));

      var $active = $('#slideshow > div.active');
      if ( $active.length == 0 ) $active = $('#slideshow > div:last');
      var $next = $($("#slideshow > div")[position]);

      $active.addClass('last-active');
 
      $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });      
      
      
      slideInterval = setInterval( "slideSwitch('#slideshow')", 4000 );
    }
 
    $(window).load(function() {
      $("#controlpanel input[type='radio']").uniform();
      if ( $('#slideshow > div').length > 1 ) {
        $("#controlpanel input").click(sliderClick);
        $('#slideshow > div').removeClass("hidden");

        
        $('#controlpanel').removeClass("hidden");

        var $active = $('#slideshow > div.active');
        if ( $active.length == 0 ) $active = $('#slideshow > div:last');
        var position = $("#slideshow > div").index($active);
        $("#controlpanel li").find("input")[position].checked = true;
        $.uniform.update($("#controlpanel li").find("input"));
        
        
        slideInterval = setInterval( "slideSwitch('#slideshow')", 4000 );
      }
    });
