var RotateTimeID = -1, ContentCount, current, next, i, currentindexer, nextindexer;
var prevlink, nextlink;
var footer; 
var ftitle = new String();
function InitRotator(IdPrefix, Count)
{
	RotateContent=function()
	{
		current = document.getElementById(IdPrefix + i);
		currentindexer = document.getElementById(IdPrefix + "a" + i);
		i++;
		if(i >= Count || i < 0){ i=0 }
		next = document.getElementById(IdPrefix + i);
		nextindexer = document.getElementById(IdPrefix + "a" + i);
		if(next != null && typeof(next) != "undefined" && current != null && typeof(current) != "undefined")
		{
			current.style.display = "none";
			currentindexer.className = "";
			next.style.display = "";
			nextindexer.className = "selected";
			var duration = document.getElementById(IdPrefix + "d" + i);
			var time = (duration != null && typeof(duration) != "undefined")? parseInt(duration.value, 10) * 1000 : 10000;
			RotateTimeID = setTimeout('RotateContent()',  time);
			
			ftitle = next.title;
			if(document.all)
			{
		    	document.getElementById('ctl00_ContentPlaceHolder1_lbTitle').innerText = ftitle;
			}
			else  // JMH For Firefox
			{
                document.getElementById('ctl00_ContentPlaceHolder1_lbTitle').textContent = ftitle;
            }
		}
	}
	
	i= Count - 1;
	ContentCount = Count;
	prevlink = document.getElementById(IdPrefix + "Prev");
	nextlink = document.getElementById(IdPrefix + "Next");
	RotateContent();
}

function DisplayContent(IdPrefix, index)
{
    //alert('DisplayContent');
    if(RotateTimeID != -1) 
    { 
        clearTimeout(RotateTimeID);
        RotateTimeID = -1;
    }
	current = document.getElementById(IdPrefix + i);
	currentindexer = document.getElementById(IdPrefix + "a" + i);
	next = document.getElementById(IdPrefix + index);
	nextindexer = document.getElementById(IdPrefix + "a" + index);
	
	if(next != null && typeof(next) != "undefined" && current != null && typeof(current) != "undefined")
	{
		current.style.display = "none";
		currentindexer.className = "";
		next.style.display = "";
		nextindexer.className = "selected";
		i = index;
		ftitle = next.title;
		
		if(document.all)
			{
		    	document.getElementById('ctl00_ContentPlaceHolder1_lbTitle').innerText = ftitle;
			}
			else  // JMH For Firefox
			{
                document.getElementById('ctl00_ContentPlaceHolder1_lbTitle').textContent = ftitle;
            }
	}	
}

function Previous(IdPrefix)
{
	if(i == 0) 
	{
	DisplayContent(IdPrefix, ContentCount - 1);
	}
	else
	{
	DisplayContent(IdPrefix, i - 1);
	}
}
function Next(IdPrefix)
{
	if(i == (ContentCount - 1))
	{
	DisplayContent(IdPrefix, 0);
	}
	else
	{
	DisplayContent(IdPrefix, i + 1);
	}
}