$(document).ready( function() {
	
	setInterval(function(){backgroundPictureSwitch()},5000);
	setInterval(function(){SponsorSwitch()},3000);

	function backgroundPictureSwitch() {
  		var $active = $('#background img.active');
		
		if ($active.length == 0){
			$active = $('#background img:last');
		}
		
  		var $next = $active.next().length ? $active.next() : $('#background img:first');
		
		$active.addClass('last-active');
		
		$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1500, function() {
					$active.removeClass('active last-active');
				});
	}
	
	/*function SponsorSwitch() {
  		var $active = $('#blok_sponsors IMG.active');
		
		if ($active.length == 0){
			$active = $('#blok_sponsors IMG:last');
		}
		
  		var $next = $active.next().length ? $active.next() : $('#blok_sponsors IMG:first');
		var $hoogte = $next.height() + 10;
		
		$active.addClass('last-active');
		$('#blok_sponsors IMG.last-active').animate({opacity: 0.0},1000);
		
		$next.css({opacity: 0.0})
				.addClass('active')
				.animate({opacity: 1.0}, 1500, function() {
					$active.removeClass('active last-active');
				});
		$('#blok_sponsors').animate({height: $hoogte}, 500);
	}*/

});

