

var currentSecAdIndex = -1;
var secAds = new Array();
var secAdGroup = new Array();
secAds.push(secAdGroup);
var secAd = new Object();
var secAdGroupCount = 1;





var blankAd = new Image();
blankAd.src = "/bf/ut/uvhba/mem/images/clear.gif";
blankAd.width = 120;
blankAd.height = 60;

var currentSecAdGroupIndex = -1;

function rotateSecondaryAd(secAdGroupIndex)
{
	var waitInMilliseconds = 6000;

	if(isNaN(secAdGroupIndex) || secAdGroupIndex >= secAdGroupCount)
		secAdGroupIndex = 0;

	if(secAds.length>secAdGroupIndex)
	{
		var currGroup = secAds[secAdGroupIndex];
		for (var idx=0; idx < currGroup.length; idx++)
		{
			var ad = currGroup[idx];
	
			document["rotateImage" + idx].src = ad.img.src;
			document["rotateImage" + idx].width = ad.width;
			document["rotateImage" + idx].height = ad.height;

			var e = document.getElementById("adCell"+idx);
				if(e) e.className=("secondaryAd");
							
			if (ad.displayCount == 0)
			{
				var dummyImage = new Image();
				dummyImage.src = ad.recordViewURL;
			}
			ad.displayCount = ad.displayCount + 1;
		}
		for (var idx=currGroup.length; idx < 5; idx++)
		{
			if (document["rotateImage" + idx])
			{
				document["rotateImage" + idx].src = blankAd.src;
				document["rotateImage" + idx].width = 120;
				document["rotateImage" + idx].height = 60;
	
				var e = document.getElementById("adCell"+idx);
					if(e) e.className=("");
			}
		}

		currentSecAdGroupIndex = secAdGroupIndex;
		var newIndex = (secAdGroupIndex==(secAds.length-1)?0:(secAdGroupIndex+1));
		if (secAds.length>1)
			setTimeout("rotateSecondaryAd(" + newIndex + ")", waitInMilliseconds);
	}
}

function rotateSecondaryAdClick(adIndex)
{
	if(currentSecAdGroupIndex >= 0 && adIndex >= 0)
	{
		var ad = secAds[currentSecAdGroupIndex][adIndex];
		window.open("/bf/ut/uvhba/mem/adClick.jsp?ad_id=" + ad.adId + "&is_global=" + ad.isGlobal);
	}
}

var oldSecondaryAdOnload = "" + window.onload;

if(oldSecondaryAdOnload)
{
	if(oldSecondaryAdOnload.indexOf("rotateSecondaryBannerAd")==-1)
	{
		oldSecondaryAdOnload = oldSecondaryAdOnload.substring(oldSecondaryAdOnload.indexOf("{")+1,oldSecondaryAdOnload.lastIndexOf("}"));

		window.onload = function doSecondaryAdOnLoad() {
			if(oldSecondaryAdOnload) eval(oldSecondaryAdOnload);
			rotateSecondaryAd();
		}
	}
}
else
{
	window.onload = function doSecondaryAdOnload() {
		rotateSecondaryAd();
	}
}


