function prepareMostPopular(){
 
	document.getElementById('aMostViewed').onclick = function(){
		togglePopularDisplay('MostViewed');
	}
	
	document.getElementById('aMostCommented').onclick = function(){
		togglePopularDisplay('MostCommented');
	}
	
	document.getElementById('aMostEmailed').onclick = function(){
		togglePopularDisplay('MostEmailed');
	}

	
	document.getElementById('aMostViewed1').onclick = function(){
		togglePopularList('MostViewed1');
	}
	document.getElementById('aMostViewed2').onclick = function(){
		togglePopularList('MostViewed2');
	}
	document.getElementById('aMostViewed3').onclick = function(){
		togglePopularList('MostViewed3');
	}
		
	document.getElementById('aMostCommented1').onclick = function(){
		togglePopularList('MostCommented1');
	}
	document.getElementById('aMostCommented2').onclick = function(){
		togglePopularList('MostCommented2');
	}
	document.getElementById('aMostCommented3').onclick = function(){
		togglePopularList('MostCommented3');
	}
		
	document.getElementById('aMostEmailed1').onclick = function(){
		togglePopularList('MostEmailed1');
	}
	document.getElementById('aMostEmailed2').onclick = function(){
		togglePopularList('MostEmailed2');
	}
	document.getElementById('aMostEmailed3').onclick = function(){
		togglePopularList('MostEmailed3');
	}
	
}



function togglePopularDisplay(objname){

	document.getElementById('liMostViewed').className = 'off';
	document.getElementById('liMostCommented').className = 'off';
	document.getElementById('liMostEmailed').className = 'off';
	
	document.getElementById('divMostViewed').style.display = 'none';
	document.getElementById('divMostCommented').style.display = 'none';
	document.getElementById('divMostEmailed').style.display = 'none';

	for (var i=1;i<=3;i++)
		{
		document.getElementById('liMostViewed' + i).className = 'on';
		document.getElementById('liMostCommented' + i).className = 'on';
		document.getElementById('liMostEmailed' + i).className = 'on';
		document.getElementById('olMostViewed' + i).style.display = 'none';
		document.getElementById('olMostCommented' + i).style.display = 'none';
		document.getElementById('olMostEmailed' + i).style.display = 'none';
		}

	document.getElementById('li' + objname).className = 'on';
	document.getElementById('div' + objname).style.display = 'inline';
	document.getElementById('ol' + objname + '1').style.display = 'block';
	document.getElementById('li' + objname + '1').className = 'off';
	
}

function togglePopularList(objname){

	for (var i=1;i<=3;i++)
		{
		document.getElementById('olMostViewed' + i).style.display = 'none';
		document.getElementById('olMostCommented' + i).style.display = 'none';
		document.getElementById('olMostEmailed' + i).style.display = 'none';
		document.getElementById('liMostViewed' + i).className = 'on';
		document.getElementById('liMostCommented' + i).className = 'on';
		document.getElementById('liMostEmailed' + i).className = 'on';
		}

	document.getElementById('ol' + objname).style.display = 'block';
	document.getElementById('li' + objname).className = 'off';

}



addLoadEvent(prepareMostPopular);
