
var fade_next = 1
function setFadeNext(value) {
	fade_next = value;
}
$("document").ready(function() {
	
	$('#tabs .stats-header a').each(function() {
		if($(this).attr("class")=="notselected") {
			$("#block_"+$(this).attr("id")).hide();
		} 
	});
	
	
	
	function show_hide_all() {
		$('#tabs .stats-header a').each(function() {
			if($(this).attr("class")=="notselected") {
				if($("#block_"+$(this).attr("id")).css("display")!="none") {
					$("#block_"+$(this).attr("id")).fadeOut(250);
				}
			} else {
				div_height = $("#block_"+$(this).attr("id")).height()+52;
				$("#tab_content_keeper").css("height", div_height);
				setFadeNext(0);
				setTimeout('$("#block_'+$(this).attr("id")+'").fadeIn(500, function() { setFadeNext(1); } );', 255);
				
			}
		});
	}
	
	function deselect_all() {
		$('#tabs .stats-header a').each(function() {
			if($(this).attr("class")=="selected") {
				$(this).attr("class", "notselected");
			}
		});
	}
	
	
	$('#tabs .stats-header a').click(function() {
		//hide rest and let this not hidden
		if(fade_next) {
			deselect_all();
			$(this).attr("class", "selected");
			show_hide_all();
		}
		
		return false;
	});
	
});
