// JavaScript Document
function initGlossary(glossary){
	return;
	
	glossary.id = 'glossary';
	
	// build glossary navigation
	var glossaryNav = document.createElement('ul');
		glossaryNav.className = 'glossaryNav';
	var glossaryNavItem;
	
	// insert previous
	glossaryNavItem = document.createElement('li');
	glossaryNavItem.setAttribute('index', 'previous');
	glossaryNavItem.appendChild(document.createTextNode('«'));
	glossaryNav.appendChild(glossaryNavItem);
	
	for(var i = 65; i < 91; i++){
		glossaryNavItem = document.createElement('li');
		glossaryNavItem.setAttribute('index', i)
		glossaryNavItem.appendChild(document.createTextNode(String.fromCharCode(i)));
		glossaryNav.appendChild(glossaryNavItem);
	}
	
	// insert next
	glossaryNavItem = document.createElement('li');
	glossaryNavItem.setAttribute('index', 'next');
	glossaryNavItem.appendChild(document.createTextNode('»'));
	glossaryNav.appendChild(glossaryNavItem);
	
	for(var i = 0; i < glossaryNav.childNodes.length; i++){
		glossaryNav.childNodes[i].onclick = function(){
			var index = this.getAttribute('index');
			var glossary = this.parentNode.parentNode.getElementsByTagName('dl')[0];
			
			switch(index){
				case 'next':
					if(this.parentNode.getAttribute('currentIndex')){
						index = parseInt(this.parentNode.getAttribute('currentIndex'));
						if(index == 90){
							index = 65;
						}else{
							index = index + 1;
						}
					}else{
						this.parentNode.setAttribute('currentIndex', 65);
						index = 65;
					}
					
					glossary.className = 'glossary ' + String.fromCharCode(parseInt(index)).toLowerCase();
					this.parentNode.setAttribute('currentIndex', index);
					
					break;
				case 'previous':
					if(this.parentNode.getAttribute('currentIndex')){
						index = parseInt(this.parentNode.getAttribute('currentIndex'));
						if(index == 65){
							index = 90;
						}else{
							index = index - 1;
						}
					}else{
						this.parentNode.setAttribute('currentIndex', 90);
						index = 90;
					}
					
					glossary.className = 'glossary ' + String.fromCharCode(parseInt(index)).toLowerCase();
					this.parentNode.setAttribute('currentIndex', index);
					
					break;
				default:
					glossary.className = 'glossary ' + String.fromCharCode(parseInt(index)).toLowerCase();
					this.parentNode.setAttribute('currentIndex', index);
					break;
			}
		}
	}
	
	(glossary.parentNode).insertBefore(glossaryNav, glossary);
	
	var definitions = glossary.getElementsByTagName('dt');
	var definition; var description; var definitionText;
	
	// walk through terms
	for(var i = 0; i < glossary.childNodes.length; i++){
		if(glossary.childNodes[i].nodeName.toLowerCase() == 'dt'){
			definition = glossary.childNodes[i];
			description = definition.nextSibling;
			definitionText = definition.firstChild;
			
			while(description.nodeName.toLowerCase() != 'dd') description = description.nextSibling;
			while(definitionText.nodeType != 3) definitionText = definitionText.firstChild;
			
			definitionText 						= definitionText.nodeValue;
			definition.className 				= definitionText.charAt(0).toLowerCase();
			description.className 				= definitionText.charAt(0).toLowerCase();
		}
	}
}

