var ti=0;
var showNum = document.getElementById("num");
function Mea(value){
	ti=value;
	setBg(value);
	plays(value);
	//msg('autoStart:'+typeof(autoStart));
}

function clk(value)
{
	ti=value;
	clearAuto();
	setBg(value);
	plays(value);
}

function setBg(value){
	for(var i=0;i<6;i++){
	   if(value==i){
	     document.getElementById("a"+value).className='act';      
			}	else{	
			 document.getElementById("a"+i).className='nor';
			}  
	} 
}

function plays(value){ 
		 for(i=0;i<6;i++){
			  if(i==value){			  
			  	document.getElementById("pc_"+value).style.display="block";
			  }else{
			    document.getElementById("pc_"+i).style.display="none";			    
			  }
		}	
}


function clearAuto(){
	if(typeof(autoStart) != "undefined")
	{		clearInterval(autoStart);		}
	}
function setAuto(){
	clearAuto();
	autoStart=setInterval("auto()", 5000);
}

function auto(){
	ti++;
	if(ti>5) ti=0;
	Mea(ti);
}

function sub(){
	ti--;
	if(ti<0)ti=5;
	Mea(ti);
}

setAuto(); 
function msg(text){	document.getElementById('msg').innerHTML += text+"\n\r"; }