var refresh_time = 15; //seconds

$(document).ready(function(){

	$('ul.btheader').show();
	$('ul.btheader').find('li').removeClass('checked');
	
	switch_comp();
	
	$('ul.comp li').click(function(){
		$(this).parent('ul').find('li').removeClass('checked');
		$(this).find('div').addClass('active');
		switch_comp();
	});
	
	setInterval('switch_comp()', (refresh_time+2)*1000);
	
});


function switch_comp() {
	
	var title1 = "Toy Story";
	var title2 = "Blu-ray Chart: This week's ten top-selling titles";
	var title3 = "Competition";
	
	switch( $("#r_join h2").html()){
	
		case title1: 
			$("#r_join h2").html(title2);
			$("#r_join").find('#occ_chart').fadeIn();
			$("#r_join").find('#competition_cta').hide();
			$("#r_join").find('#promo_1').hide();
		break;
		case title2: 
			$("#r_join h2").html(title3);
			$("#r_join").find('#occ_chart').hide();
			$("#r_join").find('#competition_cta').fadeIn();
			$("#r_join").find('#promo_1').hide();
		break;
		case title3: 
			$("#r_join h2").html(title1);
			$("#r_join").find('#occ_chart').hide();
			$("#r_join").find('#competition_cta').hide();
			$("#r_join").find('#promo_1').fadeIn();
		break;
		default: 
			$("#r_join h2").html(title3);
			$("#r_join").find('#occ_chart').hide();
			$("#r_join").find('#competition_cta').show();
			$("#r_join").find('#promo_1').hide();
		break;
	
	}
	
	$('.btheader li div').removeClass('active');
	
}

