/*
Programmer: Darryl Ballard
Last Modified: 2008-04-16
Version: 1.0

Requires:
	addLoadEvent()
	
Version History:
*/

function GST_getNextElement(objSource, strNextTagName)
{
	while (objSource.nextSibling) {
		objSource = objSource.nextSibling;
		
		if (objSource.nodeType == 1 /* Element Node */) {
			if (objSource.tagName.toLowerCase() == strNextTagName.toLowerCase()) {
				return objSource;
			}
		}
	}
	
	return false;
}

/* Make a DL's DTs toggle the DDs */
function GST_Activate_Def_Lists()
{
	var lists;
	var k, m;
	var terms, definitions;
	var objNextDef;
	
	// Get all DLs
	lists = document.getElementsByTagName('dl');
	
	// Loop through all the lists
	for(k = 0; k < lists.length; k++)
	{
		// Check that it's classed to be activated
		if (lists[k].className != 'toggle' && lists[k].indexOf(' toggle') <= -1) {
			continue;
		}
	
		// Get the terms in this list
		terms = lists[k].getElementsByTagName('dt');
		
		// Activate the terms
		for(m = 0; m < terms.length; m++)
		{
			terms[m].className = "scripted";
			terms[m].onmouseover = function()
			{
				this.className = 'scripted_hover';
			}
			terms[m].onmouseout = function()
			{
				this.className = 'scripted';
			}
			
			objNextDef = GST_getNextElement(terms[m], 'dd');
			if (objNextDef != false) {
				objNextDef.className = 'scripted_hidden';
			}
			
			terms[m].onclick = function()
			{
				var obj = GST_getNextElement(this, 'dd');

				if (obj != false) {
					obj.className = (obj.className == 'scripted_hidden') ? '' : 'scripted_hidden';
				}
			}
		} // end for(m)
	} // end for(k)
}

if (typeof addLoadEvent == 'function') {
	addLoadEvent(GST_Activate_Def_Lists);
}
