function playThroughAgain()
{
	window.setTimeout(ShowNextAd, 6000);

	adsViewed++;
	repeat = (adsViewed <= numberOfAds);
}

// previous functionality
function ShowPrevAd()
{
	// Hide the current ad
    $('ad' + adNumber).style.display = "none";

    adNumber--;
    
    // Fix the number of the previous ad
    if(adNumber < 0)
        adNumber = numberOfAds - 1;

	// Show the previous ad
	$('ad' + adNumber).style.display = "block";
}

// next functionality
function ShowNextAd()
{
    // Hide the current ad
    $('ad' + adNumber).style.display = "none";

    adNumber++;

	// Fix the number of the next ad
	if(adNumber >= numberOfAds)
	    adNumber = 0;

	// Show the next ad
	document.getElementById('ad' + adNumber).style.display = "block";

	//if all ads haven't shown yet, this calls the next one up
	if(repeat)
		playThroughAgain();
}
