function prepareBreakingNewsTabs(){

	var bnObjTotal = document.getElementById('bnTabs').getElementsByTagName('li').length;
	for (var j=1;j<=bnObjTotal;j++)
		{
		if (document.getElementById('bnTab' + j).className == 'on'){
			document.getElementById('bnSection' + j).style.display = 'block';
			} else {
			document.getElementById('bnSection' + j).style.display = 'none';
			}
		}

 	document.getElementById('bnLink1').onclick = function(){
		toggleBreakingNewsTabs(1);
		}
	document.getElementById('bnLink2').onclick = function(){
		toggleBreakingNewsTabs(2);
		}
	document.getElementById('bnLink3').onclick = function(){
		toggleBreakingNewsTabs(3);
		}
	document.getElementById('bnLink4').onclick = function(){
		toggleBreakingNewsTabs(4);
		}
	document.getElementById('bnLink5').onclick = function(){
		toggleBreakingNewsTabs(5);
		}
	document.getElementById('bnLink6').onclick = function(){
		toggleBreakingNewsTabs(6);
		}
	document.getElementById('bnLink7').onclick = function(){
		toggleBreakingNewsTabs(7);
		}
	document.getElementById('bnLink8').onclick = function(){
		toggleBreakingNewsTabs(8);
		}
	document.getElementById('bnLink9').onclick = function(){
		toggleBreakingNewsTabs(9);
		}
	document.getElementById('bnLink10').onclick = function(){
		toggleBreakingNewsTabs(10);
		}
	document.getElementById('bnLink11').onclick = function(){
		toggleBreakingNewsTabs(11);
		}
	document.getElementById('bnLink12').onclick = function(){
		toggleBreakingNewsTabs(12);
		}
	document.getElementById('bnLink13').onclick = function(){
		toggleBreakingNewsTabs(13);
		}
}

function preparePrintTabs(){

	var objTotal = document.getElementById('printTabs').getElementsByTagName('li').length;
	for (var i=1;i<=objTotal;i++)
		{
		if (document.getElementById('printTab' + i).className == 'on'){
			document.getElementById('printSection' + i).style.display = 'block';
			} else {
			document.getElementById('printSection' + i).style.display = 'none';
			}
		}

 	document.getElementById('printLink1').onclick = function(){
		togglePrintTabs(1);
		}
	document.getElementById('printLink2').onclick = function(){
		togglePrintTabs(2);
		}
	document.getElementById('printLink3').onclick = function(){
		togglePrintTabs(3);
		}
	document.getElementById('printLink4').onclick = function(){
		togglePrintTabs(4);
		}
	document.getElementById('printLink5').onclick = function(){
		togglePrintTabs(5);
		}
	document.getElementById('printLink6').onclick = function(){
		togglePrintTabs(6);
		}
	document.getElementById('printLink7').onclick = function(){
		togglePrintTabs(7);
		}
	document.getElementById('printLink8').onclick = function(){
		togglePrintTabs(8);
		}
	document.getElementById('printLink9').onclick = function(){
		togglePrintTabs(9);
		}
	document.getElementById('printLink10').onclick = function(){
		togglePrintTabs(10);
		}
	document.getElementById('printLink11').onclick = function(){
		togglePrintTabs(11);
		}
	document.getElementById('printLink12').onclick = function(){
		togglePrintTabs(12);
		}
	document.getElementById('printLink13').onclick = function(){
		togglePrintTabs(13);
		}
}

function toggleBreakingNewsTabs(bnObjNum){

	var bnObjTotal = document.getElementById('bnTabs').getElementsByTagName('li').length;
	for (var j=1;j<=bnObjTotal;j++)
		{
		document.getElementById('bnTab' + j).className = 'off';
		document.getElementById('bnSection' + j).style.display = 'none';
		}

	document.getElementById('bnTab' + bnObjNum).className = 'on';
	document.getElementById('bnSection' + bnObjNum).style.display = 'block';
	if (bnObjNum > 8){
		document.getElementById('bnTabTier1').className = 'tierUp';
		document.getElementById('bnTabTier2').className = 'tierDown';
		} else {
		document.getElementById('bnTabTier2').className = 'tierUp';
		document.getElementById('bnTabTier1').className = 'tierDown';
		}
	
}

function togglePrintTabs(objNum){

	var objTotal = document.getElementById('printTabs').getElementsByTagName('li').length;
	for (var i=1;i<=objTotal;i++)
		{
		document.getElementById('printTab' + i).className = 'off';
		document.getElementById('printSection' + i).style.display = 'none';
		}

	document.getElementById('printTab' + objNum).className = 'on';
	document.getElementById('printSection' + objNum).style.display = 'block';
	if (objNum > 8){
		document.getElementById('printTabTier1').className = 'tierUp';
		document.getElementById('printTabTier2').className = 'tierDown';
		} else {
		document.getElementById('printTabTier2').className = 'tierUp';
		document.getElementById('printTabTier1').className = 'tierDown';
		}
	
}

function rotateSpecialCoverage(item){

	var itemTotal = document.getElementById('speccov_list').getElementsByTagName('li').length;
	for (var p=1;p<=itemTotal;p++)
		{
		document.getElementById('specCov' + p).style.display = 'none';
		}
	item = item + 1;
	if (item > itemTotal) item = 1;
	document.getElementById('specCov' + item).style.display = 'block';
	specCovId = window.setTimeout("rotateSpecialCoverage("+item+")", 5000);
	
}

function rotateMiscButtons(button){

	for (var q=1;q<=3;q++)
		{
		document.getElementById('misc_button' + q).style.display = 'none';
		}
	document.getElementById('misc_button3a').style.display = 'none';
	button = button + 1;
	if (button > 3) button = 1;
	document.getElementById('misc_button' + button).style.display = 'block';
	if (button == 3) document.getElementById('misc_button3a').style.display = 'block';
	specCovId = window.setTimeout("rotateMiscButtons("+button+")", 5000);
	
}

function startRotations(){
	
	window.setTimeout("rotateSpecialCoverage(1)", 5000);
	window.setTimeout("rotateMiscButtons(1)", 5000);
	
}

function randomBackground(){

	if (document.getElementById('teammb')){
		var rand_no = Math.ceil(Math.random()*10);
		document.getElementById('teammb').className = 'teammb'+rand_no;
		}

}

addLoadEvent(prepareBreakingNewsTabs);
addLoadEvent(preparePrintTabs);
addLoadEvent(startRotations);
addLoadEvent(randomBackground);
