$(function(){

	// Init for info tabs
	$('.infotab ul a').click(function(){
		if ($(this).parents('li.active').length == 0) {
			infotabSwitch(this);
		}
		this.blur();
		return false;
	});
	$('.infotab').each(function(){
		$(this).find('div').hide().eq(0).show().addClass('active');
		$(this).find('ul li').eq(0).addClass('active');
	});
	
	// Init for TotalAccess
	$('#app-toc a').click(function(){
		if ($(this).parents('li.active').length == 0) {
			totalaccessSwitch(this);
		}
		this.blur();
		return false;
	});
	$('#app-toc li').eq(0).addClass('active');
	$('#derby-apps li').hide().eq(0).show().addClass('active');
   
  // Disable right-click on logo (yeah, yeah... I know..)
  $('#logo').bind('contextmenu', function(){return false;});
  

});

function infotabSwitch(tab) {
	// Let's reset em all
	$(tab).parents('ul').children('li').removeClass();
	$(tab).parents('.infotab').children('div.active').fadeOut('fast').removeClass();
	
	// Activate respective tab
	$(tab).parents('li').addClass('active');
	var showId = $(tab).attr('href');
	// Clean showId to work on all browsers
	showId = showId.split('#');
	showId = '#' + showId[1];
	$(showId).fadeIn('fast').addClass('active');
}

function totalaccessSwitch(tab) {
	// Let's reset em all
	$(tab).parents('ul').children('li').removeClass();
	$('#derby-apps li.active').fadeOut('fast').removeClass();
	
	// Activate respective tab
	$(tab).parents('li').addClass('active');
	var showId = $(tab).attr('href');
	// Clean showId to work on all browsers
	showId = showId.split('#');
	showId = '#' + showId[1];
	$(showId).fadeIn('fast').addClass('active');
}
