$(document).ready(function(){

  var i = 0;
  var time_gap = 8000;

  $images = $('#slideshow p img');
	$images.hide();
	$images.eq(0).show();

	$links = $('#slideshow ul li a');
	$links.removeClass('current');
	$links.eq(0).addClass('current');

	$links.each(function(index){

		$(this).click(function(){

			i = index;

			// Set class to current link
			$links.removeClass('current');
			$(this).addClass('current');

			// Set curren image
		  $images.hide();
			$images.eq(index).show();
		});

	});

	window.setInterval(
		function(){
			i++;
			i = i % $links.size();
			$links.eq(i).click();
		}, time_gap
	);

});



