/*$(function()
{
	var anchor = location.href.split('#')[1];
	
	if (anchor)
	{		
		var tab = $("a[href='#"+anchor+"']").get(0);
		
		if (tab)
		{			
			showTabJ(tab, $(tab).parent().parent().parent().attr("id"));
		}
	}
});*/
$(function()
{
	$("a.tabLink").live('click', function(event) {
		event.stopImmediatePropagation();
		showTabJ(this, $(this).closest(".tabContainer").attr("id"));
		
		return false;
	});
});
function reloadTab(containerBase)
{
	if (!containerBase) return;
	
	var cContent = containerBase + "_content";
	
	var tabUID = $.cookie(cContent);
	if (!tabUID) return;
	
	var tabCtl = $("a[data\-uid='" + tabUID + "']");	
	
	if (!tabCtl.get(0)) return;
	
	showTabJ(tabCtl.get(0), containerBase);
}
function showTabJ(linkCtl, containerID)
{	
	var tab = document.getElementById(linkCtl.href.split('#')[1]);
	var container = $("#"+containerID);	
	
	linkCtl.hideFocus = true;
	var ct = 0;
	$("#"+containerID+"_content").children("div.tabContent").hide(); //.parents("div.tabContainer").children("div.tabPageContent").fadeOut("slow");
	$("li, td", tab).each(function(i)
	{
		var bgImg = $(this).css('background-image');
		
		//IE made this easy for us to hack it's worthless png rendering... it puts the values in quotes!!
		if (bgImg.match(/png\"\)$/))
		{			
			$(this).addClass('no-bg');
		}
	});
	
	$(tab).fadeIn("slow", function(){
		$("li, td", this).each(function(i)
		{
			$(this).removeClass('no-bg');
		});	
	});
	
	container.children("ul.menuList").children("li").removeClass("selected");
	$(linkCtl).parent("li").addClass("selected");
	
	$.cookie(containerID+"_content", $(linkCtl).attr("data-uid"));
	
	//Increment the counter on tab click (for a better traffic representation)
	//$.get("http://www.fraggednation.com/index.php?callback=?",{tc:1},function(){alert('called!');});
	//$.getJSON("http://beta.fraggednation.com/index.php?tc=1&jsoncallback=?");
}