/******************
*
*  	Filename: tabs.js
*
*  	Created By: Tommy Logik
*
*	Description: This file is used to make tabs work.
*
*	Note: this files requires jQuery to be initialized or it will throw errors.
*
*******************/
$(document).ready(function(){
	$('#tabs-regions').click(function(){		  
		if($(this).hasClass('selected')){} else {
			$('#tabs-topics').removeClass('selected');$(this).addClass('selected');
			$('#topic-content').hide(0);
			$('#region-content').show(0);
		}
		return false;
	});
	$('#tabs-topics').click(function(){
		if($(this).hasClass('selected')){} else {
			$(this).addClass('selected')
			$('#tabs-regions').removeClass('selected');
			$('#region-content').hide(0);
			$('#topic-content').show(0);
		};
		return false;
	});
	
	$('#tabs-term').click(function(){
		if($(this).hasClass('selected')){} else {
			$(this).addClass('selected')
			$('#tabs-law').removeClass('selected');
			$('#tabs-crime').removeClass('selected');
			$('#crime-content').hide(0);
			$('#law-content').hide(0);
			$('#term-content').show(0);
		};
		return false;
	});
	$('#tabs-law').click(function(){
		if($(this).hasClass('selected')){} else {
			$(this).addClass('selected')
			$('#tabs-term').removeClass('selected');
			$('#tabs-crime').removeClass('selected');
			$('#term-content').hide(0);
			$('#crime-content').hide(0);
			$('#law-content').show(0);
		};
		return false;
	});
	$('#tabs-crime').click(function(){
		if($(this).hasClass('selected')){} else {
			$(this).addClass('selected')
			$('#tabs-term').removeClass('selected');
			$('#tabs-law').removeClass('selected');
			$('#term-content').hide(0);
			$('#law-content').hide(0);
			$('#crime-content').show(0);
		};
		return false;
	});
	

	

	$('#tabs #glossary').click(function(){
		if($(this).hasClass('highlighted-tab')){} else {
			$('#tabs #commentary').removeClass('highlighted-tab');
			$('#tabs #glossary').addClass('highlighted-tab');
			$('#tabs-commentary').hide(0);
			$('#tabs-glossary').show(0);
		}  
	});

	$('#tabs #commentary').click(function(){
		if($(this).hasClass('highlighted-tab')){} else {
			$('#tabs #glossary').removeClass('highlighted-tab');
			$('#tabs #commentary').addClass('highlighted-tab');
			$('#tabs-glossary').hide(0);
			$('#tabs-commentary').show(0);
		}							  
	});
	
	// Check to see which tab is to be revealed
	
	// Glossary Section
	if($('body').hasClass('category-law')){
		$('#tabs #glossary').addClass('highlighted-tab');
		$('#tabs #commentary').removeClass('highlighted-tab');
		$('#tabs-crime').removeClass('selected');
		$('#tabs-law').addClass('selected');
		$('#tabs-glossary').show(0);
		$('#tabs-commentary').hide(0);
		$('#crime-content').hide(0);
		$('#law-content').show(0);
		$('#term-content').hide(0);
	};
	if($('body').hasClass('category-term')){
		$('#tabs #glossary').addClass('highlighted-tab');
		$('#tabs #commentary').removeClass('highlighted-tab');
		$('#tabs-crime').removeClass('selected');
		$('#tabs-term').addClass('selected');
		$('#tabs-glossary').show(0);
		$('#tabs-commentary').hide(0);
		$('#crime-content').hide(0);
		$('#law-content').hide(0);
		$('#term-content').show(0);
	};
	if($('body').hasClass('category-crime')){
		$('#tabs #glossary').addClass('highlighted-tab');
		$('#tabs #commentary').removeClass('highlighted-tab');
		$('#tabs-glossary').show(0);
		$('#tabs-commentary').hide(0);
	};
	
	// Commentary Section
	if($('body').hasClass('category-topics')){
		$('#region-content').hide(0);
		$('#topic-content').show(0);
		$('#tabs-regions').removeClass('selected');
		$('#tabs-topics').addClass('selected');
	};
	
});
