﻿$(document).ready(function(){
	GLOSSARY.Load();
	GLOSSARY.Listener();
});

var GLOSSARY = {
	Load:function(){
		$('div.glossaryContent').hide();
		$('ul#glossaryMenu li').removeClass('active');
	
		if(((window.location.hash) == "") || ((window.location.hash) == "#viewAll")) {
			GLOSSARY.viewAll();
		}
		else {
			var targetGlossary = 'div#' + window.location.hash + 'Glossary';
			$(targetGlossary).show();
			var targetTab = 'ul#glossaryMenu li.' + (window.location.hash).split('#')[1];
			$(targetTab).addClass('active');
		}
	},
	Listener:function(){
		$('ul#glossaryMenu li a').live("click", function(event) {
			$('ul#glossaryMenu li').removeClass('active');
			if ($(this).parent().hasClass('empty')) {
				return false;
			}
			else if ($(this).parent().hasClass('viewAll')) {
				GLOSSARY.viewAll();
			} else {
				$('div.glossaryContent').hide();
				var targetGlossary = 'div#' + $(this).attr('href') + 'Glossary';
				$(targetGlossary).show().addClass('show').removeClass('hide');
				$(this).parent().addClass('active');
			}
		});
	},
	viewAll:function(){
		$('div#abcGlossary').show().addClass('all');
		$('div#defGlossary, div#ghiGlossary, div#jklGlossary, div#mnoGlossary, div#pqrsGlossary, div#tuvGlossary').show().addClass('hide');
		$('ul#glossaryMenu li.viewAll').addClass('active');
	}
};
