var nIndex = 0;
var timerID = null;
var period = 5000;

function setRotatePeriod(new_val){
    period = new_val;
}

function rotateTabs(){
    nIndex=tabView.get('activeIndex')+1;
    if(!tabView.getTab(nIndex)) nIndex = 0;
    tabView.selectTab(nIndex);
    timerID = setTimeout('rotateTabs()',period);
}

function pauseRotate() {
	if (timerID != null) {
		clearTimeout(timerID);
		timerID = null;
	}
}

function startRotate() {
	if (timerID == null) {
		timerID = setTimeout('rotateTabs()',period);
	}
}
