var  i = 1;
var count = 1;
var delay = 6000;
//var indexArray = new Array("1,2,3");

function switchBlock(block, id)
{


}

function highlight(id)
{
	if(document.getElementById(id).className.indexOf('highlight') == -1 )
	{
		document.getElementById(id).className = document.getElementById(id).className + 'highlight';
	}
	else
	{
		document.getElementById(id).className = document.getElementById(id).className = document.getElementById(id).className.substring(0,document.getElementById(id).className.indexOf('highlight'));
	}
}

function display(id, total)
{
	stopcounter();
	
	do 
	{ 
		document.getElementById('dyn_' + total).style.display = 'none';
		total--;
	}
	while(total>0);

	if(document.getElementById('dyn_' + id).style.display == 'inline')
	{
		document.getElementById('dyn_' + id).style.display = 'none';
	}
	else
	{
		document.getElementById('dyn_' + id).style.display = 'inline';
	}
	i=id;
}

function evaluate(total)
{
	if (i!=1) document.getElementById('dyn_' + (i-1)).style.display = 'none';
	if (i>total) i=1;

	document.getElementById('dyn_' + i).style.display = 'inline';
}

function evaluatedec(total)
{
	
	if (i!=total) document.getElementById('dyn_' + (i+1)).style.display = 'none';
	if (i<1) i=total;

	document.getElementById('dyn_' + i).style.display = 'inline';
}

function loop(total)
{
	if (count==1)
	{
		// Increment counter
		i++;
		// Evaluate
		evaluate(total);
	}
}

function increasei(total)
{
	stopcounter();
	// Increment counter
	i++;
	// Evaluate
	evaluate(total);	
	startcounter();		
}

function decreasei(total)
{
	// Reset timer
	stopcounter();
	// Decrement counter
	i--;
	// Evaluate
	evaluatedec(total);
	startcounter();	
}

function dopause()
{
	document.getElementById('unpaused').style.display = 'none';
	document.getElementById('paused').style.display = 'block';
	stopcounter();
}

function unpause()
{
	document.getElementById('paused').style.display = 'none';
	document.getElementById('unpaused').style.display = 'block';
}


function stopcounter()
{
	count = 0;
}

function startcounter()
{
	count = 1;
	window.clearInterval(interval);
	interval = window.setInterval(doLoop,delay);
	unpause();
}

function pause(millis)
{
	date = new Date();
	var curDate = null;

	do { var curDate = new Date(); }
	while(curDate-date < millis);
} 