$(document).ready(function() {
	$('.history-link a').click(popupHistory);
});

function popupHistory(event) {
	if ($("#history-data").length == 0) {
		$(document.body).append('<div id="history-data"></div>');
	}
	else {
		$("#history-data").empty().hide();
	}
	$("#history-data").css("left", event.pageX + 10 + "px").css("top", event.pageY + 10 + "px").load(this.href, function () {
		$("#history-data").fadeIn("250");
		$("#history-data span.close a").click(function () {
			$("#history-data").fadeOut("250", function () {
				$("#history-data").remove();
			});
			return false;
		});
	});
	return false;
}

function get_tab_team_stat(el, url) {
	// needed to react fast
	if($(el).parent().hasClass('active'))
		return false;
	$('.tabs li', $(el).parents('.results')).removeClass('active');
	$(el).parent().addClass('active');

	$('#tab_container').addClass('load-animation');
	$('#tab_container', $(el).parents('.results')).html('');
	$('#tab_container', $(el).parents('.results')).load(
		url,
		{},
		function() {
			// needed to show real active tab
			$('.tabs li', $(el).parents('.results')).removeClass('active');
			$(el).parent().addClass('active');
			$('#tab_container').removeClass('load-animation');
		}
	);
	return false;
}
