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