/* TV and radio block javascript*/

//Set the id names of your tablinks (without a number at the end)
var tablink_idname = 'tab';
var tabcontent_idname = 'tab_content'; //id name of the div without number
var tabcount = '3'; //amounts of tabs 
var loadtabs = '1'; //starttab 
var changespeed = 10; //in seconds
var autochangemenu= 1; //boolean yes=1 and 0=no
var stoponhover = 1; // 0=no 1=yes
//END MENU SETTINGS


/*Swich fliptab Functions - no need to edit something here*/
function fliptab(active) {
	if (active==1) {
		currenttab=active;
	}
	if (stoponhover==1) {
		stop_autochange()
	} 
	else if (stoponhover==0)  {
		counter=0;
	} 
	for (i=1; i <= tabcount; i++){
		document.getElementById(tablink_idname+i).className='tab'+i;
		document.getElementById(tabcontent_idname+i).style.display = 'none';
	}
	document.getElementById(tablink_idname+active).className='tab'+active+' tabactive';
	document.getElementById(tabcontent_idname+active).style.display = 'block';
}
var timer; 
counter=0; 
var totaltabs=tabcount;
var currenttab=loadtabs-1;

function start_autochange(){
	counter=counter+1;
	timer=setTimeout("start_autochange()",1000);
	if (counter == changespeed+1) {
		currenttab++;
	if (currenttab>totaltabs) {
		currenttab=1
	}
	fliptab(currenttab);
	restart_autochange();
	}
}

function restart_autochange(){
	clearTimeout(timer);
	counter=0;
	start_autochange();
}

function stop_autochange(){
	clearTimeout(timer);counter=0;
}

window.onload=function(){
var b = 1; 
do {
	fliptab(loadtabs);
	b++; 
}
while (b<=loadtabs)
if (autochangemenu!=0){
	start_autochange();
}
}
