﻿var cTime;
var NoRecords;
var RotatorItems;
var ActiveThumbPath;
var InActiveThumbPath;

function RotateImages(CurrentRecord)
{
    if(CurrentRecord>=NoRecords)
	{
		CurrentRecord=0;
	}
	SelectItem(CurrentRecord);
	cTime = setTimeout("RotateImages("+(CurrentRecord+1)+")",4000);
}

function SetActiveItem(CurrentRecord)
{
	clearTimeout(cTime);
	SelectItem(CurrentRecord);
}

function SelectItem(CurrentRecord)
{
	var LoopCount;
	for(LoopCount=0;LoopCount<NoRecords;LoopCount++)
	{
		if(LoopCount==CurrentRecord)
		{
			document.getElementById('NewsRotator').style.background = 'url(' + RotatorItems[LoopCount] [0] + ') no-repeat top left';
			document.getElementById(RotatorItems[LoopCount] [1]).src = ActiveThumbPath;
			document.getElementById(RotatorItems[LoopCount] [2]).style.display = 'block';
			document.getElementById(RotatorItems[LoopCount] [3]).style.background = '#4D4D4D';
		}
		else
		{
			document.getElementById(RotatorItems[LoopCount] [1]).src = InActiveThumbPath;
			document.getElementById(RotatorItems[LoopCount] [2]).style.display = 'none';
			document.getElementById(RotatorItems[LoopCount] [3]).style.background = 'black';
		}
	}
}
