function run () {
  var $first = $('#slideshow > img:first');
  
  $first.addClass('active');  
  $first.fadeIn(500);  
  		
  timeout = setTimeout('slideShow()', 4000);
}

function slideShow () {
    var $active = $('#slideshow img.active');    

    if ($active.length == 0) {
      $active = $('#slideshow img:last');
    }
    
    var $next = $active.next();
    
    if ($next.length == 0) {
      $next = $('#slideshow img:first');
    }
          
    
    $next.addClass('active');
    
    $active.fadeOut(300, function () {
  		$next.fadeIn(200);
  		
  		$active.removeClass('active');
  	});
    
    timeout = setTimeout('slideShow()', 4000);
}

$(function() {
	timeout = setTimeout('run()', 500);
});