var auswahl;

$(document).ready(function(){
	feedback_form();
	refresh_tabs();
	init_tab();
	load_highscore();
	fb_init();
	activity_stream();
});

function refresh_tabs() {
	$(".hs_tab").css({
		width: "84px",
		height: "29px",
		display: "block",
		color: "#fff",
		fontWeight: "normal",
		marginLeft: "7px",
		backgroundImage: "url('img/highscore/reiter_inactive.gif')"
	});
	
	$(".hs_tab[rel='active']").css({
		color: "#408833",
		fontWeight: "bold",
		backgroundImage: "url('img/highscore/reiter_active.gif')"
	});
}

function init_tab(){
	$(".hs_tab").click(function(){
		change_hs_tab($(this).attr("id"));
		
		$("#hs_tbl").html('<div id="ajax_loader"><img src="img/ajax-loader.gif" alt="Ajax load feedback" /></div>');
				
		$.get("php/select_highscore.php", { range: $(this).attr("id")},
	   		function(data){
	    		$("#highscore #content").html(data);
				FB.XFBML.Host.parseDomTree();
	   		}
		);
				
		return false;
	});
	$(".hs_tab").hover(function(){
		$(this).css({
			textDecoration: "underline"
		});
	}, function(){
		$(this).css({
			textDecoration: "none"
		});
	});
}

function load_highscore() {
	$.get("php/select_highscore.php", { range: "today"},
   		function(data){
    		$("#highscore #content").html(data);
			FB.XFBML.Host.parseDomTree();
   		}
	);
}

function change_hs_tab(auswahl) {
	$(".hs_tab").attr("rel","inactive");
	
	$(".hs_tab#"+auswahl).attr("rel", "active");
	
	refresh_tabs();	
}