var carrousselInterval = 4;
	var timer = setTimeout ( "nextSlide()", 9000 );

	/*
	* Het volgende item laden
	*/
	function nextSlide ( )
	{
	  
	  var currentPos = resetAll();
	  selectNextItem(currentPos);
	
	  timer = setTimeout ( "nextSlide()", carrousselInterval*1000  );
	}
	
	
	function selectNextItem(currentPos)
	{
		var i = 0;
		$('#carrousel .menu ul li').each(function(index, element) {
			if(i == currentPos+1)
			{
				$(this).attr('class', 'active');	
			}
			i++;
		});
		
		
		
		/*Als de laatste item geweest is weer bovenaan beginnen */
		if(($('#carrousel .menu ul li').length-1) == currentPos)
		{
			$('#carrousel .menu ul li').first().attr('class', 'active');
			$('#carrousel .images').animate({'marginLeft': "0px"}, 500);
		}
		else
		{
			var height = 936;
			var cur = currentPos+1;
			var pos = '-'+(cur * height)+'px';
			$('#carrousel .images').animate({'marginLeft': pos}, 500);
		}
	}
	
	function resetAll()
	{
		var i =0;
		var currentItem = 0;
		$('#carrousel .menu ul li').each(function(index, element) {
            var className = '';
			className = $(this).attr('class');
			
			switch(className)
			{
				case 'active':
					currentItem = i;
				break;	
			}
			$(this).attr('class', '');
			i++;
        });	
		return currentItem;
	}
	
	 $(document).ready(function() {
		$('#carrousel .menu ul li').click(function(){
			clearTimeout(timer);
			resetAll();
			$(this).attr('class', 'active');
			var selectedItem = $(this);
			var i =0;
			$('#carrousel .menu ul li').each(function(index, element) {
				if($(this).attr('class') == 'active')
				{
					var height = 936;
					var cur = i;
					var pos = '-'+(cur * height)+'px';
					$('#carrousel .images').animate({'marginLeft': pos}, 500);
				}
				i++;
       		});	
			
			timer = setTimeout ( "nextSlide()", (carrousselInterval*1000)*2  );	
		});  
 	});
