function toggle() {
	if (document.getElementById)
	{
		var toggle_div = document.getElementById('toggle');
		var triggers = toggle_div.getElementsByTagName('h2');
		for(var i=0;i<triggers.length;i++)
		{
		
		//Figure out what should be opened and closed.
			var tohide=triggers[i].nextSibling;
			while(tohide.nodeType!=1)
			{
				tohide=tohide.nextSibling;
			}
			//open all parts that should be open, and set their parents to be ready to close them
			cssjs('add',tohide,'hidden')
			cssjs('add',triggers[i],'open')
			triggers[i].tohide=tohide;
			//Make them act more like links so the user gets a response
			triggers[i].onmouseover=function()
			{
				cssjs('add',this,'hover');
			}
			triggers[i].onmouseout=function()
			{
				cssjs('remove',this,'hover');
			}
			triggers[i].onclick=function()
			{
				if(cssjs('check',this.tohide,'hidden'))
				{
					cssjs('swap',this,'trigger','open');			
					cssjs('swap',this.tohide,'hidden','shown');			
				} else {
					cssjs('swap',this,'open','trigger');			
					cssjs('swap',this.tohide,'shown','hidden');			
				}
			}
		}
	}  
}

function cssjs(a,o,c1,c2)
{
//Applies action a to object o by adding, removing, swapping, or checking for classes c1 or c2.
	switch (a){
		case 'swap':
	o.className=!cssjs('check',o,c1)?o.className.replace(c2,c1):o.className.replace(c1,c2);
		break;
		case 'add':
			if(!cssjs('check',o,c1)){o.className+=o.className?' '+c1:c1;}
		break;
		case 'remove':
			var rep=o.className.match(' '+c1)?' '+c1:c1;
			o.className=o.className.replace(rep,'');
		break;
		case 'check':
			return new RegExp('\\b'+c1+'\\b').test(o.className)
		break;
	}
}
