/************************************************************
Obtained this from the UGA Sport Page. Script to rotate images.
*************************************************************/
var PhotosToRotate = new Array();
function PhotosRotate_Stop(name) {
	eval('ADL_' + name + '_Running = false');
}
function PhotosRotate_Start(name) {
	eval('ADL_' + name + '_Running = true');
}
function PhotosRotate() {
	for(var i = 0; i < PhotosToRotate.length; i++)
	{
		var Loops = eval('ADL_' + PhotosToRotate[i] + '_Loops');
		var Count = eval('ADL_' + PhotosToRotate[i] + '_Count');
		var Running = eval('ADL_' + PhotosToRotate[i] + '_Running');
		if(!Running || Loops > (Count * 9999))
		{
			continue;
		}
		var Current = eval('ADL_' + PhotosToRotate[i] + '_Current');
		var now = new Date();
		now = now.getTime();
		var curel = eval('ADL_' + PhotosToRotate[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_' + PhotosToRotate[i] + '_Current = ' + newidx);
			eval('ADL_' + PhotosToRotate[i] + '_Loops += 1');
			if(document.getElementById)
			{
				var divel = document.getElementById("ADROT_" + PhotosToRotate[i]);
				if(divel != null)
				{
					var curel = eval('ADL_' + PhotosToRotate[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(PhotosRotate, 1000);

function ADL_GRP3(adhtml, height, width, displaysec) {
	this.adhtml = adhtml;
	this.height = height;
	this.width = width;
	this.displaysec = displaysec;
	this.start_display = 0;
}
var ADL_GRP3_Loops = 0;
var ADL_GRP3_Running = true;
var ADL_GRP3_Count = 5;
var ADL_GRP3_Current = 0;
var ADL_GRP3_Ads = new Array();
PhotosToRotate[PhotosToRotate.length] = "GRP3";

ADL_GRP3_Ads[ADL_GRP3_Ads.length] = new ADL_GRP3('<img alt=\"Mtn Bike Racing\" onmouseover=\"PhotoRotate_Stop(\'GRP3\')\" height=\"400\" onmouseout=\"PhotoRotate_Start(\'GRP3\')\" src=\"templates/Chainbuster/images/Photos/img04231001.jpg\" width=\"600\" border=\"0\">', '400', '600', 5);

ADL_GRP3_Ads[ADL_GRP3_Ads.length] = new ADL_GRP3('<img alt=\"Mtn Bike Racing\" onmouseover=\"PhotoRotate_Stop(\'GRP3\')\" height=\"400\" onmouseout=\"PhotoRotate_Start(\'GRP3\')\" src=\"templates/Chainbuster/images/Photos/img04231002.jpg\" width=\"600\" border=\"0\">', '400', '600', 5);

ADL_GRP3_Ads[ADL_GRP3_Ads.length] = new ADL_GRP3('<img alt=\"Mtn Bike Racing\" onmouseover=\"PhotoRotate_Stop(\'GRP3\')\" height=\"400\" onmouseout=\"PhotoRotate_Start(\'GRP3\')\" src=\"templates/Chainbuster/images/Photos/img04231003.jpg\" width=\"600\" border=\"0\">', '400', '600', 5);

ADL_GRP3_Ads[ADL_GRP3_Ads.length] = new ADL_GRP3('<img alt=\"Mtn Bike Racing\" onmouseover=\"PhotoRotate_Stop(\'GRP3\')\" height=\"400\" onmouseout=\"PhotoRotate_Start(\'GRP3\')\" src=\"templates/Chainbuster/images/Photos/img04231004.jpg\" width=\"600\" border=\"0\">', '400', '600', 5);

ADL_GRP3_Ads[ADL_GRP3_Ads.length] = new ADL_GRP3('<img alt=\"Mtn Bike Racing\" onmouseover=\"PhotoRotate_Stop(\'GRP3\')\" height=\"400\" onmouseout=\"PhotoRotate_Start(\'GRP3\')\" src=\"templates/Chainbuster/images/Photos/img04231005.jpg\" width=\"600\" border=\"0\">', '400', '600', 5);