/**
* Collapse.js
*
* 12/18/2009 - Rob Shortley
* Including this file will add a click event listener
* that works in both IE and Firefox, which will 
* allow for Definition Lists <DL> with a class 
* of "collapsable-list" to change out class names
* of the <DD> when the <DT> above it is clicked,
* effectively allowing them to expand and collapse
* as defined in the CSS.
*
* On code date, this works in IE6-8, Firefox 3.5.5,
* Safari 4.x, Opera 10.x, and Chrome.
*/
	

// Adding the listener	
	if (document.addEventListener) {
	  document.addEventListener('click',mouseEvent,false);
	} else if (document.attachEvent) {
	  document.attachEvent('onclick',mouseEvent);
	} else {
	  document.onclick = mouseEvent;
	}

// Mouse Event
	function mouseEvent(e) {
		var targ;
		if (!e) var e = window.event;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		if (targ.nodeType == 3)
			targ = targ.parentNode;
		expandLi(targ);
	}
	
// Class switcher	
	function expandLi(targ) {				
		if ((targ.tagName == "DT")&&(targ.parentNode.className == "collapsable-list")){			
			var nextNode = targ.nextSibling;
			
			 			
			while (nextNode.tagName != "DD"){ 
				nextNode = nextNode.nextSibling
			}
			
			if (nextNode.className == "open"){
				nextNode.className = "closed";
			}
			else {nextNode.className = "open";}
			
			
			if (targ.className == "open"){
				targ.className = "closed";
			}
			else {targ.className = "open";}
			
		}else if ((targ.parentNode.tagName == "DT")&&(targ.parentNode.parentNode.className == "collapsable-list")){			
			var nextNode = targ.parentNode.nextSibling;
			
				
			while (nextNode.tagName != "DD"){ 
				nextNode = nextNode.nextSibling
			}	
			
			if (nextNode.className == "open"){
				nextNode.className = "closed";
			}
			else {nextNode.className = "open";}
			
			if (targ.className == "open"){
				targ.className = "closed";
			}
			else {targ.className = "open";}
			
		}else if ((targ.parentNode.parentNode.tagName == "DT")&&(targ.parentNode.parentNode.parentNode.className == "collapsable-list")){			
			var nextNode = targ.parentNode.parentNode.nextSibling;
			
				
			while (nextNode.tagName != "DD"){ 
				nextNode = nextNode.nextSibling
			}	
			
			if (nextNode.className == "open"){
				nextNode.className = "closed";
			}
			else {nextNode.className = "open";}
			
			
			if (targ.className == "open"){
				targ.className = "closed";
			}
			else {targ.className = "open";}
		}

	}
	
/**
* SAMPLE CLASSES
*<style type="text/css">
*	body{font-family:Arial, Helvetica, sans-serif; font-size:.8em;}
*	
*	dl.collapsable-list{
*		background:transparent none repeat scroll 0 0;
*		font-size:100%;
*		list-style-type:none;
*		line-height:1.5em;
*		margin:0;
*		padding:0 0 0 0;
*	}
*	
*	dl.collapsable-list dt{
*		list-style-position:outside;
*		list-style-type:none;
*		margin-top:0px;
*		margin-bottom:0px;
*		text-decoration:underline;
*		color:blue;
*		cursor:pointer;
*	}
*	dl.collapsable-list dd, dl.collapsable-list dd.closed{
*		height:3em;
*		overflow:hidden;
*		text-decoration:none !important;
*		color:#333333;
*		cursor:default;
*	}
*	dl.collapsable-list dd.open{
*		height:auto;
*		overflow:hidden;
*		text-decoration:none !important;
*		color:#333333;
*		cursor:default;
*	}
*</style>
*
*/	
	