﻿var nCurrentDiv_MainAd = 0;
var nNumberOfDivs_MainAd = 0;

var nCurrentDiv_SecondaryAd = 0;
var nNumberOfDivs_SecondaryAd = 0;

function StartRotators()
{
	setInterval('flipdivs_MainAd()', 5000); // Set up time to iterate through them
	setInterval('flipdivs_SecondaryAd()', 4000); // Set up time to iterate through them

	flipdivs_MainAd();  // Show first one
	flipdivs_SecondaryAd();  // Show first one
}

function flipdivs_MainAd()
{
	// Hide image

	if (nCurrentDiv_MainAd > 0)
	{
		var divToHide = document.getElementById('MainAd' + nCurrentDiv_MainAd);

		if (divToHide)
		{
			divToHide.style.display = 'none';
		} 
	}

	// Show next one in sequence

	nCurrentDiv_MainAd++;

	if (nCurrentDiv_MainAd > nNumberOfDivs_MainAd)
	{
		nCurrentDiv_MainAd = 1;
	}

	var divToShow = document.getElementById('MainAd' + nCurrentDiv_MainAd);

	if (divToShow)
	{
		divToShow.style.display = 'block';
	}
}

function flipdivs_SecondaryAd()
{
	// Hide image

	if (nCurrentDiv_SecondaryAd > 0)
	{
		var divToHide = document.getElementById('SecondaryAd' + nCurrentDiv_SecondaryAd);

		if (divToHide)
		{
			divToHide.style.display = 'none';
		} 
	}

	// Show next one in sequence

	nCurrentDiv_SecondaryAd++;

	if (nCurrentDiv_SecondaryAd > nNumberOfDivs_SecondaryAd)
	{
		nCurrentDiv_SecondaryAd = 1;
	}

	var divToShow = document.getElementById('SecondaryAd' + nCurrentDiv_SecondaryAd);

	if (divToShow)
	{
		divToShow.style.display = 'block';
	}
}