var rollerTimerID = 0;
var rollerArray = new Array();
var rollerCount = 0;
var rollerCurrent = 0;

function stop() {
	rollerTimerStop();
}

function rollerContinue() {
	rollerTimerStart();
}

function rollerPause() {
	rollerTimerStop();
}

function rollerTimerStart() {
	if ( rollerTimerID == 0 ) {
		rollerTimerID = setTimeout("rollerTimerTicked()", 3000);
	}
	//hideid('control_rollerPaused');
	//showid('control_rollerNotPaused');
}

function rollerTimerStop() {
	if ( rollerTimerID != 0 ) {
		clearTimeout(rollerTimerID);
		rollerTimerID = 0;
	}
	showid('control_rollerPaused');
	hideid('control_rollerNotPaused');
}

function rollerTimerTicked() {
	if ( rollerTimerID != 0 ) {
		rollerTimerStop();
		rollerNext();
		rollerTimerStart();
	}
}

function rollerPrev() {
	rollerSet(rollerCurrent-1);
}

function rollerNext() {
	rollerSet(rollerCurrent+1);
}

function rollerSet(id)
{
	if ( id >= rollerCount ) {
		rollerCurrent = 0;
	} else if ( id < 0 ) {
		rollerCurrent = rollerCount-1;
	} else {
		rollerCurrent = id;
	}

	//if ( rollerCurrent == 0 ) {
	//	showid('control_rollerNext');
	//	hideid('control_rollerPrev');
	//} else if ( rollerCurrent == rollerCount-1 ) {
	//	hideid('control_rollerNext');
	//	showid('control_rollerPrev');		
	//} else {
	//	showid('control_rollerNext');
	//	showid('control_rollerPrev');
	//}

	if ( rollerCount > 0 ) {
		for ( i=0; i<rollerCount; ++i ) {
			if ( i == rollerCurrent ) {
				showid(rollerArray[i]);
			} else {
				hideid(rollerArray[i]);
			}
		}
	}
}

function rollerAdd(newRoller) {
	rollerArray[rollerCount++] = newRoller;
	if ( rollerCount == 1 ) {
		rollerSet(0);
		rollerTimerStart();
	} else {
		hideid(newRoller);
	}
	if ( rollerCount > 1 ) {
		//showid('control_rollerNext');
		//showid('control_rollerPrev');
	}
}

function showid(id) {
	if ( document.getElementById ) {
		document.getElementById(id).style.display = "block";
	} else {
		document[id].display = "block";
	}
}

function hideid(id) {
	if ( document.getElementById ) {
		document.getElementById(id).style.display = "none";
	} else {
		document[id].display = "none";
	}
}
