// the current slide
var currentSlide = 0;
// the counter to cycle through the array
var counter = 0;
// the variable to save the timer
var timer;
// the variable with the milliseconds
var millis = 3000;

/* 
 * hide the current item and show the selected item
 */
function showSlide( number ) 
{
	var currentItem = document.getElementById( "slide" + currentSlide );
	var currentMenu = document.getElementById( "menu" + currentSlide );
	var nextItem = document.getElementById( "slide" + number );
	var nextMenu = document.getElementById( "menu" + number );
	
	currentItem.className = "none";
	currentMenu.className = "";
	nextItem.className = "block h-250";
	nextMenu.className = "active";
	
	currentSlide = number;
	counter = number;
}

/* 
 * cycle through the items and call the showSlide function every x seconds
 */
function slideshow() 
{
	counter = ( counter % 5 );
	showSlide( counter );
	counter++;
	
	// call itself to create the neverending loop
	timer = setTimeout( "slideshow()", millis );
}

/* 
 * pause the slideshow
 */
function pauseSlideshow( id ) 
{
	clearTimeout( timer );
	showSlide( id )
}

/* 
 * resume the slideshow
 */
function resumeSlideshow() 
{
	timer = setTimeout( "slideshow()", millis );
	counter++;
}

/* 
 * start the slideshow
 */
window.onload = function() 
{
	slideshow();
}

