// /expandos.js

// ----------------------------
	function toggleExpando(prefix, id, state) {
		
		var theTbody      = document.getElementById(prefix + "Tbody_"   + id         ); if (!theTbody     ) {alert("cannot find tbody for "   + prefix + " " + id); return;}
		var theExpandoImg = document.getElementById(prefix + "Expando_" + id + "_img"); if (!theExpandoImg) {alert("cannot find expando for " + prefix + " " + id); return;}

		// optional incoming desired state
		var desiredState; 
		if (!state) {     // no incoming - toggle it
			if (theExpandoImg.src.indexOf("plus.gif") > -1) {desiredState = "open";} else {desiredState = "closed";}
		} else {          // incoming - use it
			desiredState = state;
		}
		
		var display;
		if (desiredState == "open") {display = "";} else {display = "none";}
	
		for (var i=0; i < theTbody.rows.length; i++) {
			var thisRow = theTbody.rows[i];
			thisRow.style.display = display;
			if (theTbody.nextSibling && theTbody.nextSibling.nodeName == "TBODY" && theTbody.nextSibling.id != "" ) {
				var nextTbody = theTbody.nextSibling;
				var tbodyStarts = nextTbody.id.indexOf("Tbody_");
				var tbodyEnds = tbodyStarts + "Tbody_".length;
				var thisPrefix = nextTbody.id.substring(0,tbodyStarts);
				var thisId = nextTbody.id.substring(tbodyEnds);
				toggleExpando(thisPrefix, thisId, desiredState);
			}
		}
	
		if (desiredState == "open") {theExpandoImg.src = "/images-V2/minus.gif";
		} else                      {theExpandoImg.src = "/images-V2/plus.gif";}
	
		return;
		
	}
	
