var ads = new Array();

var current;
var anchor;
var image;
var adTimer;
var adTimeout;

function initAds(anchorId, imageId)
{
	adTimeout = 2500;
	anchor = document.getElementById(anchorId);
	image = document.getElementById(imageId);
	anchor.href = ads[current = 0][1];
	image.src = 'partners/' + ads[current][0];
	window.setTimeout("startAds();", 0);
}

function cycleAds()
{
	current = current == ads.length - 1 ? 0 : current + 1;
	anchor.href = ads[current][1];
	image.src = 'partners/' + ads[current][0];
}

function startAds()
{
	if (!adTimer) adTimer = window.setInterval('cycleAds();', adTimeout);
}

function stopAds()
{
	window.clearTimeout(adTimer);
	adTimer = null;
}

function setAdTimeout(timeout)
{
	adTimeout = timeout;
}

function addAd(src, href)
{
	ads[ads.length] = new Array(src, href);
}