function changeImage(imgObj, imgTgt) {
	document.getElementById(imgTgt).src = eval(imgObj + ".src");
}

var promoTimer;
var promoTimeout;
var curPromo;
var curOpacity = 0;
var firstPromo = (document.getElementById('rotatingBanner0') != null) ? 0 : 1;

var banner = firstPromo; // holds which variable we are going to show
var bannerTimer; // holds ID of the timer that changes the banners
var offset = 0; // holds the element index where page #1 will be;
// list of pages in the banner rotation

function hideAllPromos(cur)
{
	var i = firstPromo;
	while (document.getElementById('rotatingBanner'+i) != null)
	{
		if (i != cur)
		{
			document.getElementById('rotatingBanner'+i).style.display='none';
		}
		i++;
	}

}
function promoRotate() // standard rotation of the banner;
{
	promoRotate(banner);
}
function promoRotate(num)
{
	if (!isNaN(num)) // num is a number (and not undefined, etc), change the banner to that banner #
	{
		banner = num - offset;
	}
	hideAllPromos(banner);
	var elem = document.getElementById('rotatingBanner'+banner);
	startFade(elem);
	
	banner++;
	if (document.getElementById('rotatingBanner'+banner) == undefined)
	{
		banner = firstPromo;
	}
}

function startFade(elem)
{	
	curPromo = elem;
	curOpacity = 0;
	if(elem)
	{
		elem.style.opacity='0';
		elem.style.display='';
		setTimeout("fade();", 10);
	}
}

function fade()
{
	curOpacity += .1;
	curPromo.style.opacity = curOpacity;
	if(curOpacity < 1)
	{
		setTimeout("fade();", 50);
	}
	else
	{
		if (!isNaN(bannerTimer)) // if bannerTimer has been defined, unset the timer
		{
			clearTimeout(bannerTimer);
		}
		bannerTimer = setTimeout("promoRotate();",7000); // declare banner timer
	}
}

// initial call to the banner rotation
promoRotate();
