/************************************************************
Obtained this from the UGA Sport Page. Script to rotate images.
*************************************************************/
var AdGroupsToRotate = new Array();
function AdGroupRotate_Stop(name) {
	eval('ADL_' + name + '_Running = false');
}
function AdGroupRotate_Start(name) {
	eval('ADL_' + name + '_Running = true');
}
function AdGroupRotate() {
	for(var i = 0; i < AdGroupsToRotate.length; i++)
	{
		var Loops = eval('ADL_' + AdGroupsToRotate[i] + '_Loops');
		var Count = eval('ADL_' + AdGroupsToRotate[i] + '_Count');
		var Running = eval('ADL_' + AdGroupsToRotate[i] + '_Running');
		if(!Running || Loops > (Count * 9999))
		{
			continue;
		}
		var Current = eval('ADL_' + AdGroupsToRotate[i] + '_Current');
		var now = new Date();
		now = now.getTime();
		var curel = eval('ADL_' + AdGroupsToRotate[i] + '_Ads[' + Current + ']');
		if(curel.start_display == 0)
		{
			curel.start_display = now;
		}
		if((curel.displaysec * 1000) < (now - curel.start_display))
		{
			var j = 0;
			var newidx = Math.floor(Math.random() * Count)
			while(Current == newidx && j < 10)
			{
				newidx = Math.floor(Math.random() * Count);
				j++;
			}
			curel.start_display = now;
			eval('ADL_' + AdGroupsToRotate[i] + '_Current = ' + newidx);
			eval('ADL_' + AdGroupsToRotate[i] + '_Loops += 1');
			if(document.getElementById)
			{
				var divel = document.getElementById("ADROT_" + AdGroupsToRotate[i]);
				if(divel != null)
				{
					var curel = eval('ADL_' + AdGroupsToRotate[i] + '_Ads[' + newidx + ']');
					var newhtml = curel.adhtml;
					if(divel.filters && divel.filters[0])
					{
						divel.filters[0].apply()
					}
					var tpos = newhtml.indexOf("?T=");
					if(tpos > 0)
					{
						var qpos = newhtml.indexOf("\"", tpos);
						if(qpos > 0)
						{
							newhtml = newhtml.substring(0, tpos) + "?T=" + now + newhtml.substring(qpos);
						}
					}

					divel.innerHTML = newhtml;
					if(divel.filters && divel.filters[0])
					{
						divel.filters[0].play()
					}
					curel.start_display = now;
				}
				else
				{
					// alert("NULL divel");
				}
			}
			else
			{
				// alert("Cant Dot it");
			}

		}
	}
}

window.setInterval(AdGroupRotate, 1000);

function ADL_GRP1(adhtml, height, width, displaysec) {
	this.adhtml = adhtml;
	this.height = height;
	this.width = width;
	this.displaysec = displaysec;
	this.start_display = 0;
}
var ADL_GRP1_Loops = 0;
var ADL_GRP1_Running = true;
var ADL_GRP1_Count = 3;
var ADL_GRP1_Current = 0;
var ADL_GRP1_Ads = new Array();
AdGroupsToRotate[AdGroupsToRotate.length] = "GRP1";

ADL_GRP1_Ads[ADL_GRP1_Ads.length] = new ADL_GRP1('<img alt=\"Mtn Bike Racing\" onmouseover=\"AdGroupRotate_Stop(\'GRP1\')\" height=\"142\" onmouseout=\"AdGroupRotate_Start(\'GRP1\')\" src=\"templates/Chainbuster/images/071104.jpg\" width=\"300\" border=\"0\">', '142', '300', 7);

ADL_GRP1_Ads[ADL_GRP1_Ads.length] = new ADL_GRP1('<img alt=\"Mtn Bike Racing\" onmouseover=\"AdGroupRotate_Stop(\'GRP1\')\" height=\"142\" onmouseout=\"AdGroupRotate_Start(\'GRP1\')\" src=\"templates/Chainbuster/images/071105.jpg\" width=\"300\" border=\"0\">', '142', '300', 7);

ADL_GRP1_Ads[ADL_GRP1_Ads.length] = new ADL_GRP1('<img alt=\"Mtn Bike Racing\" onmouseover=\"AdGroupRotate_Stop(\'GRP1\')\" height=\"142\" onmouseout=\"AdGroupRotate_Start(\'GRP1\')\" src=\"templates/Chainbuster/images/071106.jpg\" width=\"300\" border=\"0\">', '142', '300', 7);

function ADL_GRP2(adhtml, height, width, displaysec) {
	this.adhtml = adhtml;
	this.height = height;
	this.width = width;
	this.displaysec = displaysec;
	this.start_display = 0;
}

var ADL_GRP2_Loops = 0;
var ADL_GRP2_Running = true;
var ADL_GRP2_Count = 3;
var ADL_GRP2_Current = 0;
var ADL_GRP2_Ads = new Array();
AdGroupsToRotate[AdGroupsToRotate.length] = "GRP2";

ADL_GRP2_Ads[ADL_GRP2_Ads.length] = new ADL_GRP2('<a href=\"/http://www.tifosioptics.com\" target=\"_blank\"><img alt=\"TIFOSI\" onmouseover=\"AdGroupRotate_Stop(\'GRP2\')\" height=\"100\" onmouseout=\"AdGroupRotate_Start(\'GRP2\')\" src=\"templates/Chainbuster/images/sponsors/SP011604_on.jpg" width=\"175\" border=\"0\"></a>', '100', '175', 5);
ADL_GRP2_Ads[ADL_GRP2_Ads.length] = new ADL_GRP2('<a href=\"/http://www.newbelgium.com\" target=\"_blank\"><img alt=\"New Belgium Brewing\" onmouseover=\"AdGroupRotate_Stop(\'GRP2\')\" height=\"100\" onmouseout=\"AdGroupRotate_Start(\'GRP2\')\" src=\"templates/Chainbuster/images/sponsors/SP010501_on.jpg" width=\"175\" border=\"0\"></a>', '100', '175', 5);
ADL_GRP2_Ads[ADL_GRP2_Ads.length] = new ADL_GRP2('<a href=\"/http://www.maxxis.com\" target=\"_blank\"><img alt=\"MAXXIS\" onmouseover=\"AdGroupRotate_Stop(\'GRP2\')\" height=\"100\" onmouseout=\"AdGroupRotate_Start(\'GRP2\')\" src=\"templates/Chainbuster/images/sponsors/SP010502_on.jpg" width=\"175\" border=\"0\"></a>', '100', '175', 5); 