$(window).load(function()
{
	// get some info we'll need down the line
	var tabs = $('#tabsNavigation a');
	var elements = tabs.size();
	var hash = window.location.hash;
	
	// if the has was empty, just pick the first tab to show
	if(hash == '') hash = $('a[rel^="default"]').attr('href');

	// loop all tabs and set appropriate properties
	tabs.each(function(){ setTabProperties(this, hash) });
	
	// a link in the tabs div is clicked
	$(tabs).click(function(e)
	{
		// prevent default
		e.preventDefault();
		
		// store the value of rel as the ID
		var id = $(this).attr('href');
		
		// loop all tabs and sets the appropriate properties for this tab
		tabs.each(function(){ setTabProperties(this, id) });
	});
});


function setTabProperties(reference, id)
{
	// get href and the rel value of the referenced anchor element
	var href = $(reference).attr('href');
	
	// if the href is referring to the ID, we show the content of the requested tab
	if(href == id)
	{
		$(href).show();
		$('a[href^='+ href +']').parent().addClass('selected');
	}
	else 
	{
		$(href).hide();
		$('a[href^='+ href +']').parent().removeClass('selected');
	}
}
